Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
icalendar.prop.vDatetime Class Reference

List of all members.

Public Member Functions

def __init__
def ical
def from_ical
def __str__

Public Attributes

 dt
 params

Static Public Attributes

tuple from_ical = staticmethod(from_ical)

Detailed Description

Render and generates iCalendar datetime format.

Important: if tzinfo is defined it renders itself as "date with utc time"
Meaning that it has a 'Z' appended, and is in absolute time.

>>> d = datetime(2001, 1,1, 12, 30, 0)

>>> dt = vDatetime(d)
>>> dt.ical()
'20010101T123000'

>>> vDatetime.from_ical('20000101T120000')
datetime.datetime(2000, 1, 1, 12, 0)

>>> dutc = datetime(2001, 1,1, 12, 30, 0, tzinfo=UTC)
>>> vDatetime(dutc).ical()
'20010101T123000Z'

>>> vDatetime.from_ical('20010101T000000')
datetime.datetime(2001, 1, 1, 0, 0)

>>> vDatetime.from_ical('20010101T000000A')
Traceback (most recent call last):
  ...
ValueError: Wrong datetime format: 20010101T000000A

>>> utc = vDatetime.from_ical('20010101T000000Z')
>>> vDatetime(utc).ical()
'20010101T000000Z'

Definition at line 262 of file prop.py.


Constructor & Destructor Documentation

def icalendar.prop.vDatetime.__init__ (   self,
  dt 
)

Definition at line 295 of file prop.py.

00295 
00296     def __init__(self, dt):
00297         self.dt = dt
00298         self.params = Parameters()


Member Function Documentation

Definition at line 328 of file prop.py.

00328 
00329     def __str__(self):
00330         return self.ical()
00331 
00332 

Here is the call graph for this function:

Definition at line 306 of file prop.py.

00306 
00307     def from_ical(ical):
00308         "Parses the data format from ical text format"
00309         try:
00310             timetuple = map(int, ((
00311                 ical[:4],       # year
00312                 ical[4:6],      # month
00313                 ical[6:8],      # day
00314                 ical[9:11],     # hour
00315                 ical[11:13],    # minute
00316                 ical[13:15],    # second
00317                 )))
00318             if not ical[15:]:
00319                 return datetime(*timetuple)
00320             elif ical[15:16] == 'Z':
00321                 timetuple += [0, UTC]
00322                 return datetime(*timetuple)
00323             else:
00324                 raise ValueError, ical
00325         except:
            raise ValueError, 'Wrong datetime format: %s' % ical

Definition at line 299 of file prop.py.

00299 
00300     def ical(self):
00301         if self.dt.tzinfo:
00302             offset = self.dt.tzinfo.utcoffset(datetime.now())
00303             utc_time = self.dt - self.dt.tzinfo.utcoffset(datetime.now())
00304             return utc_time.strftime("%Y%m%dT%H%M%SZ")
00305         return self.dt.strftime("%Y%m%dT%H%M%S")

Here is the caller graph for this function:


Member Data Documentation

Definition at line 296 of file prop.py.

tuple icalendar.prop.vDatetime.from_ical = staticmethod(from_ical) [static]

Definition at line 326 of file prop.py.

Definition at line 297 of file prop.py.


The documentation for this class was generated from the following file: