From ee7ade04efc65372e07cd4056356e9e681be7601 Mon Sep 17 00:00:00 2001 From: Dag Brattli Date: Thu, 30 Nov 2023 15:01:26 +0100 Subject: [PATCH] Fix error in days to microseconds calculation --- src/fable-library-py/fable_library/date.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/fable-library-py/fable_library/date.py b/src/fable-library-py/fable_library/date.py index e0e21ba97a..97a9b59bdb 100644 --- a/src/fable-library-py/fable_library/date.py +++ b/src/fable-library-py/fable_library/date.py @@ -19,7 +19,7 @@ def subtract(x: datetime, y: datetime | TimeSpan) -> datetime | TimeSpan: delta = x - y # ts.microseconds only contains the microseconds provided to the constructor # so we need to calculate the total microseconds ourselves - delta_microseconds = delta.days * (24 * 3600) + delta.seconds * 10**6 + delta.microseconds + delta_microseconds = delta.days * (24 * 3600 * 10**6) + delta.seconds * 10**6 + delta.microseconds return create_time_span(0, 0, 0, 0, 0, delta_microseconds) return x - timedelta(microseconds=total_microseconds(y)) @@ -237,17 +237,6 @@ def try_parse(string: str, style: int, unsigned: bool, bitsize: int, defValue: F return False -def add(d: datetime, ts: int) -> datetime: - new_date = d + timedelta(milliseconds=ts) - if d.tzinfo: - old_tz_offset = d.utcoffset() - new_tz_offset = new_date.utcoffset() - if old_tz_offset is not None and new_tz_offset is not None and old_tz_offset != new_tz_offset: - return new_date + (new_tz_offset - old_tz_offset) - - return new_date - - def add_milliseconds(d: datetime, v: int) -> datetime: return d + timedelta(milliseconds=v)