Compare commits
2 commits
421d53ec28
...
5fe4a0e864
Author | SHA1 | Date | |
---|---|---|---|
5fe4a0e864 | |||
d144127c39 |
1 changed files with 9 additions and 5 deletions
14
update.py
14
update.py
|
@ -202,17 +202,21 @@ class ArchPkgVersion:
|
||||||
return self_str
|
return self_str
|
||||||
|
|
||||||
|
|
||||||
def timedelta_to_offset_string(timed: datetime.timedelta):
|
def timedelta_to_offset_string(timed: datetime.timedelta) -> str:
|
||||||
|
"""Returns a timedelta string in the format "+HH:MM" or "-HH:MM"."""
|
||||||
|
|
||||||
seconds = timed.days * 24 * 60 * 60 + timed.seconds
|
seconds = timed.days * 24 * 60 * 60 + timed.seconds
|
||||||
minutes_offset = int(seconds / 60)
|
minutes_offset = int(seconds / 60)
|
||||||
hours_offset = int(minutes_offset / 60)
|
hours_offset = int(minutes_offset / 60)
|
||||||
minutes_offset = minutes_offset - hours_offset * 60
|
minutes_offset = abs(minutes_offset - hours_offset * 60)
|
||||||
if minutes_offset < 0:
|
|
||||||
minutes_offset += 60
|
|
||||||
return f"{hours_offset:+03d}:{minutes_offset:02d}"
|
return f"{hours_offset:+03d}:{minutes_offset:02d}"
|
||||||
|
|
||||||
|
|
||||||
def get_datetime_timezone_now(other_state):
|
def get_datetime_timezone_now(other_state) -> str:
|
||||||
|
"""Returns a datetime string compatible with RFC 3339 and ISO 8601.
|
||||||
|
If other_state["datetime_in_local_time"] is True, then the returned string
|
||||||
|
is in localtime."""
|
||||||
|
|
||||||
if other_state["datetime_in_local_time"]:
|
if other_state["datetime_in_local_time"]:
|
||||||
lt = datetime.datetime.now(datetime.timezone.utc).astimezone()
|
lt = datetime.datetime.now(datetime.timezone.utc).astimezone()
|
||||||
return lt.strftime(STRFTIME_LOCAL_FORMAT) + timedelta_to_offset_string(
|
return lt.strftime(STRFTIME_LOCAL_FORMAT) + timedelta_to_offset_string(
|
||||||
|
|
Loading…
Reference in a new issue