utils.py
branchstable
changeset 4501 71ba2d0f34f2
parent 4317 b2093f8f0493
child 4510 8dc44329f5c8
equal deleted inserted replaced
4457:297a63704761 4501:71ba2d0f34f2
    13 import sys
    13 import sys
    14 import decimal
    14 import decimal
    15 import datetime as pydatetime
    15 import datetime as pydatetime
    16 from md5 import md5
    16 from md5 import md5
    17 from datetime import datetime, timedelta, date
    17 from datetime import datetime, timedelta, date
    18 from time import time, mktime
    18 from time import time
    19 from random import randint, seed
    19 from random import randint, seed
    20 from calendar import monthrange
    20 from calendar import monthrange, timegm
    21 
    21 
    22 # initialize random seed from current time
    22 # initialize random seed from current time
    23 seed()
    23 seed()
    24 try:
    24 try:
    25     strptime = datetime.strptime
    25     strptime = datetime.strptime
    42         return somedate
    42         return somedate
    43     assert isinstance(somedate, date), repr(somedate)
    43     assert isinstance(somedate, date), repr(somedate)
    44     return datetime(somedate.year, somedate.month, somedate.day)
    44     return datetime(somedate.year, somedate.month, somedate.day)
    45 
    45 
    46 def datetime2ticks(date):
    46 def datetime2ticks(date):
    47     return mktime(date.timetuple()) * 1000
    47     return timegm(date.timetuple()) * 1000
    48 
    48 
    49 ONEDAY = timedelta(days=1)
    49 ONEDAY = timedelta(days=1)
    50 ONEWEEK = timedelta(days=7)
    50 ONEWEEK = timedelta(days=7)
    51 
    51 
    52 def days_in_month(date_):
    52 def days_in_month(date_):