Edgewall Software
Modify

Opened 8 years ago

Last modified 3 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
Release Notes:
API 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@… 8 years ago.

Download all attachments as: .zip

Change History (10)

Changed 8 years ago by hwyss@…

Attachment: trac.notification.patch added

comment:1 Changed 8 years ago by Remy Blank

Milestone: next-minor-0.12.x

This is related to #2182.

comment:2 Changed 7 years ago by Christian Boos

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 Changed 7 years ago by Thijs Triemstra <lists@…>

Cc: lists@… added

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

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)?

comment:5 in reply to:  4 Changed 7 years ago by Remy Blank

Replying to Thijs Triemstra <lists@…>:

What about using the default_timezone setting (for now)?

Sounds like a good idea to me.

comment:6 Changed 7 years ago by Thijs Triemstra

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

comment:7 Changed 7 years ago by Thijs Triemstra

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?

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

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 Changed 3 years ago by Ryan J Ollos

Owner: Thijs Triemstra deleted
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.
The owner will be changed from (none) to anonymous.

Add Comment


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

 
Note: See TracTickets for help on using tickets.