[PATCH v2] Avoid timezone confusion

vkabatov at redhat.com vkabatov at redhat.com
Wed Jan 17 04:58:06 AEDT 2018


From: Veronika Kabatova <vkabatov at redhat.com>

Patchwork saves patches, comments etc with UTC timezone and reports
this time when opening the patch details. However, internally generated
processes such as events are reported with the instance's local time.
There's nothing wrong with that and making PW timezone-aware would add
useless complexity, but in a world-wide collaboration a lot of confusion
may arise as the timezone is not reported at all. Instance's local time
might be very different from the local time of CI integrating with PW,
which is different from the local time of person dealing with it etc.

Use UTC everywhere by default instead of UTC for sumbissions and local
timezone for internally generated events (which is not reported).

Signed-off-by: Veronika Kabatova <vkabatov at redhat.com>
---
 docs/api/rest.rst                                        | 4 +++-
 docs/deployment/installation.rst                         | 8 ++++++++
 patchwork/settings/base.py                               | 2 +-
 patchwork/templates/patchwork/submission.html            | 4 ++--
 releasenotes/notes/unify-timezones-0f7022f0c2a371be.yaml | 5 +++++
 5 files changed, 19 insertions(+), 4 deletions(-)
 create mode 100644 releasenotes/notes/unify-timezones-0f7022f0c2a371be.yaml

diff --git a/docs/api/rest.rst b/docs/api/rest.rst
index 3d7292e..66aee72 100644
--- a/docs/api/rest.rst
+++ b/docs/api/rest.rst
@@ -107,7 +107,9 @@ Schema
 ------
 
 Responses are returned as JSON. Blank fields are returned as ``null``, rather
-than being omitted. Timestamps use the ISO 8601 format::
+than being omitted. Timestamps use the ISO 8601 format, times are by default
+in UTC (:ref:`overridable<deployment-other-options>` by ``TIME_ZONE``
+setting)::
 
     YYYY-MM-DDTHH:MM:SSZ
 
diff --git a/docs/deployment/installation.rst b/docs/deployment/installation.rst
index a570dd8..679312b 100644
--- a/docs/deployment/installation.rst
+++ b/docs/deployment/installation.rst
@@ -267,6 +267,8 @@ below:
 
    STATIC_ROOT = '/var/www/patchwork'
 
+.. _deployment-other-options:
+
 Other Options
 ^^^^^^^^^^^^^
 
@@ -281,6 +283,12 @@ setting overridden. The purpose of many of these variables is described in
 * ``DEFAULT_FROM_EMAIL``
 * ``NOTIFICATION_FROM_EMAIL``
 
+.. note::
+
+   The default time zone is set to UTC. After changing, internally triggered
+   events will report time using this new timezone but submissions from emails
+   (cover letters, patches, comments) will still use UTC.
+
 You can generate the ``SECRET_KEY`` with the following Python code:
 
 .. code-block:: python
diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py
index 4b0d551..ec34f90 100644
--- a/patchwork/settings/base.py
+++ b/patchwork/settings/base.py
@@ -42,7 +42,7 @@ if django.VERSION >= (1, 10):
 else:
     MIDDLEWARE_CLASSES = _MIDDLEWARE_CLASSES
 
-TIME_ZONE = 'Australia/Canberra'
+TIME_ZONE = 'UTC'
 
 LANGUAGE_CODE = 'en-au'
 
diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html
index 6ed20c3..e817713 100644
--- a/patchwork/templates/patchwork/submission.html
+++ b/patchwork/templates/patchwork/submission.html
@@ -255,7 +255,7 @@ function toggle_div(link_id, headers_id)
 <div class="comment">
 <div class="meta">
  <span>{{ submission.submitter|personify:project }}</span>
- <span class="pull-right">{{ submission.date }}</span>
+ <span class="pull-right">{{ submission.date }} UTC</span>
 </div>
 <pre class="content">
 {{ submission|commentsyntax }}
@@ -271,7 +271,7 @@ function toggle_div(link_id, headers_id)
 <div class="comment">
 <div class="meta">
  <span>{{ item.submitter|personify:project }}</span>
- <span class="pull-right">{{ item.date }} | <a href="{% url 'comment-redirect' comment_id=item.id %}"
+ <span class="pull-right">{{ item.date }} UTC | <a href="{% url 'comment-redirect' comment_id=item.id %}"
    >#{{ forloop.counter }}</a></span>
 </div>
 <pre class="content">
diff --git a/releasenotes/notes/unify-timezones-0f7022f0c2a371be.yaml b/releasenotes/notes/unify-timezones-0f7022f0c2a371be.yaml
new file mode 100644
index 0000000..2513650
--- /dev/null
+++ b/releasenotes/notes/unify-timezones-0f7022f0c2a371be.yaml
@@ -0,0 +1,5 @@
+---
+other:
+  - |
+    Unify timezones used -- use UTC for both email submissions and internal
+    events.
-- 
2.13.6



More information about the Patchwork mailing list