Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 112273b

Browse files
committed
date.py: Enable copatibility with CPython.
1 parent cbf63b4 commit 112273b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

date/date.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# date.py Minimal Date class for micropython
22

33
# Released under the MIT License (MIT). See LICENSE.
4-
# Copyright (c) 2023 Peter Hinch
4+
# Copyright (c) 2023-2024 Peter Hinch
55

66
from time import mktime, localtime
7+
from sys import implementation
8+
if implementation.name != "micropython":
9+
const = lambda x : x
710

811
_SECS_PER_DAY = const(86400)
912
def leap(year):
@@ -22,7 +25,7 @@ def now(self, lt=None):
2225
def _update(self, ltmod=True): # If ltmod is False ._cur has been changed
2326
if ltmod: # Otherwise ._lt has been modified
2427
self._lt[3] = 6
25-
self._cur = mktime(self._lt) // _SECS_PER_DAY
28+
self._cur = mktime(tuple(self._lt)) // _SECS_PER_DAY
2629
self._lt = list(localtime(self._cur * _SECS_PER_DAY))
2730
self.callback()
2831

0 commit comments

Comments
 (0)