Project

General

Profile

Retrieving gmail via IMAP is resulting in incorrect timestamps in issues. Timezone trouble.

Added by Jonathan Cormier almost 8 years ago

Just started using "Incoming Email" feature of redmine. Configured it to fetch email using IMAP from gmail and have a cronjob which runs the rake task every minute. However we noticed that replies to issues that are generated from emails are posted "5 hours in advanced". Note redmine says they are 5 hours in the past but the hover text puts the timestamp 5 hours in the future. I then posted an update to the issue and it was inserted before my email replies, presumably sorted by date.

Note example image. Both "about 5 hour ago" posts were created via email before the other three posts.

Environment:
  Redmine version                3.3.1.stable
  Ruby version                   2.1.9-p490 (2016-03-30) [x86_64-linux-gnu]
  Rails version                  4.2.7.1
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.8.8
  Darcs                          2.8.4
  Mercurial                      2.8.2
  Cvs                            1.12.13
  Bazaar                         2.7.0
  Git                            2.10.1
  Filesystem                     
Redmine plugins:
  clipboard_image_paste          1.10
  google_analytics_plugin        1.0.0
  redmine_banner                 0.1.2
  redmine_charts2                0.2.1
  redmine_checklists             3.1.5
  redmine_favourite_projects     0.7
  redmine_jstoolbar_ext          0.2.1
  redmine_jstoolbar_ext_buttons  0.2.1
  redmine_jstoolbar_ext_images   0.3.1
  redmine_project_alias_2        1.0.2
  redmine_release_notes          1.3.1
  redmine_silencer               0.4.1
  redmine_tags                   3.1.1
  redmine_wiki_extensions        0.7.0
  redmine_wiki_notes             0.0.2
  redmine_xlsx_format_issue_exporter 0.1.3
  wiki_issue_fields              0.5.1

Replies (1)

RE: Retrieving gmail via IMAP is resulting in incorrect timestamps in issues. Timezone trouble. - Added by Jonathan Cormier almost 8 years ago

I was able to find the problem.

When I run the redmine:email:receive_imap rake from the command line the issue journals get created with the correct timestamp. However if I let cron run the rake the timestamps were 5 hours ahead of time.

I added the following to the receive_imap task to print the ENV variables and compared the two instances.

      require 'pp'
      pp ENV

The cronjob did not have the TZ environment variable set so its date was coming out as

2017-02-19 22:37:09 +0000

where as the command line version date was
2017-02-19 17:37:51 -0500

And the server was started with the TZ variable set as well.

Ensuring that the server was started without the TZ variable set, allowed the cronjob to set the correct timestamp. Of course now all our redmine posts are stated as 5 hours earlier than they were before but hopefully no one notices.

    (1-1/1)