Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
byteface committed Dec 8, 2024
2 parents bd34d96 + 2021959 commit e972409
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions domonic/javascript.py
Original file line number Diff line number Diff line change
@@ -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):
4 changes: 2 additions & 2 deletions tests/test_javascript_date.py
Original file line number Diff line number Diff line change
@@ -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):

0 comments on commit e972409

Please sign in to comment.