opendate 0.1.4__py3-none-any.whl → 0.1.6__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 +1 -1
- date/date.py +35 -15
- {opendate-0.1.4.dist-info → opendate-0.1.6.dist-info}/METADATA +2 -2
- opendate-0.1.6.dist-info/RECORD +7 -0
- opendate-0.1.4.dist-info/RECORD +0 -7
- {opendate-0.1.4.dist-info → opendate-0.1.6.dist-info}/LICENSE +0 -0
- {opendate-0.1.4.dist-info → opendate-0.1.6.dist-info}/WHEEL +0 -0
date/__init__.py
CHANGED
date/date.py
CHANGED
|
@@ -1040,7 +1040,7 @@ class Time(_pendulum.Time):
|
|
|
1040
1040
|
| np.datetime64
|
|
1041
1041
|
| Self
|
|
1042
1042
|
| None,
|
|
1043
|
-
tz: str | _zoneinfo.ZoneInfo | _datetime.tzinfo | None =
|
|
1043
|
+
tz: str | _zoneinfo.ZoneInfo | _datetime.tzinfo | None = None,
|
|
1044
1044
|
raise_err: bool = False,
|
|
1045
1045
|
) -> Self | None:
|
|
1046
1046
|
"""From datetime-like object
|
|
@@ -1061,11 +1061,12 @@ class Time(_pendulum.Time):
|
|
|
1061
1061
|
raise ValueError('Empty value')
|
|
1062
1062
|
return
|
|
1063
1063
|
|
|
1064
|
-
if obj.__class__ == cls:
|
|
1064
|
+
if obj.__class__ == cls and not tz:
|
|
1065
1065
|
return obj
|
|
1066
1066
|
|
|
1067
|
-
|
|
1068
|
-
|
|
1067
|
+
tz = tz or obj.tzinfo or UTC
|
|
1068
|
+
|
|
1069
|
+
return cls(obj.hour, obj.minute, obj.second, obj.microsecond, tzinfo=tz)
|
|
1069
1070
|
|
|
1070
1071
|
|
|
1071
1072
|
class DateTime(DateBusinessMixin, _pendulum.DateTime):
|
|
@@ -1219,7 +1220,7 @@ class DateTime(DateBusinessMixin, _pendulum.DateTime):
|
|
|
1219
1220
|
| np.datetime64
|
|
1220
1221
|
| Self
|
|
1221
1222
|
| None,
|
|
1222
|
-
tz: str | _zoneinfo.ZoneInfo | _datetime.tzinfo | None =
|
|
1223
|
+
tz: str | _zoneinfo.ZoneInfo | _datetime.tzinfo | None = None,
|
|
1223
1224
|
raise_err: bool = False,
|
|
1224
1225
|
) -> Self | None:
|
|
1225
1226
|
"""From datetime-like object
|
|
@@ -1263,28 +1264,30 @@ class DateTime(DateBusinessMixin, _pendulum.DateTime):
|
|
|
1263
1264
|
raise ValueError('Empty value')
|
|
1264
1265
|
return
|
|
1265
1266
|
|
|
1266
|
-
if obj.__class__ == cls:
|
|
1267
|
+
if obj.__class__ == cls and not tz:
|
|
1267
1268
|
return obj
|
|
1268
1269
|
|
|
1269
1270
|
if isinstance(obj, pd.Timestamp):
|
|
1270
1271
|
obj = obj.to_pydatetime()
|
|
1271
|
-
return cls.instance(obj, tz=tz)
|
|
1272
|
+
return cls.instance(obj, tz=tz or UTC)
|
|
1272
1273
|
if isinstance(obj, np.datetime64):
|
|
1273
1274
|
obj = np.datetime64(obj, 'us').astype(_datetime.datetime)
|
|
1274
|
-
return cls.instance(obj, tz=tz)
|
|
1275
|
+
return cls.instance(obj, tz=tz or UTC)
|
|
1276
|
+
|
|
1277
|
+
if obj.__class__ == Date:
|
|
1278
|
+
return cls(obj.year, obj.month, obj.day, tzinfo=tz or UTC)
|
|
1279
|
+
if isinstance(obj, _datetime.date) and not isinstance(obj, _datetime.datetime):
|
|
1280
|
+
return cls(obj.year, obj.month, obj.day, tzinfo=tz or UTC)
|
|
1281
|
+
|
|
1282
|
+
tz = tz or obj.tzinfo or UTC
|
|
1275
1283
|
|
|
1276
1284
|
if obj.__class__ == Time:
|
|
1277
1285
|
return cls.combine(Date.today(), obj, tzinfo=tz)
|
|
1278
1286
|
if isinstance(obj, _datetime.time):
|
|
1279
1287
|
return cls.combine(Date.today(), obj, tzinfo=tz)
|
|
1280
1288
|
|
|
1281
|
-
if obj.__class__ == Date:
|
|
1282
|
-
return cls(obj.year, obj.month, obj.day, tzinfo=tz)
|
|
1283
|
-
if isinstance(obj, _datetime.date) and not isinstance(obj, _datetime.datetime):
|
|
1284
|
-
return cls(obj.year, obj.month, obj.day, tzinfo=tz)
|
|
1285
|
-
|
|
1286
1289
|
return cls(obj.year, obj.month, obj.day, obj.hour, obj.minute,
|
|
1287
|
-
obj.second, obj.microsecond,
|
|
1290
|
+
obj.second, obj.microsecond, tzinfo=tz)
|
|
1288
1291
|
|
|
1289
1292
|
|
|
1290
1293
|
class IntervalError(AttributeError):
|
|
@@ -1438,18 +1441,35 @@ class Interval:
|
|
|
1438
1441
|
yield thedate
|
|
1439
1442
|
thedate = thedate.add(days=1)
|
|
1440
1443
|
|
|
1444
|
+
def start_of_series(self, unit='month') -> list[Date]:
|
|
1445
|
+
"""Return a series between and inclusive of begdate and enddate.
|
|
1446
|
+
|
|
1447
|
+
>>> Interval(Date(2018, 1, 5), Date(2018, 4, 5)).start_of_series('month')
|
|
1448
|
+
[Date(2018, 1, 1), Date(2018, 2, 1), Date(2018, 3, 1), Date(2018, 4, 1)]
|
|
1449
|
+
>>> Interval(Date(2018, 4, 30), Date(2018, 7, 30)).start_of_series('month')
|
|
1450
|
+
[Date(2018, 4, 1), Date(2018, 5, 1), Date(2018, 6, 1), Date(2018, 7, 1)]
|
|
1451
|
+
>>> Interval(Date(2018, 1, 5), Date(2018, 4, 5)).start_of_series('week')
|
|
1452
|
+
[Date(2018, 1, 1), Date(2018, 1, 8), ..., Date(2018, 4, 2)]
|
|
1453
|
+
"""
|
|
1454
|
+
begdate = self.begdate.start_of(unit)
|
|
1455
|
+
enddate = self.enddate.start_of(unit)
|
|
1456
|
+
interval = _pendulum.interval(begdate, enddate)
|
|
1457
|
+
return [Date.instance(d).start_of(unit) for d in interval.range(f'{unit}s')]
|
|
1458
|
+
|
|
1441
1459
|
def end_of_series(self, unit='month') -> list[Date]:
|
|
1442
1460
|
"""Return a series between and inclusive of begdate and enddate.
|
|
1443
1461
|
|
|
1444
1462
|
>>> Interval(Date(2018, 1, 5), Date(2018, 4, 5)).end_of_series('month')
|
|
1445
1463
|
[Date(2018, 1, 31), Date(2018, 2, 28), Date(2018, 3, 31), Date(2018, 4, 30)]
|
|
1464
|
+
>>> Interval(Date(2018, 4, 30), Date(2018, 7, 30)).end_of_series('month')
|
|
1465
|
+
[Date(2018, 4, 30), Date(2018, 5, 31), Date(2018, 6, 30), Date(2018, 7, 31)]
|
|
1446
1466
|
>>> Interval(Date(2018, 1, 5), Date(2018, 4, 5)).end_of_series('week')
|
|
1447
1467
|
[Date(2018, 1, 7), Date(2018, 1, 14), ..., Date(2018, 4, 8)]
|
|
1448
1468
|
"""
|
|
1449
1469
|
begdate = self.begdate.end_of(unit)
|
|
1450
1470
|
enddate = self.enddate.end_of(unit)
|
|
1451
1471
|
interval = _pendulum.interval(begdate, enddate)
|
|
1452
|
-
return [Date.instance(d) for d in interval.range(f'{unit}s')]
|
|
1472
|
+
return [Date.instance(d).end_of(unit) for d in interval.range(f'{unit}s')]
|
|
1453
1473
|
|
|
1454
1474
|
def days(self) -> int:
|
|
1455
1475
|
"""Return days between (begdate, enddate] or negative (enddate, begdate].
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
date/__init__.py,sha256=vPv4a112UZpPY0IShVpSq4ffImTTinxuySxWt1vyeS0,2747
|
|
2
|
+
date/date.py,sha256=S10D2_VtXraKzpdS0xtbzLEF_n8ny0Xadmtnc4AKSCk,55943
|
|
3
|
+
date/extras.py,sha256=7xsOsdhKrmGoyLl5W4Xhg9TfuytaaIH7uKWW9PvR5sE,2832
|
|
4
|
+
opendate-0.1.6.dist-info/LICENSE,sha256=V4Rx8WWy7v8Fim6PHcEBszpZkDLbCHeorz1e_gr0Cbk,1111
|
|
5
|
+
opendate-0.1.6.dist-info/METADATA,sha256=mbJikEalgLHajmzvTEF_MRiLUPGX0u94I5DdFnva6JQ,1841
|
|
6
|
+
opendate-0.1.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
7
|
+
opendate-0.1.6.dist-info/RECORD,,
|
opendate-0.1.4.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
date/__init__.py,sha256=eB3ZluWh9M_QVfMOpmjeigLItgUl7mywdby88ffQfbE,2747
|
|
2
|
-
date/date.py,sha256=Z-8-5T8TfLtgiGe0ahK7QIgXjbBEDmrGRw8zEhiQD2Y,54819
|
|
3
|
-
date/extras.py,sha256=7xsOsdhKrmGoyLl5W4Xhg9TfuytaaIH7uKWW9PvR5sE,2832
|
|
4
|
-
opendate-0.1.4.dist-info/LICENSE,sha256=V4Rx8WWy7v8Fim6PHcEBszpZkDLbCHeorz1e_gr0Cbk,1111
|
|
5
|
-
opendate-0.1.4.dist-info/METADATA,sha256=up550EjO3j1IFI7F_iUrlugXe6rkcfpQpeRCQrEqgN8,1816
|
|
6
|
-
opendate-0.1.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
7
|
-
opendate-0.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|