xbox.webapi.common.filetimes module
Tools to convert between Python datetime instances and Microsoft times.
- class xbox.webapi.common.filetimes.UTC[source]
Bases:
tzinfo
- utcoffset(dt)[source]
datetime -> timedelta showing offset from UTC, negative values indicating West of UTC
- xbox.webapi.common.filetimes.dt_to_filetime(dt)[source]
Converts a datetime to Microsoft filetime format. If the object is time zone-naive, it is forced to UTC before conversion.
>>> "%.0f" % dt_to_filetime(datetime(2009, 7, 25, 23, 0)) '128930364000000000'
>>> "%.0f" % dt_to_filetime(datetime(1970, 1, 1, 0, 0, tzinfo=utc)) '116444736000000000'
>>> "%.0f" % dt_to_filetime(datetime(1970, 1, 1, 0, 0)) '116444736000000000'
>>> dt_to_filetime(datetime(2009, 7, 25, 23, 0, 0, 100)) 128930364000001000
- xbox.webapi.common.filetimes.filetime_to_dt(ft)[source]
Converts a Microsoft filetime number to a Python datetime. The new datetime object is time zone-naive but is equivalent to tzinfo=utc.
>>> filetime_to_dt(116444736000000000) datetime.datetime(1970, 1, 1, 0, 0)
>>> filetime_to_dt(128930364000000000) datetime.datetime(2009, 7, 25, 23, 0)
>>> filetime_to_dt(128930364000001000) datetime.datetime(2009, 7, 25, 23, 0, 0, 100)