none-shall-parse 0.6.3__py3-none-any.whl → 0.6.4__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.
none_shall_parse/dates.py
CHANGED
|
@@ -703,32 +703,34 @@ def get_notice_end_date(given_date: DateTimeLike | date | Date | None = None) ->
|
|
|
703
703
|
return end_date
|
|
704
704
|
|
|
705
705
|
|
|
706
|
-
def dt_to_za_time_string(v: DateTimeOrDateLike |
|
|
707
|
-
"""
|
|
706
|
+
def dt_to_za_time_string(v: DateTimeOrDateLike | None) -> str | None:
|
|
707
|
+
"""
|
|
708
|
+
Convert DateTime or Date to South Africa time string.
|
|
708
709
|
|
|
709
710
|
For datetime objects: returns "YYYY-MM-DD HH:MM:SS" in ZA timezone.
|
|
710
711
|
For date objects: returns "YYYY-MM-DD" (no time component).
|
|
711
712
|
For None: returns None.
|
|
712
|
-
|
|
713
|
+
|
|
714
|
+
If an uncastable type is provided, DateUtilsError is raised.
|
|
715
|
+
Examples include Pandas NaT or NaN objects.
|
|
713
716
|
"""
|
|
714
717
|
if v is None:
|
|
715
718
|
return None
|
|
716
719
|
|
|
717
|
-
# Handle float values (NaN from pandas NULL database values)
|
|
718
|
-
if isinstance(v, float):
|
|
719
|
-
return None
|
|
720
|
-
|
|
721
720
|
# Handle date objects (no time component)
|
|
722
721
|
if isinstance(v, date) and not isinstance(v, datetime):
|
|
723
722
|
return v.strftime("%Y-%m-%d")
|
|
724
723
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
724
|
+
try:
|
|
725
|
+
# Convert datetime to Pendulum
|
|
726
|
+
naive = v.tzinfo is None
|
|
727
|
+
if naive:
|
|
728
|
+
pdt = pendulum.instance(v, tz=ZA_TZ)
|
|
729
|
+
else:
|
|
730
|
+
pdt = pendulum.instance(v).in_timezone(ZA_TZ)
|
|
731
|
+
return pdt.strftime("%Y-%m-%d %H:%M:%S")
|
|
732
|
+
except Exception:
|
|
733
|
+
raise DateUtilsError("Failed to cast `{}` to pendulum instance".format(v))
|
|
732
734
|
|
|
733
735
|
|
|
734
736
|
def months_ago_selection() -> List[Tuple[int, str]]:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: none-shall-parse
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.4
|
|
4
4
|
Summary: Trinity Shared Python utilities.
|
|
5
5
|
Author: Andries Niemandt, Jan Badenhorst
|
|
6
6
|
Author-email: Andries Niemandt <andries.niemandt@trintel.co.za>, Jan Badenhorst <jan@trintel.co.za>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
none_shall_parse/__init__.py,sha256=VQrtFMNFZGpZAWhbSnVuJIhGamkb2WUzXOzleUQL274,4051
|
|
2
|
-
none_shall_parse/dates.py,sha256=
|
|
2
|
+
none_shall_parse/dates.py,sha256=0S1yI16HXk7U8UfYCmzud8V2PjoaLEOLz5FM1YOa4dU,28555
|
|
3
3
|
none_shall_parse/imeis.py,sha256=1fFRdFryOAg2djbZjtDmJb8aRdKZ-vhqbJUVy-AFaEA,6769
|
|
4
4
|
none_shall_parse/lists.py,sha256=AZ5UbPYcLJQkLTP5X6mD72c2gcJ6helgfzBAVRWft2U,1746
|
|
5
5
|
none_shall_parse/parse.py,sha256=77bXZAtwFksRwuZ9Ax0lPxEjFpyjkQBqRa5mBc1WkF4,6843
|
|
6
6
|
none_shall_parse/strings.py,sha256=F7491CJAHJjL7vdEGwoH_4S6PjaovYUS_yzVGJ-bYIE,8463
|
|
7
7
|
none_shall_parse/types.py,sha256=WAgILMtW2_fm9MBpUuQvq68yXYBNd3rnSoQk70ibOd4,1320
|
|
8
|
-
none_shall_parse-0.6.
|
|
9
|
-
none_shall_parse-0.6.
|
|
10
|
-
none_shall_parse-0.6.
|
|
8
|
+
none_shall_parse-0.6.4.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
9
|
+
none_shall_parse-0.6.4.dist-info/METADATA,sha256=q1yr3x19C96ADSTgGXI6HPjzJIHxA8JJeX7NlpNT3aE,1701
|
|
10
|
+
none_shall_parse-0.6.4.dist-info/RECORD,,
|
|
File without changes
|