Skip to content

Commit

Permalink
Display document expiration in UTC
Browse files Browse the repository at this point in the history
The document expiration mail displays the date of the upcoming document expiration, but different timezones makes that date ambituous.  Instead, clearly show that as a timestamp in UTC.

Fixes ietf-tools#1825
  • Loading branch information
meadmaker committed Nov 4, 2023
1 parent d5e4ea8 commit 7c9aa36
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
12 changes: 9 additions & 3 deletions ietf/doc/expire.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import datetime, os, shutil, glob, re
from pathlib import Path
from zoneinfo import ZoneInfo

from typing import List, Optional # pyflakes:ignore

Expand Down Expand Up @@ -86,10 +87,15 @@ def send_expire_warning_for_draft(doc):
(doc.get_state_slug("draft") != "active")):
return # don't warn about dead or inactive documents

expiration = doc.expires.astimezone(DEADLINE_TZINFO).date()
expiration = doc.expires.astimezone(
DEADLINE_TZINFO
).replace(
hour=0, minute=0, second=0, microsecond=0
).astimezone(
ZoneInfo('UTC')
)
now_plus_12hours = timezone.now() + datetime.timedelta(hours=12)
soon = now_plus_12hours.date()
if expiration <= soon:
if expiration <= now_plus_12hours:
# The document will expire very soon, which will send email to the
# same people, so do not send the warning at this point in time
return
Expand Down
1 change: 1 addition & 0 deletions ietf/doc/tests_draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ def test_warn_expirable_drafts(self):
self.assertTrue('draft-ietf-mars-test@' in outbox[-1]['To']) # Gets the authors
self.assertTrue('[email protected]' in outbox[-1]['Cc'])
self.assertTrue('aread@' in outbox[-1]['Cc'])
self.assertIn('UTC' , get_payload_text(outbox[-1]))

# hack into expirable state to expire in 10 hours
draft.expires = timezone.now() + datetime.timedelta(hours=10)
Expand Down
4 changes: 2 additions & 2 deletions ietf/templates/doc/draft/expire_warning_email.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% load ietf_filters %}{% autoescape off %}The following Internet-Draft will expire soon:
{% load ietf_filters tz %}{% autoescape off %}The following Internet-Draft will expire soon:

Name: {{ doc.name|clean_whitespace }}
Title: {{ doc.title}}
State: {{ state }}
Expires: {{ expiration }} (in {{ expiration|timeuntil }})
Expires: {{ expiration|utc }} (in {{ expiration|timeuntil }})
{% endautoescape %}

0 comments on commit 7c9aa36

Please sign in to comment.