Project

General

Profile

« Previous | Next » 

Revision 1263

dates.py: Added strtotime() to wrap dateutil.parser.parse() with default defaulting to epoch, so that e.g. months with day missing default to day 1 instead of the current day of the month

View differences:

lib/dates.py
22 22

  
23 23
epoch = from_timestamp(0)
24 24

  
25
def total_seconds(timedelta_): return timestamp(epoch + timedelta_)
26

  
25 27
def now(): return datetime.datetime.now(utc)
26 28

  
27 29
def strftime(format, datetime_):
......
34 36
        .replace('%d', '%02d' % datetime_.day)
35 37
        )
36 38

  
37
def total_seconds(timedelta_): return timestamp(epoch + timedelta_)
39
def strtotime(str_, default=epoch):
40
    import dateutil.parser
41
    return dateutil.parser.parse(str_, default=default)

Also available in: Unified diff