Skip to content

Commit c167999

Browse files
committed
python-stdlib/datetime: Forget timedelta limits.
MicroPython integer implementation will take care of small and large deltas. Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
1 parent 84bfb1f commit c167999

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

python-stdlib/datetime/datetime.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ def _ord2ymd(n):
5757

5858

5959
class timedelta:
60-
MINYEAR = -292 # timedelta( 0, 0, 0, -365*584).total_seconds() > -2**63 / 10**9
61-
MAXYEAR = 292 # timedelta(23, 59, 59, 365*584).total_seconds() < (2**63 - 1) / 10**9
6260

6361
def __init__(
6462
self,

python-stdlib/datetime/test_datetime.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,19 @@ def test_constructor13(self):
5555
self.assertEqual(td(milliseconds=0.001), td(microseconds=1))
5656

5757
def test_constant01(self):
58-
self.assertTrue(td(0, 0, 0, 365 * td.MINYEAR).total_seconds() >= -(2 ** 63) / 10 ** 9)
58+
self.assertIsInstance(td.min, td)
59+
self.assertIsInstance(td.max, td)
60+
self.assertIsInstance(td.resolution, td)
61+
self.assertTrue(td.max > td.min)
5962

6063
def test_constant02(self):
61-
self.assertFalse(
62-
td(0, 0, 0, 365 * (td.MINYEAR - 1)).total_seconds() >= -(2 ** 63) / 10 ** 9
63-
)
64+
self.assertEqual(td.min, td(days=-999_999_999))
6465

6566
def test_constant03(self):
66-
self.assertTrue(
67-
td(23, 59, 59, 365 * td.MAXYEAR).total_seconds() <= (2 ** 63 - 1) / 10 ** 9
68-
)
67+
self.assertEqual(td.max, td(days=999_999_999, seconds=24 * 3600 - 1, microseconds=10**6 - 1))
6968

7069
def test_constant04(self):
71-
self.assertFalse(
72-
td(23, 59, 59, 365 * (td.MAXYEAR + 1)).total_seconds() <= (2 ** 63 - 1) / 10 ** 9
73-
)
70+
self.assertEqual(td.resolution, td(microseconds=1))
7471

7572
def test_computation01(self):
7673
self.assertEqual(a + b + c, td(7, 6, 10))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy