Ë
    çlÖi +  ã                   óD   — d Z ddlmZ ddlmZmZ d„ Zd„ Z G d„ d«      Zy)	z¨
This module defines a Duration class.

The class Duration allows to define durations in years and months and can be
used as limited replacement for timedelta objects.
é    )Ú	timedelta)ÚROUND_FLOORÚDecimalc                 óz   — | |z
  ||z
  }}||z  j                  t        «      }|||z  z
  }||z  }t        |«      |fS )z-
    A divmod function with boundaries.

    )Úto_integralr   Úint)ÚvalÚlowÚhighÚaÚbÚdivÚmods          úU/var/www/html/strategist-ai/venv_dbt/lib/python3.12/site-packages/isodate/duration.pyÚfquotmodr      sO   € ð �‰9�d˜S‘j€q€AØˆq‰5×
Ñ
œkÓ
*€CØ
ˆc�A‰g‰+€Cð ˆ3�J€CÜˆs‹8�Sˆ=Ðó    c                 óJ   — |dv ry|dv ry| dz  dk(  s| dz  dk7  r	| dz  dk(  ry	y
)zO
    Determines the number of days of a specific month in a specific year.
    )é   é   é   é   é   é
   é   é   )é   é   é	   é   é   i�  r   éd   r   é   é   © )ÚyearÚmonths     r   Úmax_days_in_monthr'      sB   € ð Ð'Ñ'ØØ�ÑØØ	�‰˜Ò  s¡
¨qÒ0¸¸q¹ÀQ²ØØr   c                   óˆ   — e Zd ZdZ	 	 	 	 	 	 	 	 	 dd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ ZeZd„ ZeZd„ Zd„ Zd„ Zd„ Zdd„Zy)ÚDurationaY  
    A class which represents a duration.

    The difference to datetime.timedelta is, that this class handles also
    differences given in years and months.
    A Duration treats differences given in year, months separately from all
    other components.

    A Duration can be used almost like any timedelta object, however there
    are some restrictions:
      * It is not really possible to compare Durations, because it is unclear,
        whether a duration of 1 year is bigger than 365 days or not.
      * Equality is only tested between the two (year, month vs. timedelta)
        basic components.

    A Duration can also be converted into a datetime object, but this requires
    a start date or an end date.

    The algorithm to add a duration to a date is defined at
    http://www.w3.org/TR/xmlschema-2/#adding-durations-to-dateTimes
    c
           	      óÜ   — t        |t        «      st        t        |«      «      }t        |	t        «      st        t        |	«      «      }	|| _        |	| _        t        |||||||«      | _        y)zN
        Initialise this Duration instance with the given parameters.
        N)Ú
isinstancer   ÚstrÚmonthsÚyearsr   Útdelta)
ÚselfÚdaysÚsecondsÚmicrosecondsÚmillisecondsÚminutesÚhoursÚweeksr-   r.   s
             r   Ú__init__zDuration.__init__A   s]   € ô ˜&¤'Ô*ÜœS ›[Ó)ˆFÜ˜%¤Ô)ÜœC ›JÓ'ˆEØˆŒØˆŒ
ÜØ�'˜<¨°wÀÀuó
ˆ�r   c                 ó   — | j                   S ©N)Ú__dict__©r0   s    r   Ú__getstate__zDuration.__getstate__Z   s   € Ø�}‰}Ðr   c                 ó:   — | j                   j                  |«       y r:   )r;   Úupdate)r0   Ústates     r   Ú__setstate__zDuration.__setstate__]   s   € Ø�‰×Ñ˜UÕ#r   c                 ó.   — t        | j                  |«      S )zU
        Provide direct access to attributes of included timedelta instance.
        )Úgetattrr/   )r0   Únames     r   Ú__getattr__zDuration.__getattr__`   s   € ô �t—{‘{ DÓ)Ð)r   c                 ó>  — g }| j                   r|j                  d| j                   z  «       | j                  r1d}| j                  dk  rd}|j                  || j                  z  «       |j                  t        | j                  «      «       dj                  |«      S )zW
        Return a string representation of this duration similar to timedelta.
        z%d yearsz	%d monthsr   z%d monthz, )r.   Úappendr-   r,   r/   Újoin)r0   ÚparamsÚfmts      r   Ú__str__zDuration.__str__f   s{   € ð ˆØ�:Š:Ø�M‰M˜* t§z¡zÑ1Ô2Ø�;Š;ØˆCØ�{‰{˜aÒØ �Ø�M‰M˜# §¡Ñ+Ô,Ø�‰”c˜$Ÿ+™+Ó&Ô'Ø�y‰y˜Ó Ð r   c                 ó
  — d| j                   j                  | j                   j                  | j                  j                  | j                  j
                  | j                  j                  | j                  | j                  fz  S )z=
        Return a string suitable for repr(x) calls.
        z&%s.%s(%d, %d, %d, years=%d, months=%d))	Ú	__class__Ú
__module__Ú__name__r/   r1   r2   r3   r.   r-   r<   s    r   Ú__repr__zDuration.__repr__u   se   € ð 8Ø�N‰N×%Ñ%Ø�N‰N×#Ñ#Ø�K‰K×ÑØ�K‰K×ÑØ�K‰K×$Ñ$Ø�J‰JØ�K‰Kð;
ñ 
ð 	
r   c                 óZ   — t        | j                  | j                  | j                  f«      S )zp
        Return a hash of this instance so that it can be used in, for
        example, dicts and sets.
        )Úhashr/   r-   r.   r<   s    r   Ú__hash__zDuration.__hash__ƒ   s"   € ô
 �T—[‘[ $§+¡+¨t¯z©zÐ:Ó;Ð;r   c                 óp   — t        | j                   | j                   ¬«      }| j                   |_        |S )zg
        A simple unary minus.

        Returns a new Duration instance with all it's negated.
        ©r.   r-   )r)   r.   r-   r/   )r0   Únegdurations     r   Ú__neg__zDuration.__neg__Š   s0   € ô  d§j¡j [¸$¿+¹+¸ÔFˆØ"Ÿk™k˜\ˆÔØÐr   c                 óŒ  — t        |t        «      r[t        | j                  |j                  z   | j                  |j                  z   ¬«      }| j                  |j                  z   |_        |S 	 t        | j                  «      j                  «       r#t        | j                  «      j                  «       st        d«      ‚|j                  | j                  z   }t        |dd«      \  }}|j                  | j                  z   |z   }t        ||«      }|j                  |kD  r|}n|j                  }|j                  t        |«      t        |«      t        |«      ¬«      }| j                  |z   S # t        $ r Y nw xY w	 t        | j                  | j                  ¬«      }| j                  |z   |_        |S # t        $ r Y t         S w xY w)ze
        Durations can be added with Duration, timedelta, date and datetime
        objects.
        rU   ú>fractional years or months not supported for date calculationsr   é   ©r%   r&   Úday)r+   r)   r.   r-   r/   ÚfloatÚ
is_integerÚ
ValueErrorr&   r   r%   r'   r\   Úreplacer   ÚAttributeErrorÚNotImplemented)	r0   ÚotherÚnewdurationÚnewmonthÚcarryÚnewyearÚmaxdaysÚnewdayÚnewdts	            r   Ú__add__zDuration.__add__”   sŠ  € ô
 �eœXÔ&Ü"Ø—j‘j 5§;¡;Ñ.°t·{±{ÀUÇ\Á\Ñ7QôˆKð "&§¡¨u¯|©|Ñ!;ˆKÔØÐð	ô ˜$Ÿ*™*Ó%×0Ñ0Ô2´u¸T¿[¹[Ó7I×7TÑ7TÔ7VÜ ØWóð ð —{‘{ T§[¡[Ñ0ˆHÜ& x°°BÓ7‰OˆE�8Ø—j‘j 4§:¡:Ñ-°Ñ5ˆGÜ'¨°Ó:ˆGØ�y‰y˜7Ò"Ø ‘àŸ™�Ø—M‘MÜ˜“\¬¨X«¼CÀ»Kð "ó ˆEð —;‘; Ñ&Ð&øÜò 	áð	úð	ô #¨¯©¸D¿K¹KÔHˆKØ!%§¡¨uÑ!4ˆKÔØÐøÜò 	àäÐð		ús%   Á-C=E+ Å+	E7Å6E7Å;6F2 Æ2	GÇGc                 ó¨   — t        |t        «      r=t        | j                  |z  | j                  |z  ¬«      }| j
                  |z  |_        |S t        S )NrU   )r+   r   r)   r.   r-   r/   rb   ©r0   rc   rd   s      r   Ú__mul__zDuration.__mul__Å   sH   € Ü�eœSÔ!Ü"¨¯©°eÑ);ÀDÇKÁKÐRWÑDWÔXˆKØ!%§¡¨uÑ!4ˆKÔØÐÜÐr   c                 óp  — t        |t        «      r[t        | j                  |j                  z
  | j                  |j                  z
  ¬«      }| j                  |j                  z
  |_        |S 	 t        | j                  | j                  ¬«      }| j                  |z
  |_        |S # t
        $ r Y t        S w xY w)zj
        It is possible to subtract Duration and timedelta objects from Duration
        objects.
        rU   )r+   r)   r.   r-   r/   Ú	TypeErrorrb   rm   s      r   Ú__sub__zDuration.__sub__Î   sœ   € ô
 �eœXÔ&Ü"Ø—j‘j 5§;¡;Ñ.°t·{±{ÀUÇ\Á\Ñ7QôˆKð "&§¡¨u¯|©|Ñ!;ˆKÔØÐð	ä"¨¯©¸D¿K¹KÔHˆKØ!%§¡¨uÑ!4ˆKÔØÐøÜò 	àÜÐð	ús   Á-6B$ Â$	B5Â4B5c                 ót  — t        |t        «      rt        «       }||_        || z
  S 	 t	        | j
                  «      j                  «       r#t	        | j                  «      j                  «       st        d«      ‚|j                  | j                  z
  }t        |dd«      \  }}|j                  | j
                  z
  |z   }t        ||«      }|j                  |kD  r|}n|j                  }|j                  t        |«      t        |«      t        |«      ¬«      }|| j                  z
  S # t         $ r Y t"        S w xY w)a@  
        It is possible to subtract Duration objects from date, datetime and
        timedelta objects.

        TODO: there is some weird behaviour in date - timedelta ...
              if timedelta has seconds or microseconds set, then
              date - timedelta != date + (-timedelta)
              for now we follow this behaviour to avoid surprises when mixing
              timedeltas with Durations, but in case this ever changes in
              the stdlib we can just do:
                return -self + other
              instead of all the current code
        rY   r   rZ   r[   )r+   r   r)   r/   r]   r.   r^   r-   r_   r&   r   r%   r'   r\   r`   r   ra   rb   )	r0   rc   Útmpdurre   rf   rg   rh   ri   rj   s	            r   Ú__rsub__zDuration.__rsub__ã   s  € ô �eœYÔ'Ü“ZˆFØ!ˆFŒMØ˜D‘=Ð ð	ô ˜$Ÿ*™*Ó%×0Ñ0Ô2´u¸T¿[¹[Ó7I×7TÑ7TÔ7VÜ ØWóð ð —{‘{ T§[¡[Ñ0ˆHÜ& x°°BÓ7‰OˆE�8Ø—j‘j 4§:¡:Ñ-°Ñ5ˆGÜ'¨°Ó:ˆGØ�y‰y˜7Ò"Ø ‘àŸ™�Ø—M‘MÜ˜“\¬¨X«¼CÀ»Kð "ó ˆEð ˜4Ÿ;™;Ñ&Ð&øÜò 	àÜÐð	ús   ¨C=D& Ä&	D7Ä6D7c                 ó&  — t        |t        «      rT| j                  dz  | j                  z   |j                  dz  |j                  z   k(  r| j                  |j                  k(  ryy| j                  dk(  r| j                  dk(  r| j                  |k(  S y)z†
        If the years, month part and the timedelta part are both equal, then
        the two Durations are considered equal.
        r   TFr   ©r+   r)   r.   r-   r/   ©r0   rc   s     r   Ú__eq__zDuration.__eq__  s|   € ô
 �eœXÔ&Ø—
‘
˜R‘ $§+¡+Ñ-Ø—‘˜bÑ  5§<¡<Ñ/òà—+‘+ §¡Ò-ØØð �:‰:˜Š?˜tŸ{™{¨aÒ/Ø—;‘; %Ñ'Ð'Ør   c                 ó&  — t        |t        «      rT| j                  dz  | j                  z   |j                  dz  |j                  z   k7  s| j                  |j                  k7  ryy| j                  dk(  r| j                  dk(  r| j                  |k7  S y)z‡
        If the years, month part or the timedelta part is not equal, then
        the two Durations are considered not equal.
        r   TFr   rv   rw   s     r   Ú__ne__zDuration.__ne__  s|   € ô
 �eœXÔ&Ø—
‘
˜R‘ $§+¡+Ñ-Ø—‘˜bÑ  5§<¡<Ñ/òà—‘ §¡Ò,ØØð �:‰:˜Š?˜tŸ{™{¨aÒ/Ø—;‘; %Ñ'Ð'Ør   Nc                 ób   — |€|€t        d«      ‚|�|�t        d«      ‚|�|| z   |z
  S ||| z
  z
  S )z´
        Convert this duration into a timedelta object.

        This method requires a start datetime or end datetimem, but raises
        an exception if both are given.
        zstart or end requiredzonly start or end allowed)r_   )r0   ÚstartÚends      r   ÚtotimedeltazDuration.totimedelta/  sS   € ð ˆ=˜S˜[ÜÐ4Ó5Ð5ØÐ  ÜÐ8Ó9Ð9ØÐØ˜D‘L EÑ)Ð)Ø�c˜D‘jÑ!Ð!r   )	r   r   r   r   r   r   r   r   r   )NN)rO   rN   Ú__qualname__Ú__doc__r8   r=   rA   rE   rK   rP   rS   rW   rk   Ú__radd__rn   Ú__rmul__rq   rt   rx   rz   r~   r$   r   r   r)   r)   *   s   „ ñð0 ØØØØØØØØó
ò2ò$ò*ò!ò
ò<òò-ð^ €Hòð €Hòò*(òTò"ô""r   r)   N)	r€   Údatetimer   Údecimalr   r   r   r'   r)   r$   r   r   ú<module>r…      s(   ðñõ ß (òò"
÷R"ò R"r   