Conversion of unix epoch time to windows epoch time in python
Question: Quick question: Is there a pythonic (whether in the standard libraries or not)
way to convert unix 32-bit epoch time to windows 64-bit epoch time and back
again?


Answer: You can convert a POSIX timestamp to a `datetime` with

    
    
    >>> tstamp = 1325178061  # right about now
    >>> from datetime import datetime
    >>> datetime.fromtimestamp(tstamp)
    datetime.datetime(2011, 12, 29, 18, 1, 1)
    

The
[`fromtimestamp`](http://docs.python.org/library/datetime.html#datetime.datetime.fromtimestamp)
named constructor accepts POSIX timestamps on all platforms (!).

Conversion to a Windows timestamp would be a matter of subtracting the Windows
epoch, which [Wikipedia
says](http://en.wikipedia.org/wiki/Epoch_%28reference_date%29) is January 1,
1601, and converting the resulting `timedelta` to a number of seconds:

    
    
    >>> W_EPOCH = datetime(1601, 1, 1)
    >>> (datetime.fromtimestamp(tstamp) - W_EPOCH).total_seconds()
    12969655261.0
    

Now you've got a `float` that you convert to `int` and store as a 64-bit
quantity in whichever way you like.

