Back to index

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

List of all members.

Public Member Functions

def __init__
def ical
def from_ical
def __str__

Public Attributes

 dt

Static Public Attributes

tuple from_ical = staticmethod(from_ical)

Detailed Description

A combined Datetime, Date or Duration parser/generator. Their format cannot
be confused, and often values can be of either types. So this is practical.

>>> d = vDDDTypes.from_ical('20010101T123000')
>>> type(d)
<type 'datetime.datetime'>

>>> repr(vDDDTypes.from_ical('20010101T123000Z'))[:65]
'datetime.datetime(2001, 1, 1, 12, 30, tzinfo=<icalendar.prop.UTC '

>>> d = vDDDTypes.from_ical('20010101')
>>> type(d)
<type 'datetime.date'>

>>> vDDDTypes.from_ical('P31D')
datetime.timedelta(31)

>>> vDDDTypes.from_ical('-P31D')
datetime.timedelta(-31)

Bad input
>>> vDDDTypes(42)
Traceback (most recent call last):
    ...
ValueError: You must use datetime, date or timedelta

Definition at line 532 of file prop.py.


Constructor & Destructor Documentation

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

Definition at line 561 of file prop.py.

00561 
00562     def __init__(self, dt):
00563         "Returns vDate from"
00564         wrong_type_used = 1
00565         for typ in (datetime, date, timedelta):
00566             if isinstance(dt, typ):
00567                 wrong_type_used = 0
00568         if wrong_type_used:
00569             raise ValueError ('You must use datetime, date or timedelta')
00570         self.dt = dt


Member Function Documentation

Definition at line 593 of file prop.py.

00593 
00594     def __str__(self):
00595         return self.ical()
00596 
00597 

Here is the call graph for this function:

Definition at line 582 of file prop.py.

00582 
00583     def from_ical(ical):
00584         "Parses the data format from ical text format"
00585         u = ical.upper()
00586         if u.startswith('-P') or u.startswith('P'):
00587             return vDuration.from_ical(ical)
00588         try:
00589             return vDatetime.from_ical(ical)
00590         except:
            return vDate.from_ical(ical)

Definition at line 571 of file prop.py.

00571 
00572     def ical(self):
00573         dt = self.dt
00574         if isinstance(dt, datetime):
00575             return vDatetime(dt).ical()
00576         elif isinstance(dt, date):
00577             return vDate(dt).ical()
00578         elif isinstance(dt, timedelta):
00579             return vDuration(dt).ical()
00580         else:
00581             raise ValueEror ('Unknown date type')

Here is the caller graph for this function:


Member Data Documentation

Definition at line 569 of file prop.py.

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

Definition at line 591 of file prop.py.


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