Package amplee :: Package utils :: Module isodate
[hide private]
[frames] | no frames]

Module isodate

source code


isodate.py

Functions for manipulating a subset of ISO8601 date, as specified by
  <http://www.w3.org/TR/NOTE-datetime>
  
Exposes:
  - parse(s)
    s being a conforming (regular or unicode) string. Raises ValueError for
    invalid strings. Returns a float (representing seconds from the epoch; 
    see the time module).
    
  - parse_datetime(s)   # if datetime module is available
    s being a conforming (regular or unicode) string. Raises ValueError for
    invalid strings. Returns a datetime instance.
    
  - asString(i)
    i being an integer or float. Returns a conforming string.
  
TODO:
  - Precision? it would be nice to have an interface that tells us how
    precise a datestring is, so that we don't make assumptions about it; 
    e.g., 2001 != 2001-01-01T00:00:00Z.

Thanks to Andrew Dalke for datetime support.


Version: 0.7

License: Copyright (c) 2002-2005 Mark Nottingham <mnot@pobox.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Note: datetime support added by Andrew Dalke <dalke@dalkescientific.com>. All copyrightable changes by Andrew Dalke are released into the public domain. No copyright protection is asserted.

Functions [hide private]
 
parse(s)
parse a string and return seconds since the epoch.
source code
 
parse_datetime(s)
parse a string and return a datetime object.
source code
 
asString(i)
given seconds since the epoch, return a dateTime string.
source code
 
_cross_test() source code
Variables [hide private]
  _has_datetime = 1
  date_parser = re.compile(r'(?x)^(?P<year>\d{4})(?:-(?P<month>\...
Variables Details [hide private]

date_parser

Value:
re.compile(r'(?x)^(?P<year>\d{4})(?:-(?P<month>\d{1,2})(?:-(?P<day>\d{\
1,2})(?:T(?P<hour>\d{1,2}):(?P<minute>\d{1,2})(?::(?P<second>\d{1,2})(\
?:\.(?P<dec_second>\d+)?)?)?(?:Z|(?:(?P<tz_sign>[\+-])(?P<tz_hour>\d{1\
,2}):(?P<tz_min>\d{2}))))?)?)?$')