Modify

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11134 closed defect (fixed)

The Timezone in list view mode is UTC instead of req.tz.

Reported by: Genie Owned by: Jun Omae
Priority: normal Component: TicketCalendarPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

I think missing timezone conversion in function _parse_duration_arg().

def _parse_duration_arg(arg):
    default = datetime.now(utc).date(), 7
    if not arg or '/P' not in arg:
        return default
    start, period = arg.split('/P', 1)
    try:
        start = parse_date(start, tzinfo=utc)
    except:
        start = None
    if not start:
        return default
    start = start.date()
    if period.endswith('D'):
        try:
            period = int(period[:-1])
        except:
            period = 0
        if period > 0:
            return start, period
    return default

Attachments (1)

timezone-issue.png (27.3 KB) - added by Genie 11 years ago.
This is result of run at 2013-06-03 01:36 in KST/JST timezone #2

Download all attachments as: .zip

Change History (15)

comment:1 Changed 11 years ago by Jun Omae

Status: newassigned
Trac Release: 0.12

_parse_duration_arg() returns a tuple of (date, period). Also, get_start_date() and get_due_date() of TicketCalendarModule return a date instance. The date instances has no timezone. So, the methods don't depend on user's timezone.

However, Milestone.due is a datetime which has a timezone. Indeed, the plugin has some issue for timezone.

Python 2.4.3 (#1, Jan  9 2013, 06:49:54)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ticketcalendar.web_ui import _parse_duration_arg
>>> _parse_duration_arg('2013-06-02/P14D')
(datetime.date(2013, 6, 2), 14)
>>> from trac.util.datefmt import utc, parse_date
>>> from datetime import datetime
>>> dt = parse_date('2013-06-02', tzinfo=utc)
>>> dt.date()
datetime.date(2013, 6, 2)
>>> datetime.now(utc).date()
datetime.date(2013, 6, 2)

comment:2 in reply to:  1 Changed 11 years ago by Genie

Replying to jun66j5:

Indeed, the plugin has some issue for timezone.

It has some issues at am 00:00 ~ 09:00 in KST/JST timezone (UTC+9).

Changed 11 years ago by Genie

Attachment: timezone-issue.png added

This is result of run at 2013-06-03 01:36 in KST/JST timezone #2

comment:3 Changed 11 years ago by Genie

This is result of run at 2013-06-03 01:36 in KST/JST timezone

This is result of run at 2013-06-03 01:36 in KST/JST timezone #2

comment:4 Changed 11 years ago by Jun Omae

The list view shows events from the first day to the last day in this week, not from today. Also, the first day of week is configurable with [ticketcalendar] first_week_day.

comment:5 Changed 11 years ago by Jun Omae

Ah, I've misunderstood. You're right. I'll fix the problem in comment:2.

comment:6 in reply to:  4 ; Changed 11 years ago by anonymous

Replying to jun66j5:

The list view shows events from the first day to the last day in this week, not from today. Also, the first day of week is configurable with [ticketcalendar] first_week_day.

I think that the start_date is today by default, isn't it ?

and, today in list view mode is wrong displayed by timezone.

comment:7 in reply to:  6 Changed 11 years ago by Jun Omae

Replying to anonymous:

I think that the start_date is today by default, isn't it ? and, today in list view mode is wrong displayed by timezone.

Yes, the first day in list view is today. Sorry, my comment:4 is wrong.

comment:8 Changed 11 years ago by Jun Omae

Resolution: fixed
Status: assignedclosed

(In [13256]) ticketcalendar: fixed wrong first day in list view on non-GMT timezone

Closes #11134.

comment:9 Changed 11 years ago by Genie

Thank you for your help :)

comment:10 Changed 11 years ago by Jun Omae

(In [13257]) ticketcalendar: fixed the same issue in _parse_month_arg() on non-GMT timezone, confirmed using libfaketime (refs #11134)

comment:11 Changed 11 years ago by Genie

It still have Timezone issues: syntax date.today() The result of date.today() is depend on Server's local timezone. and it is diffent timezone.

comment:12 Changed 11 years ago by Jun Omae

Resolution: fixed
Status: closedreopened

Good catch! It should be datetime.now(req.tz).date() instead.

comment:13 Changed 11 years ago by Jun Omae

Resolution: fixed
Status: reopenedclosed

(In [13259]) ticketcalendar: Don't use date.today() which depends on local timezone (fixed #11134)

comment:14 in reply to:  12 Changed 11 years ago by anonymous

Replying to jun66j5:

Good catch! It should be datetime.now(req.tz).date() instead.

Wow, very very speedy response!

I suppose that the string based date(start_date/due_date) seems to have logical timezone issue probably.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.