+
    i                     z   R t ^ RItRt]^,          ]^ ,          ,
          R8X  g   Q h]P                  ! R^^4      t]P                  ! R^^4      t]P                  ! R^^4      tRt ! R R]4      t ! R R]4      t	 ! R	 R
]4      t
 ! R R]4      t ! R R]4      t ! R R]4      tR tR tR tRtR tR tR tR# )a  
Tools for working with dates and times in Excel files.

The conversion from ``days`` to ``(year, month, day)`` starts with
an integral "julian day number" aka JDN.
FWIW:

- JDN 0 corresponds to noon on Monday November 24 in Gregorian year -4713.

More importantly:

- Noon on Gregorian 1900-03-01 (day 61 in the 1900-based system) is JDN 2415080.0
- Noon on Gregorian 1904-01-02 (day  1 in the 1904-based system) is JDN 2416482.0

Ni  ip  ik  c                       ] tR t^#tRtRtR# )XLDateErrorz-A base class for all datetime-related errors. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       T/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/xlrd/xldate.pyr   r   #   s    3r   r   c                       ] tR t^'tRtRtR# )XLDateNegativez``xldate < 0.00``r   Nr   r   r   r   r   r   '   s    r   r   c                       ] tR t^+tRtRtR# )XLDateAmbiguouszGThe 1900 leap-year problem ``(datemode == 0 and 1.0 <= xldate < 61.0)``r   Nr   r   r   r   r   r   +   s    Mr   r   c                       ] tR t^/tRtRtR# )XLDateTooLargezGregorian year 10000 or laterr   Nr   r   r   r   r   r   /   s    #r   r   c                       ] tR t^3tRtRtR# )XLDateBadDatemodez#``datemode`` arg is neither 0 nor 1r   Nr   r   r   r   r   r   3   s    )r   r   c                       ] tR t^7tRtR# )XLDateBadTupler   N)r   r   r   r	   r   r   r   r   r   r   7   s    r   r   c                l   VR9  d   \        V4      hV R8X  d   R# V R8  d   \        V 4      h\        V 4      pW,
          p\        \        VR,          4      4      p^ Tu;8:  d	   R8:  g   Q h Q hVR8X  d   ^ ;p;rgV^,          pM\	        V^<4      w  r\	        V^<4      w  rVV\
        V,          8  d   \        V 4      hV^ 8X  d   ^ ^ ^ WVV3# V^=8  d   V^ 8X  d   \        V 4      hV\        V,          ,           p	V	^,          R,           R,          ^,          ^,          V	,           R,           ^,          ^,           p
V
R,          ^,          R,          R	,           pVR
,          R,          ^,           pV^,          pV^
8  d   V
R,          R,
          V^	,
          WWg3# V
R,          R,
          V^,           WWg3# )a  
Convert an Excel number (presumed to represent a date, a datetime or a time) into
a tuple suitable for feeding to datetime or mx.DateTime constructors.

:param xldate: The Excel number
:param datemode: 0: 1900-based, 1: 1904-based.
:raises xlrd.xldate.XLDateNegative:
:raises xlrd.xldate.XLDateAmbiguous:

:raises xlrd.xldate.XLDateTooLarge:
:raises xlrd.xldate.XLDateBadDatemode:
:raises xlrd.xldate.XLDateError:
:returns: Gregorian ``(year, month, day, hour, minute, nearest_second)``.

.. warning::

  When using this function to interpret the contents of a workbook, you
  should pass in the :attr:`~xlrd.book.Book.datemode`
  attribute of that workbook. Whether the workbook has ever been anywhere
  near a Macintosh is irrelevant.

.. admonition:: Special case

    If ``0.0 <= xldate < 1.0``, it is assumed to represent a time;
    ``(0, 0, 0, hour, minute, second)`` will be returned.

.. note::

    ``1904-01-01`` is not regarded as a valid date in the ``datemode==1``
    system; its "serial number" is zero.
        g     @iQ ie/ i: iS    i  iM  i @  ik  l         )r   r   r   r   r   r   )	r   r   introunddivmod_XLDAYS_TOO_LARGEr   r   
_JDN_delta)xldatedatemodexldaysfracsecondshourminutesecondminutesjdnyregmpds   &&           r   xldate_as_tupler1   ;   s   @ v))~!!}V$$[F?D%w'(G 5     %!"""v! !"-gr*"8,,V$${1av..{x1}f%%
:h'
'CQwF*a/14;dBaG!KD$;1
	#c	)B
u*	!A2IB	Rx%rAvqGG%rAvqGGr   c                    V'       d   \         pMV ^<8  d   \        pM\        p\        V 4      pW,
          p\        \	        VR,          4      4      p\        VR4      w  rVV\        P                  ! W5^ V4      ,           # )z
Convert an Excel date/time number into a :class:`datetime.datetime` object.

:param xldate: The Excel number
:param datemode: 0: 1900-based, 1: 1904-based.

:returns: A :class:`datetime.datetime` object.
g    pAi  )
epoch_1904
epoch_1900epoch_1900_minus_1r   r    r!   datetime	timedelta)r$   r%   epochdaysfractionr(   millisecondss   &&     r   xldate_as_datetimer<      sp     B;E 'E v;D}H %:-./G"7D1G8%%dQEEEr   c                 l    V ^,          '       d   ^ # V ^d,          '       d   ^# V R,          '       d   ^ # ^# )   i  r   )ys   &r   _leapr@      s&    1uuQ3wwq3wwqr   c                :   V w  r#pVR9  d   \        V4      hV^ 8X  d   V^ 8X  d
   V^ 8X  d   R# RTu;8:  d   R8:  g   M \        RW#V3: 24      h^Tu;8:  d   ^8:  g   M \        RW#V3: 24      hV^8  g2   V\        V,          8  d1   V^8X  d   V^8X  d   \        V4      '       g   \        RW#V3: 24      hVR,           pTpV^8:  d   V^,
          pV^	,           pM	V^,
          pRV,          ^,          R	V,          ^,           ^ ,          ,           V,           R
,
          V^,           ^d,          ^,          ^,          ,
          pV\        V,          ,
          p	V	^ 8:  d   \        RW#V3: 24      hV	^=8  d   V^ 8X  d   \        RW#V3: 24      h\        V	4      # )a  
Convert a date tuple (year, month, day) to an Excel date.

:param year: Gregorian year.
:param month: ``1 <= month <= 12``
:param day: ``1 <= day <= last day of that (year, month)``
:param datemode: 0: 1900-based, 1: 1904-based.
:raises xlrd.xldate.XLDateAmbiguous:
:raises xlrd.xldate.XLDateBadDatemode:
:raises xlrd.xldate.XLDateBadTuple:
  ``(year, month, day)`` is too early/late or has invalid component(s)
:raises xlrd.xldate.XLDateError:
r   il  i'  zInvalid year: zInvalid month: zInvalid day: r   r   i  iT  zInvalid (year, month, day): zBefore 1900-03-01: r   )r   r   _days_in_monthr@   r#   r   float)

date_tupler%   yearmonthdayYpMMpr-   r&   s
   &&        r   xldate_from_date_tuplerK      s    "Dv))qyUaZC1HD D D3EGHH"T#4FHII	q
u%
%cRiEQJ5QU;;42DFGG	BAAv!VUU"9>sRx"}3
4SS(A-24C:h''F{$sASUVV{x1}$s9KMNN=r   c                    V w  rp^ Tu;8:  d   ^8  dM   M MI^ Tu;8:  d   ^<8  d;   M M7^ Tu;8:  d   ^<8  d)   M M%VR,          V,           R,          V,           R,          # \        RWV3: 24      h)a  
Convert a time tuple ``(hour, minute, second)`` to an Excel "date" value
(fraction of a day).

:param hour: ``0 <= hour < 24``
:param minute: ``0 <= minute < 60``
:param second: ``0 <= second < 60``
:raises xlrd.xldate.XLDateBadTuple: Out-of-range hour, minute, or second
g      N@g      8@z Invalid (hour, minute, second): )r   )
time_tupler)   r*   r+   s   &   r   xldate_from_time_tuplerN      sc     &D&D~2~!v**qF/?R/?$'4/$6$>>
$PVAWY
ZZr   c                V    \        V R,          V4      \        V R,          4      ,           # )a  
Convert a datetime tuple ``(year, month, day, hour, minute, second)`` to an
Excel date value.
For more details, refer to other xldate_from_*_tuple functions.

:param datetime_tuple: ``(year, month, day, hour, minute, second)``
:param datemode: 0: 1900-based, 1: 1904-based.
:N   N:rP   NN)rK   rN   )datetime_tupler%   s   &&r   xldate_from_datetime_tuplerR      s*     	~b18<~b12	3r   )i$ ia$ )i$- i- )N      rS      rS   rU   rS   rS   rU   rS   rU   rS   )r
   r6   r#   r3   r4   r5   r"   
ValueErrorr   r   r   r   r   r   r1   r<   r@   rB   rK   rN   rR   r   r   r   <module>rW      s    (
!}z!}$, ,, tQ*
tR,
&&tR4  . 4* 4[ Nk N$[ $* *	[ 	DHNFD H,^[ r   