Edgewall Software
Modify

Opened 14 years ago

Last modified 9 years ago

#8945 new enhancement

[PATCH] Send Notification Email with local timezone

Reported by: hwyss@… Owned by:
Priority: normal Milestone: next-major-releases
Component: notification Version:
Severity: normal Keywords: timezone, patch
Cc: Thijs Triemstra Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Currently, Trac sends out notifications with an UTC Date header. I would like to see my server's local timezone (patch attached) or even better the users' configured timezone.

Related: http://trac.edgewall.org/changeset/1512

Attachments (1)

trac.notification.patch (532 bytes ) - added by hwyss@… 14 years ago.

Download all attachments as: .zip

Change History (10)

by hwyss@…, 14 years ago

Attachment: trac.notification.patch added

comment:1 by Remy Blank, 14 years ago

Milestone: next-minor-0.12.x

This is related to #2182.

comment:2 by Christian Boos, 14 years ago

Component: generalnotification
Keywords: timezone added
Milestone: next-minor-0.12.xunscheduled

For user configured timezone, this is tricky, we would need to send "personalized" mails (same problematic than for translated notification mails).

For using server's local timezone instead of UTC, well, I think it all depends what kind of Trac it is (public project on the internet vs. "in house"), so maybe a setting would make sense here…

(Improved) PatchWelcome ;-)

comment:3 by Thijs Triemstra <lists@…>, 13 years ago

Cc: lists@… added

in reply to:  2 ; comment:4 by Thijs Triemstra <lists@…>, 13 years ago

Replying to cboos:

For using server's local timezone instead of UTC, well, I think it all depends what kind of Trac it is (public project on the internet vs. "in house"), so maybe a setting would make sense here…

What about using the default_timezone setting (for now)?

in reply to:  4 comment:5 by Remy Blank, 13 years ago

Replying to Thijs Triemstra <lists@…>:

What about using the default_timezone setting (for now)?

Sounds like a good idea to me.

comment:6 by Thijs Triemstra, 13 years ago

Cc: Thijs Triemstra added; lists@… removed
Milestone: unschedulednext-major-0.1X
Owner: set to Thijs Triemstra
Status: newassigned

comment:7 by Thijs Triemstra, 13 years ago

Keywords: patch added
Summary: Send Notification Email with local timezone[PATCH] Send Notification Email with local timezone

With the original patch, updated for 0.12-stable, I get:

Date: Tue, 07 Dec 2010 17:22:06 +0100
  • trac/notification.py

     
    456456                headers['To'] = ', '.join(toaddrs)
    457457        if pcc:
    458458            headers['Cc'] = ', '.join(pcc)
    459         headers['Date'] = formatdate()
     459        headers['Date'] = formatdate(localtime=True)
    460460        msg = MIMEText(body, 'plain')
    461461        # Message class computes the wrong type from MIMEText constructor,
    462462        # which does not take a Charset object as initializer. Reset the

Which is correct but it's a local trac instance so duh. Without the patch I get:

Date: Tue, 07 Dec 2010 16:24:31 -0000

This patch checks for that default_timezone setting:

  • trac/notification.py

     
    456456                headers['To'] = ', '.join(toaddrs)
    457457        if pcc:
    458458            headers['Cc'] = ', '.join(pcc)
    459         headers['Date'] = formatdate()
     459
     460        default_tz = self.config.get('trac', 'default_timezone')
     461        if default_tz:
     462            self.env.log.debug("default_tz: %s" % default_tz)
     463        else:
     464            default_tz = formatdate()
     465
     466        headers['Date'] = default_tz
    460467        msg = MIMEText(body, 'plain')
    461468        # Message class computes the wrong type from MIMEText constructor,
    462469        # which does not take a Charset object as initializer. Reset the

but doesn't do anything useful till I figured out what it supposed to hold. The default_timezone setting isn't documented in TracIni, what are valid options for this setting? Is there a list of this somewhere?

in reply to:  7 comment:8 by Remy Blank, 13 years ago

Replying to thijstriemstra:

The default_timezone setting isn't documented in TracIni, what are valid options for this setting? Is there a list of this somewhere?

It can hold any timezone name, as supported by Trac for the simple timezones (see trac.util.datefmt) and pytz if installed. The list of available values can be found in trac.util.datefmt.all_timezones.

comment:9 by Ryan J Ollos, 9 years ago

Owner: Thijs Triemstra removed
Status: assignednew

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


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