patch 940936aea4bf440b777cf726b9c88f21fc54f131
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sun May 7 11:49:05 CEST 2023
* service: In dialog list: Use timezone option to convert the date for "last" field
diff -rN -u old-irgramd/service.py new-irgramd/service.py
--- old-irgramd/service.py 2024-11-22 16:13:56.741514170 +0100
+++ new-irgramd/service.py 2024-11-22 16:13:56.741514170 +0100
@@ -88,7 +88,7 @@
ty = self.tg.get_entity_type(dialog.entity, format='short')
pin = 'Yes' if dialog.pinned else 'No'
arch = 'Yes' if dialog.archived else 'No'
- last = compact_date(dialog.date)
+ last = compact_date(dialog.date, self.tg.timezone)
if id == self.tg.id:
name_in_irc = self.tmp_ircnick
else:
diff -rN -u old-irgramd/utils.py new-irgramd/utils.py
--- old-irgramd/utils.py 2024-11-22 16:13:56.741514170 +0100
+++ new-irgramd/utils.py 2024-11-22 16:13:56.745514163 +0100
@@ -112,15 +112,16 @@
if s > 0: res += str(s) + 's'
return res
-def compact_date(date):
+def compact_date(date, tz):
delta = datetime.datetime.now(datetime.timezone.utc) - date
+ date_local = date.astimezone(zoneinfo.ZoneInfo(tz))
if delta.days < 1:
- compact_date = date.strftime('%H:%M')
+ compact_date = date_local.strftime('%H:%M')
elif delta.days < 365:
- compact_date = date.strftime('%d-%b')
+ compact_date = date_local.strftime('%d-%b')
else:
- compact_date = date.strftime('%Y')
+ compact_date = date_local.strftime('%Y')
return compact_date