File tree 2 files changed +10
-5
lines changed
2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 19
19
import logging
20
20
import datetime
21
21
import pytz
22
- import tzlocal
22
+ import time
23
23
from lynkctx import LynkContext
24
24
25
25
@@ -33,9 +33,16 @@ def user_time(utc_time):
33
33
Returns:
34
34
str: The local time formatted as a string.
35
35
"""
36
+ # Parse the input UTC time
36
37
timestamp = datetime .datetime .fromisoformat (utc_time [:- 1 ])
37
- local_timezone = tzlocal .get_localzone ()
38
+
39
+ # Get the local timezone
40
+ local_timezone = datetime .timezone (datetime .timedelta (seconds = - time .timezone ))
41
+
42
+ # Convert the UTC time to local time
38
43
local_time = timestamp .replace (tzinfo = pytz .UTC ).astimezone (local_timezone )
44
+
45
+ # Format and return the local time as a string
39
46
return local_time .strftime ('%Y-%m-%d %H:%M:%S %Z' )
40
47
41
48
Original file line number Diff line number Diff line change @@ -2,6 +2,4 @@ certifi==2024.2.2
2
2
charset-normalizer == 3.3.2
3
3
idna == 3.7
4
4
pytz == 2024.1
5
- requests == 2.32.0
6
- tzlocal == 5.2
7
- urllib3 == 1.26.18
5
+ requests == 2.31.0
You can’t perform that action at this time.
0 commit comments