
    ViO                        S r SSKrSSKrSSKrSSKrSSKJrJrJrJr  S r	S r
\R                  " S5      rS rS\" SS	9S
4S\" SS	9S4S\" SS	9S4S\" SS9S4S\" SS9S4S\" SS9S4S\" SS9S4/r\ V s/ s H  o S   U S   -  U S   U S   4PM     sn r\ V s/ s H  o S   PM	     sn rSr\R                  " S\-  5      r\" \" \SS 5       VVs/ s H  u    pUS   US-   4PM     snn5      rS r\rS rSBS jrSCS jrS  rSDS! jr\" S5      r\" SS"9r " S# S$\5      r\" S%5      r\R@                  " S\5      r!\RD                  " S5      r# " S& S'\5      r$\$" 5       r%S( r&\" SS)S*S5      r'\" SS+SS5      r(\" SS,SS5      r)\" SS-S.S5      r*\" SS,S/S5      r+\*r, " S0 S1\5      r-\-" S2S3S4S55      r.\-" S6S7S8S95      r/\-" S:S;S<S=5      r0\-" S>S?S@SA5      r1gs  sn f s  sn f s  snnf )Ea  Python's :mod:`datetime` module provides some of the most complex
and powerful primitives in the Python standard library. Time is
nontrivial, but thankfully its support is first-class in
Python. ``dateutils`` provides some additional tools for working with
time.

Additionally, timeutils provides a few basic utilities for working
with timezones in Python. The Python :mod:`datetime` module's
documentation describes how to create a
:class:`~datetime.datetime`-compatible :class:`~datetime.tzinfo`
subtype. It even provides a few examples.

The following module defines usable forms of the timezones in those
docs, as well as a couple other useful ones, :data:`UTC` (aka GMT) and
:data:`LocalTZ` (representing the local timezone as configured in the
operating system). For timezones beyond these, as well as a higher
degree of accuracy in corner cases, check out `pytz`_ and `dateutil`_.

.. _pytz: https://pypi.python.org/pypi/pytz
.. _dateutil: https://dateutil.readthedocs.io/en/stable/index.html
    N)tzinfo	timedeltadatedatetimec                 h    SnU R                   U R                  S-  -   nU R                  X!-  -   nX1-  $ )a=  For those with older versions of Python, a pure-Python
implementation of Python 2.7's :meth:`~datetime.timedelta.total_seconds`.

Args:
    td (datetime.timedelta): The timedelta to convert to seconds.
Returns:
    float: total number of seconds

>>> td = timedelta(days=4, seconds=33)
>>> total_seconds(td)
345633.0
g    .AiQ )secondsdaysmicroseconds)tda_millitd_dstd_micros       d/home/james-whalen/.local/share/pipx/venvs/semgrep/lib/python3.13/site-packages/boltons/timeutils.pytotal_secondsr   >   s8     GJJ"''E/*E%/2H    c                 `    U R                   (       a
  U [        -
  nO	U [        -
  n[        U5      $ )u#  Converts from a :class:`~datetime.datetime` object to an integer
timestamp, suitable interoperation with :func:`time.time` and
other `Epoch-based timestamps`.

.. _Epoch-based timestamps: https://en.wikipedia.org/wiki/Unix_time

>>> abs(round(time.time() - dt_to_timestamp(datetime.utcnow()), 2))
0.0

``dt_to_timestamp`` supports both timezone-aware and naïve
:class:`~datetime.datetime` objects. Note that it assumes naïve
datetime objects are implied UTC, such as those generated with
:meth:`datetime.datetime.utcnow`. If your datetime objects are
local time, such as those generated with
:meth:`datetime.datetime.now`, first convert it using the
:meth:`datetime.datetime.replace` method with ``tzinfo=``
:class:`LocalTZ` object in this module, then pass the result of
that to ``dt_to_timestamp``.
)r   EPOCH_AWAREEPOCH_NAIVEr   )dtr   s     r   dt_to_timestampr   Q   s*    ( 
yy++r   z\Dc                 x    [         R                  U 5       Vs/ s H  n[        U5      PM     nn[        U6 $ s  snf )a  Parses the limited subset of `ISO8601-formatted time`_ strings as
returned by :meth:`datetime.datetime.isoformat`.

>>> epoch_dt = datetime.utcfromtimestamp(0)
>>> iso_str = epoch_dt.isoformat()
>>> print(iso_str)
1970-01-01T00:00:00
>>> isoparse(iso_str)
datetime.datetime(1970, 1, 1, 0, 0)

>>> utcnow = datetime.utcnow()
>>> utcnow == isoparse(utcnow.isoformat())
True

For further datetime parsing, see the `iso8601`_ package for strict
ISO parsing and `dateutil`_ package for loose parsing and more.

.. _ISO8601-formatted time: https://en.wikipedia.org/wiki/ISO_8601
.. _iso8601: https://pypi.python.org/pypi/iso8601
.. _dateutil: https://pypi.python.org/pypi/python-dateutil

)_NONDIGIT_REsplitintr   )iso_strpdt_argss      r   isoparser   o   s9    .  ,11':;:!s1v:G;W <s   7   r   second<   minute  hourr	   day   week      monthim  yearz*[+-]?\ *(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?z!((?P<value>%s)\s*(?P<unit>\w)\w*)sc           	      r   0 n[         R                  U 5       H>  nUR                  S5      UR                  S5      pC [        U   n [        U5      nX1U'   M@     [        S0 UD6$ ! [         a&    [        SU< S[        R                  5       < 35      ef = f! [
         a    [        SU< SU< 35      ef = f)a>  Robustly parses a short text description of a time period into a
:class:`datetime.timedelta`. Supports weeks, days, hours, minutes,
and seconds, with or without decimal points:

Args:
    text (str): Text to parse.
Returns:
    datetime.timedelta
Raises:
    ValueError: on parse failure.

>>> parse_td('1d 2h 3.5m 0s') == timedelta(days=1, seconds=7410)
True

Also supports full words and whitespace.

>>> parse_td('2 weeks 1 day') == timedelta(days=15)
True

Negative times are supported, too:

>>> parse_td('-1.5 weeks 3m 20s') == timedelta(days=-11, seconds=43400)
True
valueunitzinvalid time unit z, expected one of zinvalid time value for unit z:  )	_PARSE_TD_REfinditergroup_PARSE_TD_KW_MAPKeyError
ValueErrorkeysfloatr   )text	td_kwargsmatchr1   r2   unit_keys         r   parse_timedeltar@      s    2 I&&t,kk'*EKK,?t	@'-H	.%LE $( - !y!!  	@ $&6&;&;&=? @ @	@
  	. $e- . .	.s   	A%B%0BB6c                     US:X  a  U $ U S-   $ )Nr   r/   r3   )r2   r1   s     r   _cardinalize_time_unitrB      s     z#:r   c                 .   Uc  [         R                  " 5       nX-
  n[        U5      n[        U5      n[        R                  " [
        U5      S-
  n[        U   u  pn
U[        U	5      -  n[        X5      nU(       a  U[        U
[        U5      5      4$ X4$ )az  Get a tuple representing the relative time difference between two
:class:`~datetime.datetime` objects or one
:class:`~datetime.datetime` and now.

Args:
    d (datetime): The first datetime object.
    other (datetime): An optional second datetime object. If
        unset, defaults to the current time as determined
        :meth:`datetime.utcnow`.
    ndigits (int): The number of decimal digits to round to,
        defaults to ``0``.
    cardinalize (bool): Whether to pluralize the time unit if
        appropriate, defaults to ``True``.
Returns:
    (float, str): A tuple of the :class:`float` difference and
       respective unit of time, pluralized if appropriate and
       *cardinalize* is set to ``True``.

Unlike :func:`relative_time`, this method's return is amenable to
localization into other languages and custom phrasing and
formatting.

>>> now = datetime.utcnow()
>>> decimal_relative_time(now - timedelta(days=1, seconds=3600), now)
(1.0, 'day')
>>> decimal_relative_time(now - timedelta(seconds=0.002), now, ndigits=5)
(0.002, 'seconds')
>>> decimal_relative_time(now, now - timedelta(days=900), ndigits=1)
(-2.5, 'years')

r   )	r   utcnowr   absbisect_BOUND_DELTAS_BOUNDSroundrB   )dotherndigitscardinalizediffdiff_secondsabs_diffb_idxbboundbunitbnamef_diffrounded_diffs                r   decimal_relative_timerW      s    @ }!9D &L4yHMM-2Q6E"5>F5M%00F)L3E3|;LMMMr   c                 P    [        XUSS9u  p4SnUS:  a  SnS[        U5      XE4-  $ )a  Get a string representation of the difference between two
:class:`~datetime.datetime` objects or one
:class:`~datetime.datetime` and the current time. Handles past and
future times.

Args:
    d (datetime): The first datetime object.
    other (datetime): An optional second datetime object. If
        unset, defaults to the current time as determined
        :meth:`datetime.utcnow`.
    ndigits (int): The number of decimal digits to round to,
        defaults to ``0``.
Returns:
    A short English-language string.

>>> now = datetime.utcnow()
>>> relative_time(now, ndigits=1)
'0 seconds ago'
>>> relative_time(now - timedelta(days=1, seconds=36000), ndigits=1)
'1.4 days ago'
>>> relative_time(now + timedelta(days=7), now, ndigits=1)
'1 week from now'

T)rM   agor   zfrom nowz%g %s %s)rW   rE   )rJ   rK   rL   drtr2   phrases         r   relative_timer\      s9    2 &aTJICF
QwS4000r   c                 N    [         R                  " X5      nUR                  5       $ )a)  Parse the date string according to the format in `format`.  Returns a
:class:`date` object.  Internally, :meth:`datetime.strptime` is used to
parse the string and thus conversion specifiers for time fields (e.g. `%H`)
may be provided;  these will be parsed but ignored.

Args:
    string (str): The date string to be parsed.
    format (str): The `strptime`_-style date format string.
Returns:
    datetime.date

.. _`strptime`: https://docs.python.org/2/library/datetime.html#strftime-strptime-behavior

>>> strpdate('2016-02-14', '%Y-%m-%d')
datetime.date(2016, 2, 14)
>>> strpdate('26/12 (2015)', '%d/%m (%Y)')
datetime.date(2015, 12, 26)
>>> strpdate('20151231 23:59:59', '%Y%m%d %H:%M:%S')
datetime.date(2015, 12, 31)
>>> strpdate('20160101 00:00:00.001', '%Y%m%d %H:%M:%S.%f')
datetime.date(2016, 1, 1)
)r   strptimer   )stringformatwhences      r   strpdaterb     s     . v.F;;=r   c              #   :  #    [        U [        5      (       d  [        S5      eU(       a   [        U[        5      (       d  [        S5      e Uu  pEn[        U5      [        U5      pT[        U[        5      (       a  [	        [        U5      S9nO$[        U[        5      (       a  O[        SU-  5      eUc  S nOTX:  a(  U(       a  [        R                  O[        R                  nO'U(       a  [        R                  O[        R                  nU nU" X5      (       di  Uv   U(       d  U(       aD  [        UR                  U-   S5      u  pUR                  UR                  U-   U	-   U
=(       d    SS	9nX-   nU" X5      (       d  Mi  g! [         a	    SSUpen GN2f = f7f)
aT  In the spirit of :func:`range` and :func:`xrange`, the `daterange`
generator that yields a sequence of :class:`~datetime.date`
objects, starting at *start*, incrementing by *step*, until *stop*
is reached.

When *inclusive* is True, the final date may be *stop*, **if**
*step* falls evenly on it. By default, *step* is one day. See
details below for many more details.

Args:
    start (datetime.date): The starting date The first value in
        the sequence.
    stop (datetime.date): The stopping date. By default not
        included in return. Can be `None` to yield an infinite
        sequence.
    step (int): The value to increment *start* by to reach
        *stop*. Can be an :class:`int` number of days, a
        :class:`datetime.timedelta`, or a :class:`tuple` of integers,
        `(year, month, day)`. Positive and negative *step* values
        are supported.
    inclusive (bool): Whether or not the *stop* date can be
        returned. *stop* is only returned when a *step* falls evenly
        on it.

>>> christmas = date(year=2015, month=12, day=25)
>>> boxing_day = date(year=2015, month=12, day=26)
>>> new_year = date(year=2016, month=1,  day=1)
>>> for day in daterange(christmas, new_year):
...     print(repr(day))
datetime.date(2015, 12, 25)
datetime.date(2015, 12, 26)
datetime.date(2015, 12, 27)
datetime.date(2015, 12, 28)
datetime.date(2015, 12, 29)
datetime.date(2015, 12, 30)
datetime.date(2015, 12, 31)
>>> for day in daterange(christmas, boxing_day):
...     print(repr(day))
datetime.date(2015, 12, 25)
>>> for day in daterange(date(2017, 5, 1), date(2017, 8, 1),
...                      step=(0, 1, 0), inclusive=True):
...     print(repr(day))
datetime.date(2017, 5, 1)
datetime.date(2017, 6, 1)
datetime.date(2017, 7, 1)
datetime.date(2017, 8, 1)

*Be careful when using stop=None, as this will yield an infinite
sequence of dates.*
z%start expected datetime.date instancez,stop expected datetime.date instance or Noner   r&   zBstep expected int, timedelta, or tuple (year, month, day), not: %rNc                     g)NFr3   )nowstops     r   <lambda>daterange.<locals>.<lambda>~  s    Ur      )r-   r,   )
isinstancer   	TypeErrorr   r   r9   operatorgtgeltledivmodr,   replacer-   )startrf   step	inclusivey_stepm_stepd_stepfinishedre   m_y_step	cur_months              r   	dateranger|   8  sh    f eT""?@@JtT**FGG2!% Vc&k&#F,	FI	&	& 8:>? @ 	@ |*	"+8;;"+8;;
Cs!!	V"(V);R"@H++388f#4x#?$-O  5Cl s!! 7  ,!"At,s1   AFF D2FFFFFFhoursc                   N    \ rS rSrSrS\4S jr\S 5       rS r	S r
S rS	 rS
rg)ConstantTZInfoi  z
A :class:`~datetime.tzinfo` subtype whose *offset* remains constant
(no daylight savings).

Args:
    name (str): Name of the timezone.
    offset (datetime.timedelta): Offset of the timezone.

ConstantTZc                     Xl         X l        g Nnameoffset)selfr   r   s      r   __init__ConstantTZInfo.__init__  s    	r   c                 2    [        U R                  5      S-  $ )Nr$   )r   r   r   s    r   utcoffset_hoursConstantTZInfo.utcoffset_hours  s    T[[)W55r   c                     U R                   $ r   )r   r   r   s     r   	utcoffsetConstantTZInfo.utcoffset  s    {{r   c                     U R                   $ r   )r   r   s     r   tznameConstantTZInfo.tzname  s    yyr   c                     [         $ r   )ZEROr   s     r   dstConstantTZInfo.dst  s    r   c                 r    U R                   R                  nU< SU R                  < SU R                  < S3$ )Nz(name=z	, offset=))	__class____name__r   r   )r   cns     r   __repr__ConstantTZInfo.__repr__  s&    ^^$$+-tyy$++FFr   r   N)r   
__module____qualname____firstlineno____doc__r   r   propertyr   r   r   r   r   __static_attributes__r3   r   r   r   r     s<     )  6 6Gr   r   UTCc                       \ rS rSrSr\" \R                  * S9r\r	\R                  (       a  \" \R                  * S9r	S rS rS rS rS rS	rg
)LocalTZInfoi  a#  The ``LocalTZInfo`` type takes data available in the time module
about the local timezone and makes a practical
:class:`datetime.tzinfo` to represent the timezone settings of the
operating system.

For a more in-depth integration with the operating system, check
out `tzlocal`_. It builds on `pytz`_ and implements heuristics for
many versions of major operating systems to provide the official
``pytz`` tzinfo, instead of the LocalTZ generalization.

.. _tzlocal: https://pypi.python.org/pypi/tzlocal
.. _pytz: https://pypi.python.org/pypi/pytz

r    c           	         UR                   UR                  UR                  UR                  UR                  UR
                  UR                  5       SS4	n[        R                  " [        R                  " U5      5      nUR                  S:  $ )Nr   )r-   r,   r'   r%   r#   r!   weekdaytime	localtimemktimetm_isdst)r   r   dt_tlocal_ts       r   is_dstLocalTZInfo.is_dst  sc    266277BII		2::<B0..T!23!##r   c                 ^    U R                  U5      (       a  U R                  $ U R                  $ r   )r   _dst_offset_std_offsetr   s     r   r   LocalTZInfo.utcoffset  s'    ;;r??###r   c                 l    U R                  U5      (       a  U R                  U R                  -
  $ [        $ r   )r   r   r   r   r   s     r   r   LocalTZInfo.dst  s+    ;;r??##d&6&666r   c                 F    [         R                  U R                  U5         $ r   )r   r   r   r   s     r   r   LocalTZInfo.tzname  s    {{4;;r?++r   c                 4    SU R                   R                  -  $ )Nz%s())r   r   r   s    r   r   LocalTZInfo.__repr__  s    ////r   r3   N)r   r   r   r   r   r   r   timezoner   r   daylightaltzoner   r   r   r   r   r   r3   r   r   r   r     sN     T]]N3KK}}6$ 

,0r   r   c                 V    SU R                  5       -
  nU(       a  U [        U5      -  n U $ )N   )r   r   )r   
days_to_gos     r   _first_sunday_on_or_afterr     s)    RZZ\!J
i
##Ir               
         c                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)

USTimeZonei	  zCopied directly from the Python docs, the ``USTimeZone`` is a
:class:`datetime.tzinfo` subtype used to create the
:data:`Eastern`, :data:`Central`, :data:`Mountain`, and
:data:`Pacific` tzinfo types.
c                 D    [        US9U l        X l        X0l        X@l        g )Nr}   )r   	stdoffsetreprnamestdnamedstname)r   r~   r   r   r   s        r   r   USTimeZone.__init__  s    "/ r   c                     U R                   $ r   )r   r   s    r   r   USTimeZone.__repr__  s    }}r   c                 ^    U R                  U5      (       a  U R                  $ U R                  $ r   )r   r   r   r   s     r   r   USTimeZone.tzname  s#    88B<<<<<<r   c                 >    U R                   U R                  U5      -   $ r   )r   r   r   s     r   r   USTimeZone.utcoffset  s    ~~,,r   c                    Ub  UR                   c  [        $ UR                   U L d   eSUR                  :  a  [        [        p2OWSUR                  s=:  a  S:  a  O  O[
        [        p2O1SUR                  s=:  a  S:  a  O  [        $ [        [        p2O[        $ [        UR                  UR                  S95      n[        UR                  UR                  S95      nXAR                  S S9s=::  a  U:  a   [        $   [        $ [        $ )Ni  i  i  i  i  )r-   )r   )r   r   r-   DSTSTART_2007DSTEND_2007DSTSTART_1987_2006DSTEND_1987_2006DSTSTART_1967_1986DSTEND_1967_1986r   rr   HOUR)r   r   dststartdstendrs   ends         r   r   USTimeZone.dst!  s    :*
 KyyD    "''>,kfBGG"d"13CfBGG"d" K  23CfK)(*:*:*:*HI'BGG(DE JJdJ+1c1K 2 K4Kr   )r   r   r   r   N)r   r   r   r   r   r   r   r   r   r   r   r3   r   r   r   r   	  s     
 -r   r   EasternESTEDTiCentralCSTCDTiMountainMSTMDTiPacificPSTPDT)Nr   T)Nr   )r   F)2r   rer   rF   rl   r   r   r   r   r   r   compiler   r   rH   rG   _FLOAT_PATTERNr4   dictreversedr7   r@   parse_tdrB   rW   r\   rb   r|   r   r   r   r   fromtimestampr   utcfromtimestampr   r   LocalTZr   r   r   r   r   r   r   r   r   r   r   r   )b_r2   s   000r   <module>r      s  B, 
    6 6&6 zz% 6 y#X.y$h/y&/ya %(ya &)yb!7+yc"F+- /6
6gaD1Q4K1qt$g
6&'w!1w'>zz>OP+3GCRL+AC+AZQ q'4#:.+AC D '"T +\1@6Tt |qGV G> U$$Q,''*(0& (0V -" Aq!$q"a# aAq) Ar2q) 
 aB* # 4 4n RUE
2
RUE
2b*eU3
RUE
2e 7'Cs   8GGG#
