diff --git a/domonic/javascript.py b/domonic/javascript.py index 9d2ec4b..306eff2 100644 --- a/domonic/javascript.py +++ b/domonic/javascript.py @@ -1611,7 +1611,7 @@ def setSeconds(self, secondsValue: int, msValue: int = None): self.setMilliseconds(msValue) return self.getTime() - def setTime(self, milliseconds: int = None): + def setTime(self, milliseconds: int = None, tz: Any = None): """Sets the date and time of a date object Args: @@ -1621,9 +1621,9 @@ def setTime(self, milliseconds: int = None): _type_: _description_ """ if milliseconds is None: - self.date = datetime.datetime.now() + self.date = datetime.datetime.now(tz) else: - self.date = datetime.datetime.fromtimestamp(milliseconds / 1000) + self.date = datetime.datetime.fromtimestamp(milliseconds / 1000, tz) return milliseconds def setUTCDate(self, day): diff --git a/tests/test_javascript_date.py b/tests/test_javascript_date.py index c541956..504537b 100644 --- a/tests/test_javascript_date.py +++ b/tests/test_javascript_date.py @@ -26,7 +26,7 @@ def test_javascript_date(self): d = Date() # set the date - d.setTime(1546300800000) # 2019-01-01, was on a Tuesday + d.setTime(1546300800000, timezone.utc) # 2019-01-01, was on a Tuesday # print('>>', d.getDate()) assert d.getDate() == 1 @@ -174,7 +174,7 @@ def test_getTime(self): # // Since month is zero based, birthday will be January 10, 1995 birthday = Date(1994, 12, 10) acopy = Date() - acopy.setTime(birthday.getTime()) + acopy.setTime(birthday.getTime(), timezone.utc) assert acopy.getTime() == birthday.getTime() # def test_getTimezoneOffset(self):