dycw-utilities 0.138.15__py3-none-any.whl → 0.138.16__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-utilities
3
- Version: 0.138.15
3
+ Version: 0.138.16
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -1,4 +1,4 @@
1
- utilities/__init__.py,sha256=truMbrEMkwTgWjlGtWBTO0md1YlF6g_-gFSBi6iu0N0,61
1
+ utilities/__init__.py,sha256=UL4hpBrSmrPmk3IahPJQKeqtiFq6zh3H6Bk-mMUlBc0,61
2
2
  utilities/aiolimiter.py,sha256=mD0wEiqMgwpty4XTbawFpnkkmJS6R4JRsVXFUaoitSU,628
3
3
  utilities/altair.py,sha256=HeZBVUocjkrTNwwKrClppsIqgNFF-ykv05HfZSoHYno,9104
4
4
  utilities/asyncio.py,sha256=dcGeKQzjLBXxKzZkVIk5oZsFXEcynVbRB9iNB5XEDZk,38526
@@ -85,11 +85,11 @@ utilities/tzlocal.py,sha256=KyCXEgCTjqGFx-389JdTuhMRUaT06U1RCMdWoED-qro,728
85
85
  utilities/uuid.py,sha256=32p7DGHGM2Btx6PcBvCZvERSWbpupMXqx6FppPoSoTU,612
86
86
  utilities/version.py,sha256=ufhJMmI6KPs1-3wBI71aj5wCukd3sP_m11usLe88DNA,5117
87
87
  utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
88
- utilities/whenever.py,sha256=Ftf-7neIyKjC_sGnQmFtac4BxPMNB547eHv4tenhwQo,23226
88
+ utilities/whenever.py,sha256=4ZzVB6IOT4vTUbI0-0TgPgnqZouiZaLzLORza2jEB3Q,24210
89
89
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
90
90
  utilities/zoneinfo.py,sha256=oEH-nL3t4h9uawyZqWDtNtDAl6M-CLpLYGI_nI6DulM,1971
91
- dycw_utilities-0.138.15.dist-info/METADATA,sha256=sO2p6FGX2-yznzkykDtCaS1X5ngWFddPkyE16Ho-36g,1639
92
- dycw_utilities-0.138.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
- dycw_utilities-0.138.15.dist-info/entry_points.txt,sha256=uLj5QWWVXv8tnMaRX3ZGYpt7w1xzLWU6LxbFhELEpkc,68
94
- dycw_utilities-0.138.15.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
95
- dycw_utilities-0.138.15.dist-info/RECORD,,
91
+ dycw_utilities-0.138.16.dist-info/METADATA,sha256=oiLhNbHe_C4E8EiVpOJkxjCsIBesSJHxhutHG7LVlQg,1639
92
+ dycw_utilities-0.138.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
+ dycw_utilities-0.138.16.dist-info/entry_points.txt,sha256=uLj5QWWVXv8tnMaRX3ZGYpt7w1xzLWU6LxbFhELEpkc,68
94
+ dycw_utilities-0.138.16.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
95
+ dycw_utilities-0.138.16.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.138.15"
3
+ __version__ = "0.138.16"
utilities/whenever.py CHANGED
@@ -636,7 +636,39 @@ class ToNanosError(Exception):
636
636
  ##
637
637
 
638
638
 
639
- def to_py_time_delta(delta: DateDelta | TimeDelta | DateTimeDelta, /) -> dt.timedelta:
639
+ @overload
640
+ def to_py_date_or_date_time(date_or_date_time: Date, /) -> dt.date: ...
641
+ @overload
642
+ def to_py_date_or_date_time(date_or_date_time: ZonedDateTime, /) -> dt.datetime: ...
643
+ @overload
644
+ def to_py_date_or_date_time(date_or_date_time: None, /) -> None: ...
645
+ def to_py_date_or_date_time(
646
+ date_or_date_time: Date | ZonedDateTime | None, /
647
+ ) -> dt.date | None:
648
+ """Convert a Date or ZonedDateTime into a standard library equivalent."""
649
+ match date_or_date_time:
650
+ case Date() as date:
651
+ return date.py_date()
652
+ case ZonedDateTime() as date_time:
653
+ return date_time.py_datetime()
654
+ case None:
655
+ return None
656
+ case _ as never:
657
+ assert_never(never)
658
+
659
+
660
+ ##
661
+
662
+
663
+ @overload
664
+ def to_py_time_delta(
665
+ delta: DateDelta | TimeDelta | DateTimeDelta, /
666
+ ) -> dt.timedelta: ...
667
+ @overload
668
+ def to_py_time_delta(delta: None, /) -> None: ...
669
+ def to_py_time_delta(
670
+ delta: DateDelta | TimeDelta | DateTimeDelta | None, /
671
+ ) -> dt.timedelta | None:
640
672
  """Try convert a DateDelta to a standard library timedelta."""
641
673
  match delta:
642
674
  case DateDelta():
@@ -651,6 +683,8 @@ def to_py_time_delta(delta: DateDelta | TimeDelta | DateTimeDelta, /) -> dt.time
651
683
  return to_py_time_delta(delta.date_part()) + to_py_time_delta(
652
684
  delta.time_part()
653
685
  )
686
+ case None:
687
+ return None
654
688
  case _ as never:
655
689
  assert_never(never)
656
690
 
@@ -888,6 +922,7 @@ __all__ = [
888
922
  "to_local_plain",
889
923
  "to_months",
890
924
  "to_nanos",
925
+ "to_py_date_or_date_time",
891
926
  "to_py_time_delta",
892
927
  "to_zoned_date_time",
893
928
  "two_digit_year_month",