none-shall-parse 0.4.7__tar.gz → 0.5.0__tar.gz
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-0.4.7 → none_shall_parse-0.5.0}/PKG-INFO +1 -1
- {none_shall_parse-0.4.7 → none_shall_parse-0.5.0}/pyproject.toml +1 -1
- {none_shall_parse-0.4.7 → none_shall_parse-0.5.0}/src/none_shall_parse/__init__.py +2 -2
- {none_shall_parse-0.4.7 → none_shall_parse-0.5.0}/src/none_shall_parse/dates.py +25 -6
- {none_shall_parse-0.4.7 → none_shall_parse-0.5.0}/README.md +0 -0
- {none_shall_parse-0.4.7 → none_shall_parse-0.5.0}/src/none_shall_parse/imeis.py +0 -0
- {none_shall_parse-0.4.7 → none_shall_parse-0.5.0}/src/none_shall_parse/lists.py +0 -0
- {none_shall_parse-0.4.7 → none_shall_parse-0.5.0}/src/none_shall_parse/parse.py +0 -0
- {none_shall_parse-0.4.7 → none_shall_parse-0.5.0}/src/none_shall_parse/strings.py +0 -0
- {none_shall_parse-0.4.7 → none_shall_parse-0.5.0}/src/none_shall_parse/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: none-shall-parse
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
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>
|
|
@@ -14,7 +14,7 @@ from __future__ import annotations
|
|
|
14
14
|
from .dates import (
|
|
15
15
|
DateUtilsError, assert_week_start_date_is_valid,
|
|
16
16
|
assert_month_start_date_is_valid,
|
|
17
|
-
get_datetime_now, za_now,
|
|
17
|
+
get_datetime_now, za_now, utc_now,
|
|
18
18
|
za_ordinal_year_day_now,
|
|
19
19
|
za_ordinal_year_day_tomorrow, utc_epoch_start,
|
|
20
20
|
now_offset_n_minutes, now_offset_n_hours,
|
|
@@ -85,7 +85,7 @@ __license__ = "MIT"
|
|
|
85
85
|
__all__ = (
|
|
86
86
|
"DateUtilsError", "assert_week_start_date_is_valid",
|
|
87
87
|
"assert_month_start_date_is_valid",
|
|
88
|
-
"get_datetime_now", "za_now",
|
|
88
|
+
"get_datetime_now", "za_now", "utc_now",
|
|
89
89
|
"za_ordinal_year_day_now",
|
|
90
90
|
"za_ordinal_year_day_tomorrow", "utc_epoch_start",
|
|
91
91
|
"now_offset_n_minutes", "now_offset_n_hours",
|
|
@@ -71,6 +71,15 @@ def za_now() -> DateTime:
|
|
|
71
71
|
return get_datetime_now(naive=False, tz=ZA_TZ)
|
|
72
72
|
|
|
73
73
|
|
|
74
|
+
def utc_now() -> DateTime:
|
|
75
|
+
"""
|
|
76
|
+
Shorthand for the current date and time in the UTC timezone.
|
|
77
|
+
Returns:
|
|
78
|
+
pendulum.DateTime: The current date and time in the UTC timezone.
|
|
79
|
+
"""
|
|
80
|
+
return get_datetime_now(naive=False, tz=UTC_TZ)
|
|
81
|
+
|
|
82
|
+
|
|
74
83
|
def za_ordinal_year_day_now() -> int:
|
|
75
84
|
"""
|
|
76
85
|
Returns the current ordinal day of the year for the ZA_TZ timezone.
|
|
@@ -509,13 +518,21 @@ def unroll_span_func(
|
|
|
509
518
|
DateUtilsError: If the date range cannot be processed due to invalid dates or formatting.
|
|
510
519
|
"""
|
|
511
520
|
cover = pendulum.now() if cover is None else cover
|
|
512
|
-
|
|
521
|
+
|
|
513
522
|
try:
|
|
514
523
|
start, end = f(cover)
|
|
515
524
|
start = pendulum.instance(start)
|
|
516
|
-
start = start.naive() if naive else start
|
|
517
525
|
end = pendulum.instance(end)
|
|
518
|
-
|
|
526
|
+
|
|
527
|
+
# Determine naiveness from the dates returned by f, not from cover
|
|
528
|
+
naive = start.tzinfo is None
|
|
529
|
+
if naive:
|
|
530
|
+
start = start.naive()
|
|
531
|
+
end = end.naive()
|
|
532
|
+
|
|
533
|
+
# Get actual current time for filtering future dates (always "now", not cover)
|
|
534
|
+
current_date_sentinel = pendulum.now().naive() if naive else pendulum.now()
|
|
535
|
+
|
|
519
536
|
except Exception as e:
|
|
520
537
|
raise DateUtilsError(f"Function f failed to compute date range: {str(e)}")
|
|
521
538
|
|
|
@@ -528,9 +545,11 @@ def unroll_span_func(
|
|
|
528
545
|
ord_days = []
|
|
529
546
|
iso_date_strings = []
|
|
530
547
|
for dt in interval.range(unit="days"):
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
548
|
+
# Filter: only include dates up to today (not future dates)
|
|
549
|
+
if dt <= current_date_sentinel and dt < end:
|
|
550
|
+
date_range.append(dt)
|
|
551
|
+
ord_days.append(dt.day_of_year)
|
|
552
|
+
iso_date_strings.append(dt.format('YYYY-MM-DD'))
|
|
534
553
|
|
|
535
554
|
return date_range, ord_days, iso_date_strings, start, end
|
|
536
555
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|