Mercurial > repos > shellac > guppy_basecaller
annotate env/lib/python3.7/site-packages/dateutil/relativedelta.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac | 
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 
0
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
1 # -*- coding: utf-8 -*- | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
2 import datetime | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
3 import calendar | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
4 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
5 import operator | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
6 from math import copysign | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
7 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
8 from six import integer_types | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
9 from warnings import warn | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
10 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
11 from ._common import weekday | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
12 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
13 MO, TU, WE, TH, FR, SA, SU = weekdays = tuple(weekday(x) for x in range(7)) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
14 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
15 __all__ = ["relativedelta", "MO", "TU", "WE", "TH", "FR", "SA", "SU"] | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
16 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
17 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
18 class relativedelta(object): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
19 """ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
20 The relativedelta type is designed to be applied to an existing datetime and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
21 can replace specific components of that datetime, or represents an interval | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
22 of time. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
23 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
24 It is based on the specification of the excellent work done by M.-A. Lemburg | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
25 in his | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
26 `mx.DateTime <https://www.egenix.com/products/python/mxBase/mxDateTime/>`_ extension. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
27 However, notice that this type does *NOT* implement the same algorithm as | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
28 his work. Do *NOT* expect it to behave like mx.DateTime's counterpart. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
29 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
30 There are two different ways to build a relativedelta instance. The | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
31 first one is passing it two date/datetime classes:: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
32 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
33 relativedelta(datetime1, datetime2) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
34 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
35 The second one is passing it any number of the following keyword arguments:: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
36 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
37 relativedelta(arg1=x,arg2=y,arg3=z...) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
38 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
39 year, month, day, hour, minute, second, microsecond: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
40 Absolute information (argument is singular); adding or subtracting a | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
41 relativedelta with absolute information does not perform an arithmetic | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
42 operation, but rather REPLACES the corresponding value in the | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
43 original datetime with the value(s) in relativedelta. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
44 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
45 years, months, weeks, days, hours, minutes, seconds, microseconds: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
46 Relative information, may be negative (argument is plural); adding | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
47 or subtracting a relativedelta with relative information performs | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
48 the corresponding arithmetic operation on the original datetime value | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
49 with the information in the relativedelta. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
50 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
51 weekday: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
52 One of the weekday instances (MO, TU, etc) available in the | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
53 relativedelta module. These instances may receive a parameter N, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
54 specifying the Nth weekday, which could be positive or negative | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
55 (like MO(+1) or MO(-2)). Not specifying it is the same as specifying | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
56 +1. You can also use an integer, where 0=MO. This argument is always | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
57 relative e.g. if the calculated date is already Monday, using MO(1) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
58 or MO(-1) won't change the day. To effectively make it absolute, use | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
59 it in combination with the day argument (e.g. day=1, MO(1) for first | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
60 Monday of the month). | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
61 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
62 leapdays: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
63 Will add given days to the date found, if year is a leap | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
64 year, and the date found is post 28 of february. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
65 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
66 yearday, nlyearday: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
67 Set the yearday or the non-leap year day (jump leap days). | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
68 These are converted to day/month/leapdays information. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
69 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
70 There are relative and absolute forms of the keyword | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
71 arguments. The plural is relative, and the singular is | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
72 absolute. For each argument in the order below, the absolute form | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
73 is applied first (by setting each attribute to that value) and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
74 then the relative form (by adding the value to the attribute). | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
75 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
76 The order of attributes considered when this relativedelta is | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
77 added to a datetime is: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
78 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
79 1. Year | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
80 2. Month | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
81 3. Day | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
82 4. Hours | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
83 5. Minutes | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
84 6. Seconds | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
85 7. Microseconds | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
86 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
87 Finally, weekday is applied, using the rule described above. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
88 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
89 For example | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
90 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
91 >>> from datetime import datetime | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
92 >>> from dateutil.relativedelta import relativedelta, MO | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
93 >>> dt = datetime(2018, 4, 9, 13, 37, 0) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
94 >>> delta = relativedelta(hours=25, day=1, weekday=MO(1)) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
95 >>> dt + delta | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
96 datetime.datetime(2018, 4, 2, 14, 37) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
97 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
98 First, the day is set to 1 (the first of the month), then 25 hours | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
99 are added, to get to the 2nd day and 14th hour, finally the | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
100 weekday is applied, but since the 2nd is already a Monday there is | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
101 no effect. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
102 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
103 """ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
104 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
105 def __init__(self, dt1=None, dt2=None, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
106 years=0, months=0, days=0, leapdays=0, weeks=0, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
107 hours=0, minutes=0, seconds=0, microseconds=0, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
108 year=None, month=None, day=None, weekday=None, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
109 yearday=None, nlyearday=None, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
110 hour=None, minute=None, second=None, microsecond=None): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
111 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
112 if dt1 and dt2: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
113 # datetime is a subclass of date. So both must be date | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
114 if not (isinstance(dt1, datetime.date) and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
115 isinstance(dt2, datetime.date)): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
116 raise TypeError("relativedelta only diffs datetime/date") | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
117 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
118 # We allow two dates, or two datetimes, so we coerce them to be | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
119 # of the same type | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
120 if (isinstance(dt1, datetime.datetime) != | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
121 isinstance(dt2, datetime.datetime)): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
122 if not isinstance(dt1, datetime.datetime): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
123 dt1 = datetime.datetime.fromordinal(dt1.toordinal()) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
124 elif not isinstance(dt2, datetime.datetime): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
125 dt2 = datetime.datetime.fromordinal(dt2.toordinal()) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
126 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
127 self.years = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
128 self.months = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
129 self.days = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
130 self.leapdays = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
131 self.hours = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
132 self.minutes = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
133 self.seconds = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
134 self.microseconds = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
135 self.year = None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
136 self.month = None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
137 self.day = None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
138 self.weekday = None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
139 self.hour = None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
140 self.minute = None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
141 self.second = None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
142 self.microsecond = None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
143 self._has_time = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
144 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
145 # Get year / month delta between the two | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
146 months = (dt1.year - dt2.year) * 12 + (dt1.month - dt2.month) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
147 self._set_months(months) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
148 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
149 # Remove the year/month delta so the timedelta is just well-defined | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
150 # time units (seconds, days and microseconds) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
151 dtm = self.__radd__(dt2) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
152 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
153 # If we've overshot our target, make an adjustment | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
154 if dt1 < dt2: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
155 compare = operator.gt | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
156 increment = 1 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
157 else: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
158 compare = operator.lt | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
159 increment = -1 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
160 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
161 while compare(dt1, dtm): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
162 months += increment | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
163 self._set_months(months) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
164 dtm = self.__radd__(dt2) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
165 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
166 # Get the timedelta between the "months-adjusted" date and dt1 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
167 delta = dt1 - dtm | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
168 self.seconds = delta.seconds + delta.days * 86400 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
169 self.microseconds = delta.microseconds | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
170 else: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
171 # Check for non-integer values in integer-only quantities | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
172 if any(x is not None and x != int(x) for x in (years, months)): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
173 raise ValueError("Non-integer years and months are " | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
174 "ambiguous and not currently supported.") | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
175 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
176 # Relative information | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
177 self.years = int(years) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
178 self.months = int(months) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
179 self.days = days + weeks * 7 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
180 self.leapdays = leapdays | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
181 self.hours = hours | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
182 self.minutes = minutes | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
183 self.seconds = seconds | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
184 self.microseconds = microseconds | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
185 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
186 # Absolute information | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
187 self.year = year | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
188 self.month = month | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
189 self.day = day | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
190 self.hour = hour | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
191 self.minute = minute | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
192 self.second = second | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
193 self.microsecond = microsecond | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
194 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
195 if any(x is not None and int(x) != x | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
196 for x in (year, month, day, hour, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
197 minute, second, microsecond)): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
198 # For now we'll deprecate floats - later it'll be an error. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
199 warn("Non-integer value passed as absolute information. " + | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
200 "This is not a well-defined condition and will raise " + | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
201 "errors in future versions.", DeprecationWarning) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
202 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
203 if isinstance(weekday, integer_types): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
204 self.weekday = weekdays[weekday] | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
205 else: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
206 self.weekday = weekday | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
207 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
208 yday = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
209 if nlyearday: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
210 yday = nlyearday | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
211 elif yearday: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
212 yday = yearday | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
213 if yearday > 59: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
214 self.leapdays = -1 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
215 if yday: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
216 ydayidx = [31, 59, 90, 120, 151, 181, 212, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
217 243, 273, 304, 334, 366] | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
218 for idx, ydays in enumerate(ydayidx): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
219 if yday <= ydays: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
220 self.month = idx+1 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
221 if idx == 0: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
222 self.day = yday | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
223 else: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
224 self.day = yday-ydayidx[idx-1] | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
225 break | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
226 else: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
227 raise ValueError("invalid year day (%d)" % yday) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
228 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
229 self._fix() | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
230 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
231 def _fix(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
232 if abs(self.microseconds) > 999999: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
233 s = _sign(self.microseconds) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
234 div, mod = divmod(self.microseconds * s, 1000000) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
235 self.microseconds = mod * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
236 self.seconds += div * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
237 if abs(self.seconds) > 59: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
238 s = _sign(self.seconds) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
239 div, mod = divmod(self.seconds * s, 60) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
240 self.seconds = mod * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
241 self.minutes += div * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
242 if abs(self.minutes) > 59: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
243 s = _sign(self.minutes) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
244 div, mod = divmod(self.minutes * s, 60) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
245 self.minutes = mod * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
246 self.hours += div * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
247 if abs(self.hours) > 23: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
248 s = _sign(self.hours) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
249 div, mod = divmod(self.hours * s, 24) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
250 self.hours = mod * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
251 self.days += div * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
252 if abs(self.months) > 11: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
253 s = _sign(self.months) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
254 div, mod = divmod(self.months * s, 12) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
255 self.months = mod * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
256 self.years += div * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
257 if (self.hours or self.minutes or self.seconds or self.microseconds | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
258 or self.hour is not None or self.minute is not None or | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
259 self.second is not None or self.microsecond is not None): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
260 self._has_time = 1 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
261 else: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
262 self._has_time = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
263 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
264 @property | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
265 def weeks(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
266 return int(self.days / 7.0) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
267 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
268 @weeks.setter | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
269 def weeks(self, value): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
270 self.days = self.days - (self.weeks * 7) + value * 7 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
271 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
272 def _set_months(self, months): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
273 self.months = months | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
274 if abs(self.months) > 11: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
275 s = _sign(self.months) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
276 div, mod = divmod(self.months * s, 12) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
277 self.months = mod * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
278 self.years = div * s | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
279 else: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
280 self.years = 0 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
281 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
282 def normalized(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
283 """ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
284 Return a version of this object represented entirely using integer | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
285 values for the relative attributes. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
286 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
287 >>> relativedelta(days=1.5, hours=2).normalized() | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
288 relativedelta(days=+1, hours=+14) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
289 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
290 :return: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
291 Returns a :class:`dateutil.relativedelta.relativedelta` object. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
292 """ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
293 # Cascade remainders down (rounding each to roughly nearest microsecond) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
294 days = int(self.days) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
295 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
296 hours_f = round(self.hours + 24 * (self.days - days), 11) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
297 hours = int(hours_f) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
298 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
299 minutes_f = round(self.minutes + 60 * (hours_f - hours), 10) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
300 minutes = int(minutes_f) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
301 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
302 seconds_f = round(self.seconds + 60 * (minutes_f - minutes), 8) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
303 seconds = int(seconds_f) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
304 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
305 microseconds = round(self.microseconds + 1e6 * (seconds_f - seconds)) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
306 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
307 # Constructor carries overflow back up with call to _fix() | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
308 return self.__class__(years=self.years, months=self.months, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
309 days=days, hours=hours, minutes=minutes, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
310 seconds=seconds, microseconds=microseconds, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
311 leapdays=self.leapdays, year=self.year, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
312 month=self.month, day=self.day, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
313 weekday=self.weekday, hour=self.hour, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
314 minute=self.minute, second=self.second, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
315 microsecond=self.microsecond) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
316 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
317 def __add__(self, other): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
318 if isinstance(other, relativedelta): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
319 return self.__class__(years=other.years + self.years, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
320 months=other.months + self.months, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
321 days=other.days + self.days, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
322 hours=other.hours + self.hours, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
323 minutes=other.minutes + self.minutes, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
324 seconds=other.seconds + self.seconds, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
325 microseconds=(other.microseconds + | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
326 self.microseconds), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
327 leapdays=other.leapdays or self.leapdays, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
328 year=(other.year if other.year is not None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
329 else self.year), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
330 month=(other.month if other.month is not None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
331 else self.month), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
332 day=(other.day if other.day is not None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
333 else self.day), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
334 weekday=(other.weekday if other.weekday is not None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
335 else self.weekday), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
336 hour=(other.hour if other.hour is not None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
337 else self.hour), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
338 minute=(other.minute if other.minute is not None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
339 else self.minute), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
340 second=(other.second if other.second is not None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
341 else self.second), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
342 microsecond=(other.microsecond if other.microsecond | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
343 is not None else | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
344 self.microsecond)) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
345 if isinstance(other, datetime.timedelta): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
346 return self.__class__(years=self.years, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
347 months=self.months, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
348 days=self.days + other.days, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
349 hours=self.hours, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
350 minutes=self.minutes, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
351 seconds=self.seconds + other.seconds, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
352 microseconds=self.microseconds + other.microseconds, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
353 leapdays=self.leapdays, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
354 year=self.year, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
355 month=self.month, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
356 day=self.day, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
357 weekday=self.weekday, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
358 hour=self.hour, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
359 minute=self.minute, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
360 second=self.second, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
361 microsecond=self.microsecond) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
362 if not isinstance(other, datetime.date): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
363 return NotImplemented | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
364 elif self._has_time and not isinstance(other, datetime.datetime): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
365 other = datetime.datetime.fromordinal(other.toordinal()) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
366 year = (self.year or other.year)+self.years | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
367 month = self.month or other.month | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
368 if self.months: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
369 assert 1 <= abs(self.months) <= 12 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
370 month += self.months | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
371 if month > 12: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
372 year += 1 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
373 month -= 12 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
374 elif month < 1: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
375 year -= 1 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
376 month += 12 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
377 day = min(calendar.monthrange(year, month)[1], | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
378 self.day or other.day) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
379 repl = {"year": year, "month": month, "day": day} | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
380 for attr in ["hour", "minute", "second", "microsecond"]: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
381 value = getattr(self, attr) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
382 if value is not None: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
383 repl[attr] = value | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
384 days = self.days | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
385 if self.leapdays and month > 2 and calendar.isleap(year): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
386 days += self.leapdays | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
387 ret = (other.replace(**repl) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
388 + datetime.timedelta(days=days, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
389 hours=self.hours, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
390 minutes=self.minutes, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
391 seconds=self.seconds, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
392 microseconds=self.microseconds)) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
393 if self.weekday: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
394 weekday, nth = self.weekday.weekday, self.weekday.n or 1 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
395 jumpdays = (abs(nth) - 1) * 7 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
396 if nth > 0: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
397 jumpdays += (7 - ret.weekday() + weekday) % 7 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
398 else: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
399 jumpdays += (ret.weekday() - weekday) % 7 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
400 jumpdays *= -1 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
401 ret += datetime.timedelta(days=jumpdays) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
402 return ret | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
403 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
404 def __radd__(self, other): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
405 return self.__add__(other) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
406 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
407 def __rsub__(self, other): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
408 return self.__neg__().__radd__(other) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
409 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
410 def __sub__(self, other): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
411 if not isinstance(other, relativedelta): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
412 return NotImplemented # In case the other object defines __rsub__ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
413 return self.__class__(years=self.years - other.years, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
414 months=self.months - other.months, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
415 days=self.days - other.days, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
416 hours=self.hours - other.hours, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
417 minutes=self.minutes - other.minutes, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
418 seconds=self.seconds - other.seconds, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
419 microseconds=self.microseconds - other.microseconds, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
420 leapdays=self.leapdays or other.leapdays, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
421 year=(self.year if self.year is not None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
422 else other.year), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
423 month=(self.month if self.month is not None else | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
424 other.month), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
425 day=(self.day if self.day is not None else | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
426 other.day), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
427 weekday=(self.weekday if self.weekday is not None else | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
428 other.weekday), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
429 hour=(self.hour if self.hour is not None else | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
430 other.hour), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
431 minute=(self.minute if self.minute is not None else | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
432 other.minute), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
433 second=(self.second if self.second is not None else | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
434 other.second), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
435 microsecond=(self.microsecond if self.microsecond | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
436 is not None else | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
437 other.microsecond)) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
438 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
439 def __abs__(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
440 return self.__class__(years=abs(self.years), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
441 months=abs(self.months), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
442 days=abs(self.days), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
443 hours=abs(self.hours), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
444 minutes=abs(self.minutes), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
445 seconds=abs(self.seconds), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
446 microseconds=abs(self.microseconds), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
447 leapdays=self.leapdays, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
448 year=self.year, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
449 month=self.month, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
450 day=self.day, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
451 weekday=self.weekday, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
452 hour=self.hour, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
453 minute=self.minute, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
454 second=self.second, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
455 microsecond=self.microsecond) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
456 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
457 def __neg__(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
458 return self.__class__(years=-self.years, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
459 months=-self.months, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
460 days=-self.days, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
461 hours=-self.hours, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
462 minutes=-self.minutes, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
463 seconds=-self.seconds, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
464 microseconds=-self.microseconds, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
465 leapdays=self.leapdays, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
466 year=self.year, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
467 month=self.month, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
468 day=self.day, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
469 weekday=self.weekday, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
470 hour=self.hour, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
471 minute=self.minute, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
472 second=self.second, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
473 microsecond=self.microsecond) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
474 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
475 def __bool__(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
476 return not (not self.years and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
477 not self.months and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
478 not self.days and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
479 not self.hours and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
480 not self.minutes and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
481 not self.seconds and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
482 not self.microseconds and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
483 not self.leapdays and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
484 self.year is None and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
485 self.month is None and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
486 self.day is None and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
487 self.weekday is None and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
488 self.hour is None and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
489 self.minute is None and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
490 self.second is None and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
491 self.microsecond is None) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
492 # Compatibility with Python 2.x | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
493 __nonzero__ = __bool__ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
494 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
495 def __mul__(self, other): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
496 try: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
497 f = float(other) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
498 except TypeError: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
499 return NotImplemented | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
500 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
501 return self.__class__(years=int(self.years * f), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
502 months=int(self.months * f), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
503 days=int(self.days * f), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
504 hours=int(self.hours * f), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
505 minutes=int(self.minutes * f), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
506 seconds=int(self.seconds * f), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
507 microseconds=int(self.microseconds * f), | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
508 leapdays=self.leapdays, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
509 year=self.year, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
510 month=self.month, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
511 day=self.day, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
512 weekday=self.weekday, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
513 hour=self.hour, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
514 minute=self.minute, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
515 second=self.second, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
516 microsecond=self.microsecond) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
517 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
518 __rmul__ = __mul__ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
519 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
520 def __eq__(self, other): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
521 if not isinstance(other, relativedelta): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
522 return NotImplemented | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
523 if self.weekday or other.weekday: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
524 if not self.weekday or not other.weekday: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
525 return False | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
526 if self.weekday.weekday != other.weekday.weekday: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
527 return False | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
528 n1, n2 = self.weekday.n, other.weekday.n | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
529 if n1 != n2 and not ((not n1 or n1 == 1) and (not n2 or n2 == 1)): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
530 return False | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
531 return (self.years == other.years and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
532 self.months == other.months and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
533 self.days == other.days and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
534 self.hours == other.hours and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
535 self.minutes == other.minutes and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
536 self.seconds == other.seconds and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
537 self.microseconds == other.microseconds and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
538 self.leapdays == other.leapdays and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
539 self.year == other.year and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
540 self.month == other.month and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
541 self.day == other.day and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
542 self.hour == other.hour and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
543 self.minute == other.minute and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
544 self.second == other.second and | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
545 self.microsecond == other.microsecond) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
546 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
547 def __hash__(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
548 return hash(( | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
549 self.weekday, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
550 self.years, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
551 self.months, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
552 self.days, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
553 self.hours, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
554 self.minutes, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
555 self.seconds, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
556 self.microseconds, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
557 self.leapdays, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
558 self.year, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
559 self.month, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
560 self.day, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
561 self.hour, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
562 self.minute, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
563 self.second, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
564 self.microsecond, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
565 )) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
566 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
567 def __ne__(self, other): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
568 return not self.__eq__(other) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
569 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
570 def __div__(self, other): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
571 try: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
572 reciprocal = 1 / float(other) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
573 except TypeError: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
574 return NotImplemented | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
575 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
576 return self.__mul__(reciprocal) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
577 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
578 __truediv__ = __div__ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
579 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
580 def __repr__(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
581 l = [] | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
582 for attr in ["years", "months", "days", "leapdays", | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
583 "hours", "minutes", "seconds", "microseconds"]: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
584 value = getattr(self, attr) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
585 if value: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
586 l.append("{attr}={value:+g}".format(attr=attr, value=value)) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
587 for attr in ["year", "month", "day", "weekday", | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
588 "hour", "minute", "second", "microsecond"]: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
589 value = getattr(self, attr) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
590 if value is not None: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
591 l.append("{attr}={value}".format(attr=attr, value=repr(value))) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
592 return "{classname}({attrs})".format(classname=self.__class__.__name__, | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
593 attrs=", ".join(l)) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
594 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
595 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
596 def _sign(x): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
597 return int(copysign(1, x)) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
598 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
599 # vim:ts=4:sw=4:et | 
