Edgewall Software
Modify

Opened 10 years ago

Closed 9 years ago

#8664 closed defect (fixed)

Timeline calls today yesterday

Reported by: Leif Ryge <leif@…> Owned by:
Priority: normal Milestone: 0.12
Component: timeline Version: 0.11.5
Severity: major Keywords: datetime
Cc: ryano@… Branch:
Release Notes:
API 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 Ryan Ollos <ryano@…>, 10 years ago

Cc: ryano@… added

comment:2 by Leif Ryge <leif@…>, 10 years ago

Here is a patch which fixes this. I tested it with my timezone set to -0700 as well as UTC.

--- trac/timeline/web_ui.py.orig	2009-09-14 00:45:31.000000000 +0000
+++ trac/timeline/web_ui.py	2009-09-14 00:45:36.000000000 +0000
@@ -120,8 +120,8 @@
             daysback = min(self.max_daysback, daysback)
 
         data = {'fromdate': fromdate, 'daysback': daysback,
-                'today': format_date(today),
-                'yesterday': format_date(today - timedelta(days=1)),
+                'today': format_date(today, tzinfo=req.tz),
+                'yesterday': format_date(today - timedelta(days=1), tzinfo=req.tz),
                 'precisedate': precisedate, 'precision': precision,
                 'events': [], 'filters': [],
                 'abbreviated_messages': self.abbreviated_messages}

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.

comment:3 by Christian Boos, 10 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 Christian Boos, 10 years ago

Milestone: 0.12next-minor-0.12.x

comment:5 by Remy Blank, 9 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 Christian Boos, 9 years ago

Milestone: next-minor-0.12.x0.12.1
Severity: normalmajor

I'll take a look.

comment:7 by Remy Blank, 9 years ago

The original issue seems to be fixed with [9799], so we could close this against 0.12.

comment:8 by Christian Boos, 9 years ago

Milestone: 0.12.10.12
Resolution: fixed
Status: newclosed

Fine by me.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.