Skip to content

Commit

Permalink
Merge pull request #48 from interlynk-io/fix/compatibility-issue
Browse files Browse the repository at this point in the history
[NO-TKT] Remove dependency on tzlocal
  • Loading branch information
surendrapathak authored Aug 15, 2024
2 parents 44b7403 + 5d182c8 commit e15131a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 9 additions & 2 deletions pylynk.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
import datetime
import pytz
import tzlocal
import time
from lynkctx import LynkContext


Expand All @@ -33,9 +33,16 @@ def user_time(utc_time):
Returns:
str: The local time formatted as a string.
"""
# Parse the input UTC time
timestamp = datetime.datetime.fromisoformat(utc_time[:-1])
local_timezone = tzlocal.get_localzone()

# Get the local timezone
local_timezone = datetime.timezone(datetime.timedelta(seconds=-time.timezone))

# Convert the UTC time to local time
local_time = timestamp.replace(tzinfo=pytz.UTC).astimezone(local_timezone)

# Format and return the local time as a string
return local_time.strftime('%Y-%m-%d %H:%M:%S %Z')


Expand Down
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ certifi==2024.2.2
charset-normalizer==3.3.2
idna==3.7
pytz==2024.1
requests==2.32.0
tzlocal==5.2
urllib3==1.26.18
requests==2.31.0

0 comments on commit e15131a

Please sign in to comment.