
    ,h                     \   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__     M/var/www/html/Resume-Scraper/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   iQ 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! !"-gr*f"8,,V$${1avv..{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                     |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    pAi  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"7D1G\8%%dGQ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     1uQ3wq3wq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))qyUaZC1HD D D%3EGHH"T5#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                     | \  }}}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**qF/?R/?$'4/$6$>>
$PVAW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.     	~bq18<~ab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tQ*
XtR,
&X&&tR4  . 4* 4[ Nk N$[ $* *	[ 	DHNFD H,^[ r   