I have some trouble understanding time conversions in python.
I have two identical time_struct objects
In [22]: local_dt
Out[22]: datetime.datetime(2000, 1, 1, 0, 0, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>)
In [23]: local_dt.timetuple()
Out[24]: time.struct_time(tm_year=2000, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=1, tm_isdst=0)
When I feed it to the time.mktime function on one machine
time.mktime(local_dt.timetuple())
it returns 946681200.0
On a second machine I get a different answer
In [31]: local_dt.timetuple()
Out[31]: time.struct_time(tm_year=2000, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=1, tm_isdst=0)
In [32]: time.mktime(local_dt.timetuple())
Out[32]: 946684800.0
The machines have different timezones, though:
In [44]: time.tzname
Out[44]: ('Europe', 'Europe')
In [45]: time.tzname
Out[45]: ('CET', 'CEST')
The documentation on the time module says:
Use the following functions to convert between time representations: struct_time in local time seconds since the epoch mktime()
As I understand my local time is "America/Los_Angeles" so seconds since epoch should be exactly the same and not be depending on the system configuration.
What am I misunderstanding? How do I have to calculate the timestamp correctly then?