Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to adjust time for timezone #17

Closed
KyleGW opened this issue Feb 11, 2022 · 4 comments
Closed

Add ability to adjust time for timezone #17

KyleGW opened this issue Feb 11, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@KyleGW
Copy link
Contributor

KyleGW commented Feb 11, 2022

Currently for me everything shows in UTC time. Add a way to easily adjust the timezone offset so the correct local time is displayed on the overlay.

@tve
Copy link

tve commented Feb 13, 2022

If you're using an xml layout the following hack will shift to localtime:

--- a/gopro_overlay/layout_xml.py
+++ b/gopro_overlay/layout_xml.py
@@ -194,9 +194,9 @@ def date_formatter_from(element, entry):
     truncate = iattrib(element, "truncate", d=0)

     if truncate > 0:
-        return lambda: entry().dt.strftime(format_string)[:-truncate]
+        return lambda: entry().dt.astimezone(tz=None).strftime(format_string)[:-truncate]
     else:
-        return lambda: entry().dt.strftime(format_string)
+        return lambda: entry().dt.astimezone(tz=None).strftime(format_string)

@time4tea
Copy link
Owner

This looks like a good fix. I'm on vacation atm, away from keyboard, so I'll release it when I'm back next week.
Thanks for the contribution!

@KyleGW
Copy link
Contributor Author

KyleGW commented Feb 15, 2022

This change did the trick exactly. Thank you!

@tve
Copy link

tve commented Feb 17, 2022

If you want to make that change you should also tackle:

diff --git a/gopro_overlay/widgets.py b/gopro_overlay/widgets.py
index a94721f..5c0db6c 100644
--- a/gopro_overlay/widgets.py
+++ b/gopro_overlay/widgets.py
@@ -2,6 +2,7 @@ import functools
 import importlib
 import os
 from typing import Callable
+from datetime import timezone

 from PIL import Image, ImageDraw

@@ -113,11 +114,11 @@ class Drawable:


 def time(clock):
-    return lambda: clock().strftime("%H:%M:%S.%f")[:-5]
+    return lambda: clock().astimezone(tz=None).strftime("%H:%M:%S.%f")[:-5]


 def date(clock):
-    return lambda: clock().strftime("%Y/%m/%d")
+    return lambda: clock().astimezone(tz=None).strftime("DD %Y/%m/%d")


 def icon(file, at, transform=lambda x: x):

I have not tested this patch, though.

@time4tea time4tea added the enhancement New feature or request label Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants