Opened 15 years ago
Closed 14 years ago
#8664 closed defect (fixed)
Timeline calls today yesterday
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | normal | Milestone: | 0.12 |
Component: | timeline | Version: | 0.11.5 |
Severity: | major | Keywords: | datetime |
Cc: | ryano@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
In the hours between UTC midnight and my local (UTC-0700) midnight, the trac timeline calls the current day "yesterday".
All dates and times are correct; it is just the word yesterday that is wrong.
The server's timezone is UTC; my trac account's preferences and my browser are both -0700.
Attachments (0)
Change History (8)
comment:1 by , 15 years ago
Cc: | added |
---|
comment:2 by , 15 years ago
comment:3 by , 15 years ago
Milestone: | → 0.12 |
---|
Thanks for the report and the patch.
Yes, I think format_date
should not require an extra req.tz argument here.
So instead of:
def format_datetime(t=None, format='%x %X', tzinfo=None): tz = tzinfo or localtz t = to_datetime(t, tzinfo).astimezone(tz)
we should do something like:
def format_datetime(t=None, format='%x %X', tzinfo=None): if tzinfo: tz = tzinfo elif isinstance(t, (date, time, datetime)): tz = t.tzinfo or localtz else: tz = localtz if not isinstance(t, datetime): t = to_datetime(t, tzinfo).astimezone(tz)
(to be tested)
comment:4 by , 15 years ago
Milestone: | 0.12 → next-minor-0.12.x |
---|
comment:5 by , 14 years ago
#9386 reported the same issue, and suggested the same patch as comment:2. That patch does resolve the issue, so I applied it in [9799]. I also tested the suggestion in comment:3, but not only does it not solve the issue, but it also mangles displayed times in various locations (e.g. in the date/time preferences). I'm leaving this ticket open to find a correct solution.
comment:6 by , 14 years ago
Milestone: | next-minor-0.12.x → 0.12.1 |
---|---|
Severity: | normal → major |
I'll take a look.
comment:7 by , 14 years ago
The original issue seems to be fixed with [9799], so we could close this against 0.12.
comment:8 by , 14 years ago
Milestone: | 0.12.1 → 0.12 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Fine by me.
Here is a patch which fixes this. I tested it with my timezone set to -0700 as well as UTC.
This timezone stuff is a bit confusing. It seems like since
today = datetime.now(req.tz)
it should not be necessary to also pass req.tz to format_date, but apparently it is.