time.localtime() reports local time 1 hour later than actual

Open
#570 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, python

Research direction

Start by running the reported time.localtime(), time.timezone, time.altzone, and time.daylight examples under IronPython 3 and CPython around the DST boundary. Trace the time module's local-time and timezone conversion entry points; done means IronPython reports the same local hour and timezone values as CPython before and after the transition.

Written by the indexing model from the issue text.

Description

Prerequisites
  • Are you running the latest version?
  • Are you reporting to the correct repository?
  • Did you perform a cursory search?
Description

On the night of DST taking effect in Canada, time.localtime() reports local time 1 hour later than actual.

Steps to Reproduce
import time
t = time.time()
print(time.localtime(t))

Expected behavior:

Output produced by Python 3.4 (correct hour):

time.struct_time(tm_year=2019, tm_mon=3, tm_mday=9, tm_hour=20, tm_min=23, tm_sec=53, tm_wday=5, tm_yday=68, tm_isdst=0)

Further:

print(time.timezone / 3600)
print(time.altzone / 3600)
print(time.daylight)

produces

8.0
7.0
1

Actual behavior:

Output produced by IronPython 3 (incorrect hour):

time.struct_time(tm_year=2019, tm_mon=3, tm_mday=9, tm_hour=21, tm_min=23, tm_sec=53, tm_wday=5, tm_yday=68, tm_isdst=0)

time.timezone has the correct value (28800), but the difference between localtime and gmtime is 7 hours, which is incorrect, until 2:00 AM next day local time, or 10:00 AM today UTC. After that moment the difference will indeed be 7 hours.

Further:

print(time.timezone / 3600)
print(time.altzone / 3600)
print(time.daylight)

produces

8.0
8.0
1

which is different than CPython's output.

Versions

Latest, commit 4a784ac .

Dominant language
C#
Stars
2.8k
Forks
316
Avg merge
1d 9h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IronLanguages/ironpython3

All issues in IronLanguages/ironpython3

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.