]> git.rmz.io Git - dotfiles.git/commitdiff
mutt/ical2txt: show time in local tz
authorSamir Benmendil <me@rmz.io>
Thu, 24 Oct 2019 15:11:40 +0000 (16:11 +0100)
committerSamir Benmendil <me@rmz.io>
Thu, 24 Oct 2019 15:11:40 +0000 (16:11 +0100)
mutt/ical2txt

index 5b7c998b237f1e53356ba03d6bfc0d785dd4014e..de9d739e889b83d8b2836de85da020ea81ee991f 100755 (executable)
@@ -2,9 +2,13 @@
 
 from icalendar import Calendar
 
-def format_cal(start, end, description):
-    str  = "Start: {:%Y-%m-%d %H:%M}\n".format(start)
-    str += "End:   {:%Y-%m-%d %H:%M}\n\n".format(end)
+def format_cal(event):
+    start = event.get('dtstart').dt
+    end   = event.get('dtend').dt
+    str  = "Start: {:%Y-%m-%d %H:%M}\n".format(start.astimezone())
+    str += "End:   {:%Y-%m-%d %H:%M}\n".format(end.astimezone())
+
+    description = event.get('description')
     if description is not None:
         str += description
 
@@ -16,7 +20,4 @@ with open('/dev/stdin', 'r') as f:
 
 for c in cal.walk():
     if c.name == "VEVENT":
-        print(format_cal(
-            c.get('dtstart').dt,
-            c.get('dtend').dt,
-            c.get('description')))
+        print(format_cal(c))