Trees | Indices | Help |
|
---|
|
1 ### BITPIM 2 ### 3 ### Copyright (C) 2006 Joe Pham <djpham@bitpim.org> 4 ### 5 ### This program is free software; you can redistribute it and/or modify 6 ### it under the terms of the BitPim license as detailed in the LICENSE file. 7 ### 8 ### $Id: prototypes_moto.py 3460 2006-07-08 23:55:09Z djpham $ 9 10 """Implement specific prototypes class for Motorola phones""" 11 12 import re 13 14 import prototypes 1517 """Dates used for Calendar Events (mm-dd-yyyy)"""5719 super(CAL_DATE, self).__init__(*args, **kwargs) 20 self._valuedate=(0, 0, 0) # y,m,d 21 if self._ismostderived(CAL_DATE): 22 self._update(args, kwargs)2325 s='' 26 if len(date)>=3: 27 year,month,day=date[:3] 28 if month>0 or day>0 or year>0: 29 s='%2.2d-%2.2d-%4.4d'%(month, day, year) 30 return s3133 for k in ('constant', 'default', 'value'): 34 if kwargs.has_key(k): 35 kwargs[k]=self._converttostring(kwargs[k]) 36 if len(args)==0: 37 pass 38 elif len(args)==1: 39 args=(self._converttostring(args[0]),) 40 else: 41 raise TypeError("expected (year,month,day) as arg") 42 super(CAL_DATE, self)._update(args, kwargs) 43 self._complainaboutunusedargs(CAL_DATE, kwargs)4459 """Times used for Calendar Events (hh:mm)"""9161 super(CAL_TIME, self).__init__(*args, **kwargs) 62 self._valuetime=(0, 0) # h,m 63 if self._ismostderived(CAL_TIME): 64 self._update(args, kwargs)65 7173 for k in ('constant', 'default', 'value'): 74 if kwargs.has_key(k): 75 kwargs[k]=self._converttostring(kwargs[k]) 76 if len(args)==0: 77 pass 78 elif len(args)==1: 79 args=(self._converttostring(args[0]),) 80 else: 81 raise TypeError("expected (hour, min) as arg") 82 super(CAL_TIME, self)._update(args, kwargs) 83 self._complainaboutunusedargs(CAL_TIME, kwargs)8493 """ Represent date time with the format 'yyyy/M+/d+,h+:m+:s+' used 94 by Motorola SMS messages. 95 Currently works only 1 way: SMS Date Time -> ISO String 96 """ 97 _re_pattern='^\d\d+/\d+/\d+,\d+:\d+:\d+$' 98 _re_compiled_pattern=None123100 if M_SMSDATETIME._re_compiled_pattern is None: 101 M_SMSDATETIME._re_compiled_pattern=re.compile(M_SMSDATETIME._re_pattern) 102 super(M_SMSDATETIME, self).__init__(*args, **kwargs) 103 if self._ismostderived(M_SMSDATETIME): 104 self._update(args, kwargs)105107 super(M_SMSDATETIME, self)._update(args, kwargs) 108 # strip blanks, and replace quotechar 109 if self._value: 110 self._value=self._value.strip(' ').replace('"', '') 111 if self._value and \ 112 not re.match(M_SMSDATETIME._re_compiled_pattern, self._value): 113 raise ValueError('Correct Format: [yy]yy/[M]M/[d]d,[h]h:[m]m:[s]s')114116 """Returns the ISO Format 'yyyyMMddThhmmss""" 117 if self._value: 118 _d,_t=self._value.strip(' ').replace('"', '').split(',') 119 _d=_d.split('/') 120 _t=_t.split(':') 121 return '%s%s%sT%s%s%s'%(_d[0].zfill(4), _d[1].zfill(2), _d[2].zfill(2), 122 _t[0].zfill(2), _t[1].zfill(2), _t[2].zfill(2))
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Jan 24 16:21:55 2010 | http://epydoc.sourceforge.net |