Skip to content

Commit

Permalink
Merge pull request #151 from modoboa/fix/default_date_format
Browse files Browse the repository at this point in the history
Use en as default date format.
  • Loading branch information
tonioo committed Feb 2, 2018
2 parents 0fcff5d + 2a4d586 commit 6851bc4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modoboa_webmail/lib/imapheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"it": {'SHORT': 'l, H:i', 'LONG': 'd. N Y H:i'},
"ja_JP": {'SHORT': 'l, P', 'LONG': 'N j, Y P'},
"nl": {'SHORT': 'l, H:i', 'LONG': 'd. N Y H:i'},
"pl_PL": {'SHORT': 'l, H:i', 'LONG': 'd. N Y H:i'},
"pt_PT": {'SHORT': 'l, H:i', 'LONG': 'd. N Y H:i'},
"pt_BR": {'SHORT': 'l, H:i', 'LONG': 'd. N Y H:i'},
"ru": {'SHORT': 'l, H:i', 'LONG': 'd. N Y H:i'},
Expand Down Expand Up @@ -116,8 +117,13 @@ def parse_date(value, **kwargs):
ndate = tz.localize(datetime.datetime.fromtimestamp(ndate))
current_language = get_request().user.language
if datetime.datetime.now() - ndate > datetime.timedelta(7):
return date_format(ndate, DATETIME_FORMATS[current_language]['LONG'])
return date_format(ndate, DATETIME_FORMATS[current_language]['SHORT'])
fmt = "LONG"
else:
fmt = "SHORT"
return date_format(
ndate,
DATETIME_FORMATS.get(current_language, DATETIME_FORMATS.get("en"))[fmt]
)


def parse_message_id(value, **kwargs):
Expand Down

0 comments on commit 6851bc4

Please sign in to comment.