none-shall-parse 0.5.0__py3-none-any.whl → 0.6.0__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
@@ -3,7 +3,7 @@ import logging
3
3
  import time
4
4
  from datetime import date, datetime
5
5
  from typing import Callable, Any, Tuple, Sequence, List
6
- from .types import DateTimeLike
6
+ from .types import DateTimeLike, DateTimeOrDateLike
7
7
 
8
8
  import pendulum
9
9
  from pendulum import DateTime, Date
@@ -417,7 +417,7 @@ def month_span(mso: int) -> Callable[[DateTimeLike], Tuple[DateTime, DateTime]]:
417
417
  return find_dates
418
418
 
419
419
 
420
- def arb_span(dates: Sequence[str | DateTimeLike], naive: bool = False) -> Callable[
420
+ def arb_span(dates: Sequence[str | DateTimeOrDateLike], naive: bool = False) -> Callable[
421
421
  [Any], Tuple[DateTime, DateTime]]:
422
422
  """
423
423
  Parses two given dates and returns a callable function that provides the date range
@@ -452,15 +452,20 @@ def arb_span(dates: Sequence[str | DateTimeLike], naive: bool = False) -> Callab
452
452
 
453
453
  parsed_dates.append(parsed.start_of('day'))
454
454
  else:
455
- # It's already a datetime
456
- if date.tzinfo is None:
457
- # Input is naive, keep it naive using pendulum.naive()
458
- parsed = pendulum.naive(date.year, date.month, date.day,
459
- date.hour, date.minute, date.second,
460
- date.microsecond)
455
+ # It's already a datetime-like object
456
+ if isinstance(date, datetime):
457
+ # datetime objects have tzinfo, hour, minute, etc.
458
+ if date.tzinfo is None:
459
+ # Input is naive, keep it naive using pendulum.naive()
460
+ parsed = pendulum.naive(date.year, date.month, date.day,
461
+ date.hour, date.minute, date.second,
462
+ date.microsecond)
463
+ else:
464
+ # Input is timezone-aware, preserve it
465
+ parsed = pendulum.instance(date)
461
466
  else:
462
- # Input is timezone-aware, preserve it
463
- parsed = pendulum.instance(date)
467
+ # date objects (no time component, no tzinfo) - treat as naive
468
+ parsed = pendulum.naive(date.year, date.month, date.day)
464
469
 
465
470
  parsed_dates.append(parsed.start_of('day'))
466
471
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: none-shall-parse
3
- Version: 0.5.0
3
+ Version: 0.6.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>
@@ -1,10 +1,10 @@
1
1
  none_shall_parse/__init__.py,sha256=ekNMvJaRzR-SOv2bQAOuH86ImPHXGpIj2NbeCO45GOc,3897
2
- none_shall_parse/dates.py,sha256=Dp0BgP6d5U_q1u4_8WunVpLW6HkKPsYV-JXzCgW4a4Y,27454
2
+ none_shall_parse/dates.py,sha256=MeBc_Z4rNloTqUkUq9RLfuKg3gkj7SAdlzJM-gHUwL8,27824
3
3
  none_shall_parse/imeis.py,sha256=20pONoUhLKomZxAJegqSSjG72hZjYs60r8IcaRt-15M,6770
4
4
  none_shall_parse/lists.py,sha256=PKtYD8H1Z7MqbJQ5eFpsK_jgexLwiratMJiYeRMiOwc,1701
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.5.0.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
9
- none_shall_parse-0.5.0.dist-info/METADATA,sha256=dz5kIHgEwuEtWYwBev_r8oOUULd18fSn7-e3AW9P_jY,1701
10
- none_shall_parse-0.5.0.dist-info/RECORD,,
8
+ none_shall_parse-0.6.0.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
9
+ none_shall_parse-0.6.0.dist-info/METADATA,sha256=xe3e8WZa_AyId0ml5x-O05AaHloy1fkqgYRDLDSGyBQ,1701
10
+ none_shall_parse-0.6.0.dist-info/RECORD,,