Skip to content

Commit e15131a

Browse files
Merge pull request #48 from interlynk-io/fix/compatibility-issue
[NO-TKT] Remove dependency on tzlocal
2 parents 44b7403 + 5d182c8 commit e15131a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pylynk.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import logging
2020
import datetime
2121
import pytz
22-
import tzlocal
22+
import time
2323
from lynkctx import LynkContext
2424

2525

@@ -33,9 +33,16 @@ def user_time(utc_time):
3333
Returns:
3434
str: The local time formatted as a string.
3535
"""
36+
# Parse the input UTC time
3637
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
3843
local_time = timestamp.replace(tzinfo=pytz.UTC).astimezone(local_timezone)
44+
45+
# Format and return the local time as a string
3946
return local_time.strftime('%Y-%m-%d %H:%M:%S %Z')
4047

4148

requirements.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ certifi==2024.2.2
22
charset-normalizer==3.3.2
33
idna==3.7
44
pytz==2024.1
5-
requests==2.32.0
6-
tzlocal==5.2
7-
urllib3==1.26.18
5+
requests==2.31.0

0 commit comments

Comments
 (0)