1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
U
«ý°dHaã@s ddlZddlZddlZddlmZddlmZddlmZddl    m
Z
e dd„e d    ƒDƒƒ\Z ZZZZZZZd
d d d ddddgZGdd
„d
eƒZdd„ZdS)éN)Úcopysign)Ú integer_types)Úwarné©Úweekdayccs|]}t|ƒVqdS©Nr©Ú.0Úx©r úMd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\dateutil/relativedelta.pyÚ    <genexpr> sréÚ relativedeltaÚMOÚTUÚWEÚTHÚFRÚSAÚSUc@sÀeZdZdZd)dd„Zdd„Zedd    „ƒZejd
d    „ƒZd d „Z    d d„Z
dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„ZeZdd„ZeZdd „Zd!d"„Zd#d$„Zd%d&„ZeZd'd(„ZdS)*ra;
    The relativedelta type is designed to be applied to an existing datetime and
    can replace specific components of that datetime, or represents an interval
    of time.
 
    It is based on the specification of the excellent work done by M.-A. Lemburg
    in his
    `mx.DateTime <https://www.egenix.com/products/python/mxBase/mxDateTime/>`_ extension.
    However, notice that this type does *NOT* implement the same algorithm as
    his work. Do *NOT* expect it to behave like mx.DateTime's counterpart.
 
    There are two different ways to build a relativedelta instance. The
    first one is passing it two date/datetime classes::
 
        relativedelta(datetime1, datetime2)
 
    The second one is passing it any number of the following keyword arguments::
 
        relativedelta(arg1=x,arg2=y,arg3=z...)
 
        year, month, day, hour, minute, second, microsecond:
            Absolute information (argument is singular); adding or subtracting a
            relativedelta with absolute information does not perform an arithmetic
            operation, but rather REPLACES the corresponding value in the
            original datetime with the value(s) in relativedelta.
 
        years, months, weeks, days, hours, minutes, seconds, microseconds:
            Relative information, may be negative (argument is plural); adding
            or subtracting a relativedelta with relative information performs
            the corresponding arithmetic operation on the original datetime value
            with the information in the relativedelta.
 
        weekday: 
            One of the weekday instances (MO, TU, etc) available in the
            relativedelta module. These instances may receive a parameter N,
            specifying the Nth weekday, which could be positive or negative
            (like MO(+1) or MO(-2)). Not specifying it is the same as specifying
            +1. You can also use an integer, where 0=MO. This argument is always
            relative e.g. if the calculated date is already Monday, using MO(1)
            or MO(-1) won't change the day. To effectively make it absolute, use
            it in combination with the day argument (e.g. day=1, MO(1) for first
            Monday of the month).
 
        leapdays:
            Will add given days to the date found, if year is a leap
            year, and the date found is post 28 of february.
 
        yearday, nlyearday:
            Set the yearday or the non-leap year day (jump leap days).
            These are converted to day/month/leapdays information.
 
    There are relative and absolute forms of the keyword
    arguments. The plural is relative, and the singular is
    absolute. For each argument in the order below, the absolute form
    is applied first (by setting each attribute to that value) and
    then the relative form (by adding the value to the attribute).
 
    The order of attributes considered when this relativedelta is
    added to a datetime is:
 
    1. Year
    2. Month
    3. Day
    4. Hours
    5. Minutes
    6. Seconds
    7. Microseconds
 
    Finally, weekday is applied, using the rule described above.
 
    For example
 
    >>> from datetime import datetime
    >>> from dateutil.relativedelta import relativedelta, MO
    >>> dt = datetime(2018, 4, 9, 13, 37, 0)
    >>> delta = relativedelta(hours=25, day=1, weekday=MO(1))
    >>> dt + delta
    datetime.datetime(2018, 4, 2, 14, 37)
 
    First, the day is set to 1 (the first of the month), then 25 hours
    are added, to get to the 2nd day and 14th hour, finally the
    weekday is applied, but since the 2nd is already a Monday there is
    no effect.
 
    Nrc Cs|r†|r†t|tjƒr$t|tjƒs,tdƒ‚t|tjƒt|tjƒkr~t|tjƒsbtj | ¡¡}nt|tjƒs~tj | ¡¡}d|_d|_d|_d|_    d|_
d|_ d|_ d|_ d|_d|_d|_d|_d|_d|_d|_d|_d|_|j|jd|j|j}| |¡| |¡}||kr*tj}d}n
tj}d}|||ƒr`||7}| |¡| |¡}q4||}|j |jd|_ |j |_ n~tdd„||fDƒƒr¦td    ƒ‚t|ƒ|_t|ƒ|_||d
|_||_    ||_
|    |_ |
|_ | |_ | |_| |_||_||_||_||_||_td d„| | |||||fDƒƒr<td t ƒt|t!ƒrTt"||_n||_d}|rj|}n|r„|}|d kr„d|_    |rdd ddddddddddg }t#|ƒD]H\}}||kr®|d|_|dkrÜ||_n|||d|_qq®td|ƒ‚| $¡dS)Nz&relativedelta only diffs datetime/dateré réÿÿÿÿi€Qcss"|]}|dk    o|t|ƒkVqdSr©Úintr    r r r r¬sz)relativedelta.__init__.<locals>.<genexpr>zGNon-integer years and months are ambiguous and not currently supported.rcss"|]}|dk    ot|ƒ|kVqdSrrr    r r r rÃsÿz€Non-integer value passed as absolute information. This is not a well-defined condition and will raise errors in future versions.é;ééZéxé—éµéÔéóii0iNinzinvalid year day (%d))%Ú
isinstanceÚdatetimeÚdateÚ    TypeErrorÚ fromordinalÚ    toordinalÚyearsÚmonthsÚdaysÚleapdaysÚhoursÚminutesÚsecondsÚ microsecondsÚyearÚmonthÚdayrÚhourÚminuteÚsecondÚ microsecondÚ    _has_timeÚ _set_monthsÚ__radd__ÚoperatorÚgtÚltÚanyÚ
ValueErrorrrÚDeprecationWarningrÚweekdaysÚ    enumerateÚ_fix)ÚselfZdt1Zdt2r*r+r,r-Úweeksr.r/r0r1r2r3r4rZyeardayZ    nlyeardayr5r6r7r8ZdtmÚcompareÚ    incrementÚdeltaZydayZydayidxÚidxZydaysr r r Ú__init__isÄ  
ÿ
 
ÿ  
 
 
 
 
 
ÿÿ
þ  
ÿ
 
 
 
 zrelativedelta.__init__cCsÎt|jƒdkrHt|jƒ}t|j|dƒ\}}|||_|j||7_t|jƒdkrt|jƒ}t|j|dƒ\}}|||_|j||7_t|jƒdkrØt|jƒ}t|j|dƒ\}}|||_|j||7_t|jƒdkr"t|jƒ}t|j|dƒ\}}|||_|j||7_t|jƒdkrlt|jƒ}t|j|dƒ\}}|||_|j    ||7_    |js¼|js¼|js¼|js¼|j
dk    s¼|j dk    s¼|j dk    s¼|j dk    rÄd    |_nd
|_dS) Ni?Bi@Bré<ééé rrr)Úabsr1Ú_signÚdivmodr0r/r.r,r+r*r5r6r7r8r9)rEÚsÚdivÚmodr r r rDçsH
 
 
 
 
 
 
 
 
 
 ÿÿþþzrelativedelta._fixcCst|jdƒS)Ng@)rr,©rEr r r rFszrelativedelta.weekscCs|j|jd|d|_dS)Nr)r,rF)rEÚvaluer r r rF scCsR||_t|jƒdkrHt|jƒ}t|j|dƒ\}}|||_|||_nd|_dS)NrOrr)r+rPrQrRr*)rEr+rSrTrUr r r r:s
 
 zrelativedelta._set_monthsc    CsÂt|jƒ}t|jd|j|dƒ}t|ƒ}t|jd||dƒ}t|ƒ}t|jd||dƒ}t|ƒ}t|jd||ƒ}|j|j|j    ||||||j
|j |j |j |j|j|j|j|jdS)aC
        Return a version of this object represented entirely using integer
        values for the relative attributes.
 
        >>> relativedelta(days=1.5, hours=2).normalized()
        relativedelta(days=+1, hours=+14)
 
        :return:
            Returns a :class:`dateutil.relativedelta.relativedelta` object.
        rNrOrLé
ég€„.A©r*r+r,r.r/r0r1r-r2r3r4rr5r6r7r8)rr,Úroundr.r/r0r1Ú    __class__r*r+r-r2r3r4rr5r6r7r8)    rEr,Zhours_fr.Z    minutes_fr/Z    seconds_fr0r1r r r Ú
normalizeds0
 ùzrelativedelta.normalizedc Csdt|tƒr|j|j|j|j|j|j|j|j|j|j|j|j|j|j    |j    |j
p`|j
|j dk    rp|j n|j |j dk    r„|j n|j |j dk    r˜|j n|j |jdk    r¬|jn|j|jdk    rÀ|jn|j|jdk    rÔ|jn|j|jdk    rè|jn|j|jdk    rü|jn|jdSt|tjƒrp|j|j|j|j|j|j|j|j|j|j    |j    |j
|j |j |j |j|j|j|j|jdSt|tjƒs‚tS|jr¨t|tjƒs¨tj | ¡¡}|j p´|j |j}|j pÈ|j }|jr6dt|jƒkrðdksönt‚||j7}|dkr|d7}|d8}n|dkr6|d8}|d7}tt ||¡d|j pR|j ƒ}|||dœ}dD]"}t||ƒ}|dk    rf|||<qf|j}|j
r¸|dkr¸t  |¡r¸||j
7}|j!f|Žtj||j|j|j|j    d}    |jr`|jj|jj"púd}
} t| ƒdd} | d    kr4| d|     ¡|
d7} n| |     ¡|
d7} | d
9} |    tj| d 7}    |    S) NrZrr)r2r3r4)r5r6r7r8é)r,r.r/r0r1rrr)r,)#r$rr\r*r+r,r.r/r0r1r-r2r3r4rr5r6r7r8r%Ú    timedeltar&ÚNotImplementedr9r(r)rPÚAssertionErrorÚminÚcalendarÚ
monthrangeÚgetattrÚisleapÚreplaceÚn) rEÚotherr2r3r4ÚreplÚattrrWr,ÚretrZnthZjumpdaysr r r Ú__add__=s¶ 
 
 
 
 
ÿ
ÿ
ç
 
 
ñ$
 
 
 
 ÿ 
 
 
 
üÿ
zrelativedelta.__add__cCs
| |¡Sr)rm©rErir r r r;”szrelativedelta.__radd__cCs| ¡ |¡Sr)Ú__neg__r;rnr r r Ú__rsub__—szrelativedelta.__rsub__cCst|tƒstS|j|j|j|j|j|j|j|j|j|j|j|j    |j    |j
|j
|j pb|j |j dk    rr|j n|j |j dk    r†|j n|j |jdk    rš|jn|j|jdk    r®|jn|j|jdk    rÂ|jn|j|jdk    rÖ|jn|j|jdk    rê|jn|j|jdk    rþ|jn|jdS©NrZ)r$rr`r\r*r+r,r.r/r0r1r-r2r3r4rr5r6r7r8rnr r r Ú__sub__šs:
 
 
 
 
 
 
 
ÿ
èzrelativedelta.__sub__cCsf|jt|jƒt|jƒt|jƒt|jƒt|jƒt|jƒt|jƒ|j    |j
|j |j |j |j|j|j|jdSrq)r\rPr*r+r,r.r/r0r1r-r2r3r4rr5r6r7r8rVr r r Ú__abs__·s" ñzrelativedelta.__abs__cCsX|j|j |j |j |j |j |j |j |j|j    |j
|j |j |j |j|j|jdSrq)r\r*r+r,r.r/r0r1r-r2r3r4rr5r6r7r8rVr r r roÉs"
ñzrelativedelta.__neg__cCs’|j oŽ|j oŽ|j oŽ|j oŽ|j oŽ|j oŽ|j oŽ|j oŽ|jdkoŽ|j    dkoŽ|j
dkoŽ|j dkoŽ|j dkoŽ|j dkoŽ|jdkoŽ|jdk SrrZrVr r r Ú__bool__Ûs>ÿþýüûúùø    ÷
ö õ ô óòñzrelativedelta.__bool__cCs¨z t|ƒ}Wntk
r$tYSX|jt|j|ƒt|j|ƒt|j|ƒt|j|ƒt|j    |ƒt|j
|ƒt|j |ƒ|j |j |j|j|j|j|j|j|jdSrq)Úfloatr'r`r\rr*r+r,r.r/r0r1r-r2r3r4rr5r6r7r8)rEriÚfr r r Ú__mul__ïs* 
      ñzrelativedelta.__mul__cCsDt|tƒstS|js|jrt|jr&|js*dS|jj|jjkr>dS|jj|jj}}||krt|rd|dkrp|rt|dkstdS|j|jkoB|j|jkoB|j|jkoB|j|jkoB|j    |j    koB|j
|j
koB|j |j koB|j |j koB|j |j koB|j|jkoB|j|jkoB|j|jkoB|j|jkoB|j|jkoB|j|jkS)NFr)r$rr`rrhr*r+r,r.r/r0r1r-r2r3r4r5r6r7r8)rEriZn1Zn2r r r Ú__eq__sN
   
ÿ
þ
ý
ü
û
ú
ù
ø    
÷
 
ö
õ
ô
ó
òzrelativedelta.__eq__cCsHt|j|j|j|j|j|j|j|j|j    |j
|j |j |j |j|j|jfƒSr)Úhashrr*r+r,r.r/r0r1r-r2r3r4r5r6r7r8rVr r r Ú__hash__#s$ðzrelativedelta.__hash__cCs | |¡ Sr)rxrnr r r Ú__ne__7szrelativedelta.__ne__cCs4zdt|ƒ}Wntk
r(tYSX| |¡S©Nr)rur'r`rw)rEriZ
reciprocalr r r Ú__div__:s
 
zrelativedelta.__div__cCs|g}dD]&}t||ƒ}|r| dj||d¡qdD].}t||ƒ}|dk    r4| dj|t|ƒd¡q4dj|jjd |¡dS)    N)r*r+r,r-r.r/r0r1z{attr}={value:+g})rkrW)r2r3r4rr5r6r7r8z{attr}={value}z{classname}({attrs})z, )Ú    classnameÚattrs)reÚappendÚformatÚreprr\Ú__name__Újoin)rEÚlrkrWr r r Ú__repr__Ds
 
 
ÿzrelativedelta.__repr__)NNrrrrrrrrrNNNNNNNNNN)rƒÚ
__module__Ú __qualname__Ú__doc__rKrDÚpropertyrFÚsetterr:r]rmr;rprrrsrortÚ __nonzero__rwÚ__rmul__rxrzr{r}Ú __truediv__r†r r r r rsZVû
~!
 
 
#WcCsttd|ƒƒSr|)rr)r r r r rQTsrQ)r%rcr<ÚmathrÚsixrÚwarningsrZ_commonrÚtupleÚrangerrrrrrrrBÚ__all__ÚobjectrrQr r r r Ú<module>s    (F