Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time.mktime returns unexpected results #209

Open
azmeuk opened this issue Sep 12, 2017 · 0 comments
Open

time.mktime returns unexpected results #209

azmeuk opened this issue Sep 12, 2017 · 0 comments
Labels

Comments

@azmeuk
Copy link
Contributor

azmeuk commented Sep 12, 2017

The time.mktime function takes a local time argument and returns a timestamp, but it seems the system timezone is used over the tz_offset value.

# dt.py

import freezegun, datetime, time
with freezegun.freeze_time("1970-01-01 00:00:00"):
    timetuple = datetime.datetime.now().timetuple()
    print(timetuple)

    mktime = time.mktime(timetuple)
    print(mktime)
$ env TZ=UTC-1 python dt.py
time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=-1)
-3600.0

The expected value of time.mktime is 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants