python-dateutil-rust 2.9.0__cp312-cp312-manylinux_2_34_x86_64.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.
- dateutil/__init__.py +24 -0
- dateutil/_common.py +43 -0
- dateutil/_dateutil.cpython-312-x86_64-linux-gnu.so +0 -0
- dateutil/easter.py +89 -0
- dateutil/parser/__init__.py +64 -0
- dateutil/parser/_parser.py +66 -0
- dateutil/parser/_parser_py.py +1609 -0
- dateutil/parser/isoparser.py +15 -0
- dateutil/relativedelta.py +12 -0
- dateutil/rrule.py +38 -0
- dateutil/tz/__init__.py +12 -0
- dateutil/tz/_common.py +421 -0
- dateutil/tz/_factories.py +80 -0
- dateutil/tz/tz.py +657 -0
- dateutil/tz/win.py +370 -0
- dateutil/tzwin.py +2 -0
- dateutil/utils.py +71 -0
- dateutil/zoneinfo/__init__.py +167 -0
- dateutil/zoneinfo/dateutil-zoneinfo.tar.gz +0 -0
- dateutil/zoneinfo/rebuild.py +75 -0
- python_dateutil_rust-2.9.0.dist-info/METADATA +45 -0
- python_dateutil_rust-2.9.0.dist-info/RECORD +26 -0
- python_dateutil_rust-2.9.0.dist-info/WHEEL +4 -0
- python_dateutil_rust-2.9.0.dist-info/licenses/LICENSE +54 -0
- python_dateutil_rust-2.9.0.dist-info/licenses/NOTICE +21 -0
- python_dateutil_rust-2.9.0.dist-info/sboms/python-dateutil-rust.cyclonedx.json +1081 -0
dateutil/__init__.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
from ._version import version as __version__
|
|
6
|
+
except ImportError:
|
|
7
|
+
__version__ = 'unknown'
|
|
8
|
+
|
|
9
|
+
__all__ = ['easter', 'parser', 'relativedelta', 'rrule', 'tz',
|
|
10
|
+
'utils', 'zoneinfo']
|
|
11
|
+
|
|
12
|
+
def __getattr__(name):
|
|
13
|
+
import importlib
|
|
14
|
+
|
|
15
|
+
if name in __all__:
|
|
16
|
+
return importlib.import_module("." + name, __name__)
|
|
17
|
+
raise AttributeError(
|
|
18
|
+
"module {!r} has not attribute {!r}".format(__name__, name)
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def __dir__():
|
|
23
|
+
# __dir__ should include all the lazy-importable modules as well.
|
|
24
|
+
return [x for x in globals() if x not in sys.modules] + __all__
|
dateutil/_common.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Common code used in multiple modules.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class weekday(object):
|
|
7
|
+
__slots__ = ["weekday", "n"]
|
|
8
|
+
|
|
9
|
+
def __init__(self, weekday, n=None):
|
|
10
|
+
self.weekday = weekday
|
|
11
|
+
self.n = n
|
|
12
|
+
|
|
13
|
+
def __call__(self, n):
|
|
14
|
+
if n == self.n:
|
|
15
|
+
return self
|
|
16
|
+
else:
|
|
17
|
+
return self.__class__(self.weekday, n)
|
|
18
|
+
|
|
19
|
+
def __eq__(self, other):
|
|
20
|
+
try:
|
|
21
|
+
if self.weekday != other.weekday or self.n != other.n:
|
|
22
|
+
return False
|
|
23
|
+
except AttributeError:
|
|
24
|
+
return False
|
|
25
|
+
return True
|
|
26
|
+
|
|
27
|
+
def __hash__(self):
|
|
28
|
+
return hash((
|
|
29
|
+
self.weekday,
|
|
30
|
+
self.n,
|
|
31
|
+
))
|
|
32
|
+
|
|
33
|
+
def __ne__(self, other):
|
|
34
|
+
return not (self == other)
|
|
35
|
+
|
|
36
|
+
def __repr__(self):
|
|
37
|
+
s = ("MO", "TU", "WE", "TH", "FR", "SA", "SU")[self.weekday]
|
|
38
|
+
if not self.n:
|
|
39
|
+
return s
|
|
40
|
+
else:
|
|
41
|
+
return "%s(%+d)" % (s, self.n)
|
|
42
|
+
|
|
43
|
+
# vim:ts=4:sw=4:et
|
|
Binary file
|
dateutil/easter.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
This module offers a generic Easter computing method for any given year, using
|
|
4
|
+
Western, Orthodox or Julian algorithms.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import datetime
|
|
8
|
+
|
|
9
|
+
__all__ = ["easter", "EASTER_JULIAN", "EASTER_ORTHODOX", "EASTER_WESTERN"]
|
|
10
|
+
|
|
11
|
+
EASTER_JULIAN = 1
|
|
12
|
+
EASTER_ORTHODOX = 2
|
|
13
|
+
EASTER_WESTERN = 3
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def easter(year, method=EASTER_WESTERN):
|
|
17
|
+
"""
|
|
18
|
+
This method was ported from the work done by GM Arts,
|
|
19
|
+
on top of the algorithm by Claus Tondering, which was
|
|
20
|
+
based in part on the algorithm of Ouding (1940), as
|
|
21
|
+
quoted in "Explanatory Supplement to the Astronomical
|
|
22
|
+
Almanac", P. Kenneth Seidelmann, editor.
|
|
23
|
+
|
|
24
|
+
This algorithm implements three different Easter
|
|
25
|
+
calculation methods:
|
|
26
|
+
|
|
27
|
+
1. Original calculation in Julian calendar, valid in
|
|
28
|
+
dates after 326 AD
|
|
29
|
+
2. Original method, with date converted to Gregorian
|
|
30
|
+
calendar, valid in years 1583 to 4099
|
|
31
|
+
3. Revised method, in Gregorian calendar, valid in
|
|
32
|
+
years 1583 to 4099 as well
|
|
33
|
+
|
|
34
|
+
These methods are represented by the constants:
|
|
35
|
+
|
|
36
|
+
* ``EASTER_JULIAN = 1``
|
|
37
|
+
* ``EASTER_ORTHODOX = 2``
|
|
38
|
+
* ``EASTER_WESTERN = 3``
|
|
39
|
+
|
|
40
|
+
The default method is method 3.
|
|
41
|
+
|
|
42
|
+
More about the algorithm may be found at:
|
|
43
|
+
|
|
44
|
+
`GM Arts: Easter Algorithms <http://www.gmarts.org/index.php?go=415>`_
|
|
45
|
+
|
|
46
|
+
and
|
|
47
|
+
|
|
48
|
+
`The Calendar FAQ: Easter <https://www.tondering.dk/claus/cal/easter.php>`_
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
if not (1 <= method <= 3):
|
|
53
|
+
raise ValueError("invalid method")
|
|
54
|
+
|
|
55
|
+
# g - Golden year - 1
|
|
56
|
+
# c - Century
|
|
57
|
+
# h - (23 - Epact) mod 30
|
|
58
|
+
# i - Number of days from March 21 to Paschal Full Moon
|
|
59
|
+
# j - Weekday for PFM (0=Sunday, etc)
|
|
60
|
+
# p - Number of days from March 21 to Sunday on or before PFM
|
|
61
|
+
# (-6 to 28 methods 1 & 3, to 56 for method 2)
|
|
62
|
+
# e - Extra days to add for method 2 (converting Julian
|
|
63
|
+
# date to Gregorian date)
|
|
64
|
+
|
|
65
|
+
y = year
|
|
66
|
+
g = y % 19
|
|
67
|
+
e = 0
|
|
68
|
+
if method < 3:
|
|
69
|
+
# Old method
|
|
70
|
+
i = (19*g + 15) % 30
|
|
71
|
+
j = (y + y//4 + i) % 7
|
|
72
|
+
if method == 2:
|
|
73
|
+
# Extra dates to convert Julian to Gregorian date
|
|
74
|
+
e = 10
|
|
75
|
+
if y > 1600:
|
|
76
|
+
e = e + y//100 - 16 - (y//100 - 16)//4
|
|
77
|
+
else:
|
|
78
|
+
# New method
|
|
79
|
+
c = y//100
|
|
80
|
+
h = (c - c//4 - (8*c + 13)//25 + 19*g + 15) % 30
|
|
81
|
+
i = h - (h//28)*(1 - (h//28)*(29//(h + 1))*((21 - g)//11))
|
|
82
|
+
j = (y + y//4 + i + 2 - c + c//4) % 7
|
|
83
|
+
|
|
84
|
+
# p can be from -6 to 56 corresponding to dates 22 March to 23 May
|
|
85
|
+
# (later dates apply to method 2, although 23 May never actually occurs)
|
|
86
|
+
p = i - j + e
|
|
87
|
+
d = 1 + (p + 27 + (p + 6)//40) % 31
|
|
88
|
+
m = 3 + (p + 26)//30
|
|
89
|
+
return datetime.date(int(y), int(m), int(d))
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Provenance: rustsmith Stage-1 mirror of dateutil/dateutil (Apache-2.0).
|
|
3
|
+
# Verbatim upstream `__init__` (names now resolve to the Rust-backed shims).
|
|
4
|
+
# -*- coding: utf-8 -*-
|
|
5
|
+
from ._parser import parse, parser, parserinfo, ParserError
|
|
6
|
+
from ._parser import DEFAULTPARSER, DEFAULTTZPARSER
|
|
7
|
+
from ._parser import UnknownTimezoneWarning
|
|
8
|
+
|
|
9
|
+
from ._parser import __doc__
|
|
10
|
+
|
|
11
|
+
from .isoparser import isoparser, isoparse
|
|
12
|
+
|
|
13
|
+
__all__ = ['parse', 'parser', 'parserinfo',
|
|
14
|
+
'isoparse', 'isoparser',
|
|
15
|
+
'ParserError',
|
|
16
|
+
'UnknownTimezoneWarning']
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
###
|
|
20
|
+
# Deprecate portions of the private interface so that downstream code that
|
|
21
|
+
# is improperly relying on it is given *some* notice.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def __deprecated_private_func(f):
|
|
25
|
+
from functools import wraps
|
|
26
|
+
import warnings
|
|
27
|
+
|
|
28
|
+
msg = ('{name} is a private function and may break without warning, '
|
|
29
|
+
'it will be moved and or renamed in future versions.')
|
|
30
|
+
msg = msg.format(name=f.__name__)
|
|
31
|
+
|
|
32
|
+
@wraps(f)
|
|
33
|
+
def deprecated_func(*args, **kwargs):
|
|
34
|
+
warnings.warn(msg, DeprecationWarning)
|
|
35
|
+
return f(*args, **kwargs)
|
|
36
|
+
|
|
37
|
+
return deprecated_func
|
|
38
|
+
|
|
39
|
+
def __deprecate_private_class(c):
|
|
40
|
+
import warnings
|
|
41
|
+
|
|
42
|
+
msg = ('{name} is a private class and may break without warning, '
|
|
43
|
+
'it will be moved and or renamed in future versions.')
|
|
44
|
+
msg = msg.format(name=c.__name__)
|
|
45
|
+
|
|
46
|
+
class private_class(c):
|
|
47
|
+
__doc__ = c.__doc__
|
|
48
|
+
|
|
49
|
+
def __init__(self, *args, **kwargs):
|
|
50
|
+
warnings.warn(msg, DeprecationWarning)
|
|
51
|
+
super(private_class, self).__init__(*args, **kwargs)
|
|
52
|
+
|
|
53
|
+
private_class.__name__ = c.__name__
|
|
54
|
+
|
|
55
|
+
return private_class
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
from ._parser import _timelex, _resultbase
|
|
59
|
+
from ._parser import _tzparser, _parsetz
|
|
60
|
+
|
|
61
|
+
_timelex = __deprecate_private_class(_timelex)
|
|
62
|
+
_tzparser = __deprecate_private_class(_tzparser)
|
|
63
|
+
_resultbase = __deprecate_private_class(_resultbase)
|
|
64
|
+
_parsetz = __deprecated_private_func(_parsetz)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Provenance: rustsmith Stage-1 mirror of dateutil/dateutil (Apache-2.0).
|
|
3
|
+
# Original: src/dateutil/parser/_parser.py — the hot path (`_timelex`,
|
|
4
|
+
# default `parserinfo` tables, `_ymd`, `parser._parse`,
|
|
5
|
+
# `_parse_numeric_token`) now runs in the Rust `dateutil-core` crate via
|
|
6
|
+
# `dateutil._dateutil`; this module re-exports that surface.
|
|
7
|
+
#
|
|
8
|
+
# `_parser_py.py` alongside is the verbatim upstream module. It stays for
|
|
9
|
+
# two reasons: (a) lineage — the kept private pieces (`_tzparser`,
|
|
10
|
+
# `_parsetz`, `_resultbase`, `_result`, `_ymd`, `ParserError`,
|
|
11
|
+
# `UnknownTimezoneWarning`) import from there, so a future upstream sync
|
|
12
|
+
# is a plain re-copy plus diff; (b) the `tzstr` engine path
|
|
13
|
+
# (`tz.tzstr -> parser._parsetz`) keeps its exact objects.
|
|
14
|
+
"""
|
|
15
|
+
This module offers a generic date/time string parser which is able to parse
|
|
16
|
+
most known formats to represent a date and/or time.
|
|
17
|
+
|
|
18
|
+
This module attempts to be forgiving with regards to unlikely input formats,
|
|
19
|
+
returning a datetime object even for dates which are ambiguous. If an element
|
|
20
|
+
of a date/time stamp is omitted, the following rules are applied:
|
|
21
|
+
|
|
22
|
+
- If AM or PM is left unspecified, a 24-hour clock is assumed, however, an hour
|
|
23
|
+
on a 12-hour clock (``0 <= hour <= 12``) *must* be specified if AM or PM is
|
|
24
|
+
specified.
|
|
25
|
+
- If a time zone is omitted, a timezone-naive datetime is returned.
|
|
26
|
+
|
|
27
|
+
If any other elements are missing, they are taken from the
|
|
28
|
+
:class:`datetime.datetime` object passed to the parameter ``default``. If this
|
|
29
|
+
results in a day number exceeding the valid number of days per month, the
|
|
30
|
+
value falls back to the end of the month.
|
|
31
|
+
|
|
32
|
+
Additional resources about date/time string formats can be found below:
|
|
33
|
+
|
|
34
|
+
- `A summary of the international standard date and time notation
|
|
35
|
+
<https://www.cl.cam.ac.uk/~mgk25/iso-time.html>`_
|
|
36
|
+
- `W3C Date and Time Formats <https://www.w3.org/TR/NOTE-datetime>`_
|
|
37
|
+
- `Time Formats (Planetary Rings Node) <https://pds-rings.seti.org:443/tools/time_formats.html>`_
|
|
38
|
+
- `CPAN ParseDate module
|
|
39
|
+
<https://metacpan.org/pod/release/MUIR/Time-modules-2013.0912/lib/Time/ParseDate.pm>`_
|
|
40
|
+
- `Java SimpleDateFormat Class
|
|
41
|
+
<https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html>`_
|
|
42
|
+
"""
|
|
43
|
+
from dateutil._dateutil import (
|
|
44
|
+
DEFAULTPARSER,
|
|
45
|
+
_timelex,
|
|
46
|
+
parse,
|
|
47
|
+
parser,
|
|
48
|
+
parserinfo,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
from ._parser_py import (
|
|
52
|
+
DEFAULTTZPARSER,
|
|
53
|
+
ParserError,
|
|
54
|
+
UnknownTimezoneWarning,
|
|
55
|
+
_parsetz,
|
|
56
|
+
_resultbase,
|
|
57
|
+
_tzparser,
|
|
58
|
+
_ymd,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class _result(_resultbase):
|
|
63
|
+
__slots__ = ["year", "month", "day", "weekday",
|
|
64
|
+
"hour", "minute", "second", "microsecond",
|
|
65
|
+
"tzname", "tzoffset", "ampm", "any_unused_tokens"]
|
|
66
|
+
|