opendate 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of opendate might be problematic. Click here for more details.
- date/__init__.py +7 -8
- date/date.py +45 -3
- {opendate-0.1.3.dist-info → opendate-0.1.5.dist-info}/METADATA +2 -2
- opendate-0.1.5.dist-info/RECORD +7 -0
- opendate-0.1.3.dist-info/RECORD +0 -7
- {opendate-0.1.3.dist-info → opendate-0.1.5.dist-info}/LICENSE +0 -0
- {opendate-0.1.3.dist-info → opendate-0.1.5.dist-info}/WHEEL +0 -0
date/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
__version__ = '0.1.
|
|
1
|
+
__version__ = '0.1.5'
|
|
2
2
|
|
|
3
3
|
import datetime as _datetime
|
|
4
4
|
|
|
@@ -51,11 +51,10 @@ def time(*args, **kwargs):
|
|
|
51
51
|
return Time(*args, **kwargs)
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
def parse():
|
|
55
|
-
"""
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
)
|
|
54
|
+
def parse(s: str | None, fmt: str = None, entity: Entity = NYSE, raise_err: bool = False) -> DateTime | None:
|
|
55
|
+
"""Parse using DateTime.parse
|
|
56
|
+
"""
|
|
57
|
+
return DateTime.parse(s, entity=entity, raise_err=True)
|
|
59
58
|
|
|
60
59
|
|
|
61
60
|
def instance(obj: _datetime.date | _datetime.datetime | _datetime.time) -> DateTime | Date | Time:
|
|
@@ -72,13 +71,13 @@ def instance(obj: _datetime.date | _datetime.datetime | _datetime.time) -> DateT
|
|
|
72
71
|
|
|
73
72
|
|
|
74
73
|
def now(tz: str | _zoneinfo.ZoneInfo | None = None) -> DateTime:
|
|
75
|
-
"""
|
|
74
|
+
"""Returns Datetime.now
|
|
76
75
|
"""
|
|
77
76
|
return DateTime.now(tz)
|
|
78
77
|
|
|
79
78
|
|
|
80
79
|
def today(tz: str | _zoneinfo.ZoneInfo = None) -> DateTime:
|
|
81
|
-
"""
|
|
80
|
+
"""Returns DateTime.today
|
|
82
81
|
"""
|
|
83
82
|
return DateTime.today(tz)
|
|
84
83
|
|
date/date.py
CHANGED
|
@@ -47,6 +47,27 @@ __all__ = [
|
|
|
47
47
|
|
|
48
48
|
def Timezone(name:str = 'US/Eastern') -> _zoneinfo.ZoneInfo:
|
|
49
49
|
"""Simple wrapper around Pendulum `Timezone`
|
|
50
|
+
|
|
51
|
+
Ex: sanity check US/Eastern == America/New_York
|
|
52
|
+
|
|
53
|
+
>>> winter1 = DateTime(2000, 1, 1, 12, tzinfo=Timezone('US/Eastern'))
|
|
54
|
+
>>> winter2 = DateTime(2000, 1, 1, 12, tzinfo=Timezone('America/New_York'))
|
|
55
|
+
|
|
56
|
+
>>> summer1 = DateTime(2000, 7, 1, 12, tzinfo=Timezone('US/Eastern'))
|
|
57
|
+
>>> summer2 = DateTime(2000, 7, 1, 12, tzinfo=Timezone('America/New_York'))
|
|
58
|
+
|
|
59
|
+
>>> winter = [winter1, winter2,
|
|
60
|
+
... winter1.astimezone(Timezone('America/New_York')),
|
|
61
|
+
... winter2.astimezone(Timezone('US/Eastern')),
|
|
62
|
+
... ]
|
|
63
|
+
>>> assert all(x==winter[0] for x in winter)
|
|
64
|
+
|
|
65
|
+
>>> summer = [summer1, summer2,
|
|
66
|
+
... summer1.astimezone(Timezone('America/New_York')),
|
|
67
|
+
... summer2.astimezone(Timezone('US/Eastern')),
|
|
68
|
+
... ]
|
|
69
|
+
>>> assert all(x==summer[0] for x in summer)
|
|
70
|
+
|
|
50
71
|
"""
|
|
51
72
|
return _pendulum.tz.Timezone(name)
|
|
52
73
|
|
|
@@ -1115,7 +1136,11 @@ class DateTime(DateBusinessMixin, _pendulum.DateTime):
|
|
|
1115
1136
|
return Time.instance(self)
|
|
1116
1137
|
|
|
1117
1138
|
@classmethod
|
|
1118
|
-
def parse(
|
|
1139
|
+
def parse(
|
|
1140
|
+
cls, s: str | int | None,
|
|
1141
|
+
entity: Entity = NYSE,
|
|
1142
|
+
raise_err: bool = False
|
|
1143
|
+
) -> Self | None:
|
|
1119
1144
|
"""Thin layer on Date parser and our custom `Date.parse``
|
|
1120
1145
|
|
|
1121
1146
|
>>> DateTime.parse('2022/1/1')
|
|
@@ -1173,7 +1198,7 @@ class DateTime(DateBusinessMixin, _pendulum.DateTime):
|
|
|
1173
1198
|
if d is not None and t is not None:
|
|
1174
1199
|
return DateTime.combine(d, t, LCL)
|
|
1175
1200
|
|
|
1176
|
-
d = Date.parse(s)
|
|
1201
|
+
d = Date.parse(s, entity=entity)
|
|
1177
1202
|
if d is not None:
|
|
1178
1203
|
return cls(d.year, d.month, d.day, 0, 0, 0)
|
|
1179
1204
|
|
|
@@ -1413,18 +1438,35 @@ class Interval:
|
|
|
1413
1438
|
yield thedate
|
|
1414
1439
|
thedate = thedate.add(days=1)
|
|
1415
1440
|
|
|
1441
|
+
def start_of_series(self, unit='month') -> list[Date]:
|
|
1442
|
+
"""Return a series between and inclusive of begdate and enddate.
|
|
1443
|
+
|
|
1444
|
+
>>> Interval(Date(2018, 1, 5), Date(2018, 4, 5)).start_of_series('month')
|
|
1445
|
+
[Date(2018, 1, 1), Date(2018, 2, 1), Date(2018, 3, 1), Date(2018, 4, 1)]
|
|
1446
|
+
>>> Interval(Date(2018, 4, 30), Date(2018, 7, 30)).start_of_series('month')
|
|
1447
|
+
[Date(2018, 4, 1), Date(2018, 5, 1), Date(2018, 6, 1), Date(2018, 7, 1)]
|
|
1448
|
+
>>> Interval(Date(2018, 1, 5), Date(2018, 4, 5)).start_of_series('week')
|
|
1449
|
+
[Date(2018, 1, 1), Date(2018, 1, 8), ..., Date(2018, 4, 2)]
|
|
1450
|
+
"""
|
|
1451
|
+
begdate = self.begdate.start_of(unit)
|
|
1452
|
+
enddate = self.enddate.start_of(unit)
|
|
1453
|
+
interval = _pendulum.interval(begdate, enddate)
|
|
1454
|
+
return [Date.instance(d).start_of(unit) for d in interval.range(f'{unit}s')]
|
|
1455
|
+
|
|
1416
1456
|
def end_of_series(self, unit='month') -> list[Date]:
|
|
1417
1457
|
"""Return a series between and inclusive of begdate and enddate.
|
|
1418
1458
|
|
|
1419
1459
|
>>> Interval(Date(2018, 1, 5), Date(2018, 4, 5)).end_of_series('month')
|
|
1420
1460
|
[Date(2018, 1, 31), Date(2018, 2, 28), Date(2018, 3, 31), Date(2018, 4, 30)]
|
|
1461
|
+
>>> Interval(Date(2018, 4, 30), Date(2018, 7, 30)).end_of_series('month')
|
|
1462
|
+
[Date(2018, 4, 30), Date(2018, 5, 31), Date(2018, 6, 30), Date(2018, 7, 31)]
|
|
1421
1463
|
>>> Interval(Date(2018, 1, 5), Date(2018, 4, 5)).end_of_series('week')
|
|
1422
1464
|
[Date(2018, 1, 7), Date(2018, 1, 14), ..., Date(2018, 4, 8)]
|
|
1423
1465
|
"""
|
|
1424
1466
|
begdate = self.begdate.end_of(unit)
|
|
1425
1467
|
enddate = self.enddate.end_of(unit)
|
|
1426
1468
|
interval = _pendulum.interval(begdate, enddate)
|
|
1427
|
-
return [Date.instance(d) for d in interval.range(f'{unit}s')]
|
|
1469
|
+
return [Date.instance(d).end_of(unit) for d in interval.range(f'{unit}s')]
|
|
1428
1470
|
|
|
1429
1471
|
def days(self) -> int:
|
|
1430
1472
|
"""Return days between (begdate, enddate] or negative (enddate, begdate].
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
date/__init__.py,sha256=A3XyfTndgbAkc-rfT_InuuU9uORhPgGxUT_yEz-heOM,2747
|
|
2
|
+
date/date.py,sha256=K10ETuUqqhgFLU7backJGrItKqpZ97szDE0l6RWNKtY,55855
|
|
3
|
+
date/extras.py,sha256=7xsOsdhKrmGoyLl5W4Xhg9TfuytaaIH7uKWW9PvR5sE,2832
|
|
4
|
+
opendate-0.1.5.dist-info/LICENSE,sha256=V4Rx8WWy7v8Fim6PHcEBszpZkDLbCHeorz1e_gr0Cbk,1111
|
|
5
|
+
opendate-0.1.5.dist-info/METADATA,sha256=7PMv5fe7Hu2F3jc75ZE9nU2pXIpzU2ozOJfs0vs3DUE,1841
|
|
6
|
+
opendate-0.1.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
7
|
+
opendate-0.1.5.dist-info/RECORD,,
|
opendate-0.1.3.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
date/__init__.py,sha256=OUG51eAQp1unyaQT2pxSXrsU_VUorfofQ6xcGLmJ9OM,2693
|
|
2
|
-
date/date.py,sha256=W6TcGhkRfaDNtY6gWeLfJy-pi80M10CTqWTpQKXhDEU,53971
|
|
3
|
-
date/extras.py,sha256=7xsOsdhKrmGoyLl5W4Xhg9TfuytaaIH7uKWW9PvR5sE,2832
|
|
4
|
-
opendate-0.1.3.dist-info/LICENSE,sha256=V4Rx8WWy7v8Fim6PHcEBszpZkDLbCHeorz1e_gr0Cbk,1111
|
|
5
|
-
opendate-0.1.3.dist-info/METADATA,sha256=cySMy5_i5RWt0XTzOO3UUmz6qSrBONhSiEtES2HXwMI,1816
|
|
6
|
-
opendate-0.1.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
7
|
-
opendate-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|