Ë
    •2Úiþ  ã                   ó\  — d Z ddlZdZed   ed   z
  dk(  sJ ‚ ej                  ddd«      Z ej                  ddd	«      Z ej                  ddd
«      ZdZ G d„ de«      Z G d„ de«      Z	 G d„ de«      Z
 G d„ de«      Z G d„ de«      Z G d„ de«      Zd„ Zd„ Zd„ ZdZd„ Zd„ Zd„ Zy)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

é    N)i«Ù$ iaß$ é   i¶  ip  ik  é   é   é   )i‚$- iÌ- c                   ó   — e Zd ZdZy)ÚXLDateErrorz-A base class for all datetime-related errors.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úB/var/www/html/acx/venv/lib/python3.12/site-packages/xlrd/xldate.pyr   r   #   s   „ Ú3r   r   c                   ó   — e Zd ZdZy)ÚXLDateNegativez``xldate < 0.00``Nr	   r   r   r   r   r   '   s   „ Úr   r   c                   ó   — e Zd ZdZy)ÚXLDateAmbiguouszGThe 1900 leap-year problem ``(datemode == 0 and 1.0 <= xldate < 61.0)``Nr	   r   r   r   r   r   +   s   „ ÚMr   r   c                   ó   — e Zd ZdZy)ÚXLDateTooLargezGregorian year 10000 or laterNr	   r   r   r   r   r   /   s   „ Ú#r   r   c                   ó   — e Zd ZdZy)ÚXLDateBadDatemodez#``datemode`` arg is neither 0 nor 1Nr	   r   r   r   r   r   3   s   „ Ú)r   r   c                   ó   — e Zd Zy)ÚXLDateBadTupleN)r
   r   r   r   r   r   r   r   7   s   „ Ør   r   c                 óf  — |dvrt        |«      ‚| dk(  ry| dk  rt        | «      ‚t        | «      }| |z
  }t        t        |dz  «      «      }d|cxk  rdk  sJ ‚ J ‚|dk(  rdx}x}}|dz  }nt	        |d«      \  }}t	        |d«      \  }}|t
        |   k\  rt        | «      ‚|dk(  rddd|||fS |d	k  r|dk(  rt        | «      ‚|t        |   z   }	|	d
z  dz   dz  dz  d
z  |	z   dz   d
z  dz   }
|
dz  d
z  dz  dz   }|dz  dz  dz   }|dz  }|dk\  r|
dz  dz
  |dz
  ||||fS |
dz  dz
  |dz   ||||fS )aU  
    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.
    ©r   r   ç        )r   r   r   r   r   r   g     õ@r   i€Q r   é<   é=   é   ie/ i±: é   iS  éµ  i  iM  i @  é   é
   ik  é	   él  )	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_tupler9   ;   sº  € ð@ �vÑÜ Ó)Ð)Ø�‚~Ø!Ø�‚}Ü˜VÓ$Ð$Ü�‹[€FØ�F‰?€DÜ”%˜˜w™Ó'Ó(€GØ�Ô ˜5Ò Ð Ñ Ð Ð Ø�%ÒØ!"Ð"ˆÐ"ˆv˜Ø�!‰‰ô ! ¨"Ó-‰ˆ�ä˜g rÓ*‰ˆˆfØÔ" 8Ñ,Ò,Ü˜VÓ$Ð$à�‚{Ø�1�a˜˜v vÐ.Ð.à�‚{�x 1’}Ü˜fÓ%Ð%à
”:˜hÑ'Ñ
'€CØ�Q‰w˜Ñ FÑ*¨aÑ/°1Ñ4¸Ñ;¸dÑBÀaÑGÈ!ÑK€DØ�$‰;˜1Ñ
 Ñ	# cÑ	)€BØ
ˆu‰*˜Ñ	 Ñ!€Aàˆ2�I€BØ	ˆR‚xØ˜‘ Ñ% r¨A¡v¨q°$¸ÀÐGÐGà˜‘ Ñ% r¨A¡v¨q°$¸ÀÐGÐGr   c                 óÚ   — |rt         }n| dk  rt        }nt        }t        | «      }| |z
  }t        t	        |dz  «      «      }t        |d«      \  }}|t        j                  ||d|«      z   S )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.
    r   g    p™”Aiè  r   )Ú
epoch_1904Ú
epoch_1900Úepoch_1900_minus_1r'   r(   r)   ÚdatetimeÚ	timedelta)r,   r-   ÚepochÚdaysÚfractionr0   Úmillisecondss          r   Úxldate_as_datetimerD   ‚   sv   € ñ Ü‰à�BŠ;Ü‰Eô 'ˆEô ˆv‹;€DØ˜‰}€Hô ”%˜ :Ñ-Ó.Ó/€GÜ" 7¨DÓ1Ñ€Gˆ\à”8×%Ñ% d¨G°Q¸ÓEÑEÐEr   c                 ó(   — | dz  ry| dz  ry| dz  ryy)Nr    r   éd   r   i�  r   )Úys    r   Ú_leaprH   ¤   s    € Øˆ1‚u�QØˆ3‚w�qØˆ3‚w�qØr   )Nr   é   r   r   r   r   r   r   r   r   r   r   c                 óL  — | \  }}}|dvrt        |«      ‚|dk(  r|dk(  r|dk(  ryd|cxk  rdk  sn t        d|||f›�«      ‚d|cxk  rdk  sn t        d	|||f›�«      ‚|dk  s!|t        |   kD  r&|d
k(  r|dk(  rt        |«      st        d|||f›�«      ‚|dz   }|}|dk  r|dz
  }|dz   }n|dz
  }d|z  dz  d|z  dz   dz  z   |z   dz
  |dz   dz  dz  dz  z
  }|t        |   z
  }	|	dk  rt        d|||f›�«      ‚|	dk  r|dk(  rt        d|||f›�«      ‚t        |	«      S )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   r   r   il  i'  zInvalid year: r   r   zInvalid month: é   é   zInvalid day: r&   r%   r!   r"   r    iÓ  é   é    iT  é¸   rF   zInvalid (year, month, day): r   zBefore 1900-03-01: )r   r   Ú_days_in_monthrH   r+   r   Úfloat)
Ú
date_tupler-   ÚyearÚmonthÚdayÚYpÚMÚMpr5   r.   s
             r   Úxldate_from_date_tuplerY   ­   sŠ  € ð "Ñ€Dˆ%�à�vÑÜ Ó)Ð)àˆq‚y�U˜a’Z C¨1¢HØà�DÔ ˜DÔ Ý°D¸%ÀÑ3EÐGÓHÐHØ�Ô˜"ÔÝ°T¸5À#Ñ4FÐHÓIÐIØ	ˆqŠØ
”˜uÑ%Ò
%¨c°Rªi¸EÀQºJÌ5ÐQUÌ;Ý°4¸ÀÑ2DÐFÓGÐGà	�‰€BØ€AØˆA‚vØ�!‰VˆØ�‰U‰à�‰UˆØ�"‰9˜‰>˜s R™x¨"™}°Ñ3Ñ
4ØñØñØ˜S™ SÑ(¨AÑ-°Ñ2ñ4€Cà”:˜hÑ'Ñ'€FØ�‚{ÝÀ$ÈÈsÑASÐUÓVÐVØ�‚{�x 1’}Ý¸$ÀÀsÑ9KÐMÓNÐNÜ�‹=Ðr   c                 ó¦   — | \  }}}d|cxk  rdk  r0n n-d|cxk  rdk  r"n nd|cxk  rdk  rn n|dz  |z   dz  |z   dz  S t        d|||f›�«      ‚)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
    r   é   r   g      N@g      8@z Invalid (hour, minute, second): )r   )Ú
time_tupler1   r2   r3   s       r   Úxldate_from_time_tupler]   Ü   sg   € ð &Ñ€Dˆ&�&ØˆD„~�2…~˜!˜vÔ*¨Õ*¨q°FÔ/?¸RÕ/?Ø˜$‘ Ñ'¨4Ñ/°$Ñ6¸$Ñ>Ð>Ý
À$ÈÐPVÑAWÐYÓ
ZÐZr   c                 ó>   — t        | dd |«      t        | dd «      z   S )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.
    Nr!   )rY   r]   )Údatetime_tupler-   s     r   Úxldate_from_datetime_tupler`   ì   s.   € ô 	˜~¨b¨qÐ1°8Ó<Ü˜~¨a¨bÐ1Ó2ñ	3ðr   )r   r>   r+   r;   r<   r=   r*   Ú
ValueErrorr   r   r   r   r   r   r9   rD   rH   rP   rY   r]   r`   r   r   r   ú<module>rb      só   ðñó à(€
Ø�!�}�z !‘}Ñ$¨Ò,Ð ,Ð,ð ˆX×Ñ˜t Q¨Ó*€
ØˆX×Ñ˜t R¨Ó,€
Ø&�X×&Ñ& t¨R°Ó4Ð ð .Ð ô4�*ô 4ô�[ô ôN�kô Nô$�[ô $ô*˜ô *ô	�[ô 	òDHòNFòDð H€ò,ò^[ó r   