Codebase list isodate / 29aefd6
Update upstream source from tag 'upstream/0.6.1' Update to upstream version '0.6.1' with Debian dir 0592e630698a25dae77d1b65d16553a685294a73 Michael R. Crusoe 2 years ago
5 changed file(s) with 566 addition(s) and 531 deletion(s). Raw diff Collapse all Expand all
00
11 CHANGES
22 =======
3
4 0.6.1 (2021-12-13)
5 ------------------
6
7 - support python 3.10 ()
8 - last version to support py 2.7
9
310
411 0.6.0 (2017-10-13)
512 ------------------
+273
-262
PKG-INFO less more
0 Metadata-Version: 1.1
0 Metadata-Version: 2.1
11 Name: isodate
2 Version: 0.6.0
2 Version: 0.6.1
33 Summary: An ISO 8601 date/time/duration parser and formatter
44 Home-page: https://github.com/gweis/isodate/
55 Author: Gerhard Weis
66 Author-email: gerhard.weis@proclos.com
77 License: BSD
8 Description:
9 ISO 8601 date/time parser
10 =========================
11
12 .. image:: https://travis-ci.org/gweis/isodate.svg?branch=master
13 :target: https://travis-ci.org/gweis/isodate
14 :alt: Travis-CI
15 .. image:: https://coveralls.io/repos/gweis/isodate/badge.svg?branch=master
16 :target: https://coveralls.io/r/gweis/isodate?branch=master
17 :alt: Coveralls
18 .. image:: https://img.shields.io/pypi/v/isodate.svg
19 :target: https://pypi.python.org/pypi/isodate/
20 :alt: Latest Version
21 .. image:: https://img.shields.io/pypi/l/isodate.svg
22 :target: https://pypi.python.org/pypi/isodate/
23 :alt: License
24
25
26 This module implements ISO 8601 date, time and duration parsing.
27 The implementation follows ISO8601:2004 standard, and implements only
28 date/time representations mentioned in the standard. If something is not
29 mentioned there, then it is treated as non existent, and not as an allowed
30 option.
31
32 For instance, ISO8601:2004 never mentions 2 digit years. So, it is not
33 intended by this module to support 2 digit years. (while it may still
34 be valid as ISO date, because it is not explicitly forbidden.)
35 Another example is, when no time zone information is given for a time,
36 then it should be interpreted as local time, and not UTC.
37
38 As this module maps ISO 8601 dates/times to standard Python data types, like
39 *date*, *time*, *datetime* and *timedelta*, it is not possible to convert
40 all possible ISO 8601 dates/times. For instance, dates before 0001-01-01 are
41 not allowed by the Python *date* and *datetime* classes. Additionally
42 fractional seconds are limited to microseconds. That means if the parser finds
43 for instance nanoseconds it will round it to microseconds.
44
45 Documentation
46 -------------
47
48 Currently there are four parsing methods available.
49 * parse_time:
50 parses an ISO 8601 time string into a *time* object
51 * parse_date:
52 parses an ISO 8601 date string into a *date* object
53 * parse_datetime:
54 parses an ISO 8601 date-time string into a *datetime* object
55 * parse_duration:
56 parses an ISO 8601 duration string into a *timedelta* or *Duration*
57 object.
58 * parse_tzinfo:
59 parses the time zone info part of an ISO 8601 string into a
60 *tzinfo* object.
61
62 As ISO 8601 allows to define durations in years and months, and *timedelta*
63 does not handle years and months, this module provides a *Duration* class,
64 which can be used almost like a *timedelta* object (with some limitations).
65 However, a *Duration* object can be converted into a *timedelta* object.
66
67 There are also ISO formatting methods for all supported data types. Each
68 *xxx_isoformat* method accepts a format parameter. The default format is
69 always the ISO 8601 expanded format. This is the same format used by
70 *datetime.isoformat*:
71
72 * time_isoformat:
73 Intended to create ISO time strings with default format
74 *hh:mm:ssZ*.
75 * date_isoformat:
76 Intended to create ISO date strings with default format
77 *yyyy-mm-dd*.
78 * datetime_isoformat:
79 Intended to create ISO date-time strings with default format
80 *yyyy-mm-ddThh:mm:ssZ*.
81 * duration_isoformat:
82 Intended to create ISO duration strings with default format
83 *PnnYnnMnnDTnnHnnMnnS*.
84 * tz_isoformat:
85 Intended to create ISO time zone strings with default format
86 *hh:mm*.
87 * strftime:
88 A re-implementation mostly compatible with Python's *strftime*, but
89 supports only those format strings, which can also be used for dates
90 prior 1900. This method also understands how to format *datetime* and
91 *Duration* instances.
92
93 Installation:
94 -------------
95
96 This module can easily be installed with Python standard installation methods.
97
98 Either use *python setup.py install* or in case you have *setuptools* or
99 *distribute* available, you can also use *easy_install*.
100
101 Limitations:
102 ------------
103
104 * The parser accepts several date/time representation which should be invalid
105 according to ISO 8601 standard.
106
107 1. for date and time together, this parser accepts a mixture of basic and extended format.
108 e.g. the date could be in basic format, while the time is accepted in extended format.
109 It also allows short dates and times in date-time strings.
110 2. For incomplete dates, the first day is chosen. e.g. 19th century results in a date of
111 1901-01-01.
112 3. negative *Duration* and *timedelta* value are not fully supported yet.
113
114 Further information:
115 --------------------
116
117 The doc strings and unit tests should provide rather detailed information about
118 the methods and their limitations.
119
120 The source release provides a *setup.py* script,
121 which can be used to run the unit tests included.
122
123 Source code is available at `<http://github.com/gweis/isodate>`_.
124
125 CHANGES
126 =======
127
128 0.6.0 (2017-10-13)
129 ------------------
130
131 - support incomplete month date (Fabien Loffredo)
132 - rely on duck typing when doing duration maths
133 - support ':' as separator in fractional time zones (usrenmae)
134
135
136 0.5.4 (2015-08-06)
137 ------------------
138
139 - Fix parsing of Periods (Fabien Bochu)
140 - Make Duration objects hashable (Geoffrey Fairchild)
141 - Add multiplication to duration (Reinoud Elhorst)
142
143
144 0.5.1 (2014-11-07)
145 ------------------
146
147 - fixed pickling of Duration objects
148 - raise ISO8601Error when there is no 'T' separator in datetime strings (Adrian Coveney)
149
150
151 0.5.0 (2014-02-23)
152 ------------------
153
154 - ISO8601Error are subclasses of ValueError now (Michael Hrivnak)
155 - improve compatibility across various python variants and versions
156 - raise exceptions when using fractional years and months in date
157 maths with durations
158 - renamed method todatetime on Duraction objects to totimedelta
159
160
161 0.4.9 (2012-10-30)
162 ------------------
163
164 - support pickling FixedOffset instances
165 - make sure parsed fractional seconds are in microseconds
166 - add leading zeros when formattig microseconds (Jarom Loveridge)
167
168
169 0.4.8 (2012-05-04)
170 ------------------
171
172 - fixed incompatibility of unittests with python 2.5 and 2.6 (runs fine on 2.7
173 and 3.2)
174
175
176 0.4.7 (2012-01-26)
177 ------------------
178
179 - fixed tzinfo formatting (never pass None into tzinfo.utcoffset())
180
181
182 0.4.6 (2012-01-06)
183 ------------------
184
185 - added Python 3 compatibility via 2to3
186
187 0.4.5 (2012-01-06)
188 ------------------
189
190 - made setuptools dependency optional
191
192 0.4.4 (2011-04-16)
193 ------------------
194
195 - Fixed formatting of microseconds for datetime objects
196
197 0.4.3 (2010-10-29)
198 ------------------
199
200 - Fixed problem with %P formating and fractions (supplied by David Brooks)
201
202 0.4.2 (2010-10-28)
203 ------------------
204
205 - Implemented unary - for Duration (supplied by David Brooks)
206 - Output fractional seconds with '%P' format. (partly supplied by David Brooks)
207
208 0.4.1 (2010-10-13)
209 ------------------
210
211 - fixed bug in comparison between timedelta and Duration.
212 - fixed precision problem with microseconds (reported by Tommi Virtanen)
213
214 0.4.0 (2009-02-09)
215 ------------------
216
217 - added method to parse ISO 8601 time zone strings
218 - added methods to create ISO 8601 conforming strings
219
220 0.3.0 (2009-1-05)
221 ------------------
222
223 - Initial release
224
225 TODOs
226 =====
227
228 This to do list contains some thoughts and ideas about missing features, and
229 parts to think about, whether to implement them or not. This list is probably
230 not complete.
231
232 Missing features:
233 -----------------
234
235 * time formating does not allow to create fractional representations.
236 * parser for ISO intervals.
237 * currently microseconds are always padded to a length of 6 characters.
238 trailing 0s should be optional
239
240 Documentation:
241 --------------
242
243 * parse_datetime:
244 - complete documentation to show what this function allows, but ISO forbids.
245 and vice verse.
246 - support other separators between date and time than 'T'
247
248 * parse_date:
249 - yeardigits should be always greater than 4
250 - dates before 0001-01-01 are not supported
251
252 * parse_duration:
253 - alternative formats are not fully supported due to parse_date restrictions
254 - standard duration format is fully supported but not very restrictive.
255
256 * Duration:
257 - support fractional years and month in calculations
258 - implement w3c order relation? (`<http://www.w3.org/TR/xmlschema-2/#duration-order>`_)
259 - refactor to have duration mathematics only at one place.
260 - localize __str__ method (does timedelta do this?)
261 - when is a Duration negative?
262 - normalize Durations. months [00-12] and years ]-inf,+inf[
263
2648 Platform: UNKNOWN
2659 Classifier: Development Status :: 4 - Beta
26610 Classifier: Intended Audience :: Developers
26711 Classifier: License :: OSI Approved :: BSD License
26812 Classifier: Operating System :: OS Independent
26913 Classifier: Programming Language :: Python
270 Classifier: Programming Language :: Python :: 2.6
14 Classifier: Programming Language :: Python :: 2
27115 Classifier: Programming Language :: Python :: 2.7
272 Classifier: Programming Language :: Python :: 3.3
273 Classifier: Programming Language :: Python :: 3.4
274 Classifier: Programming Language :: Python :: 3.5
16 Classifier: Programming Language :: Python :: 3
27517 Classifier: Programming Language :: Python :: 3.6
18 Classifier: Programming Language :: Python :: 3.7
19 Classifier: Programming Language :: Python :: 3.8
20 Classifier: Programming Language :: Python :: 3.9
21 Classifier: Programming Language :: Python :: 3.10
27622 Classifier: Programming Language :: Python :: Implementation :: PyPy
27723 Classifier: Topic :: Internet
27824 Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
26
27 ISO 8601 date/time parser
28 =========================
29
30 .. image:: https://travis-ci.org/gweis/isodate.svg?branch=master
31 :target: https://travis-ci.org/gweis/isodate
32 :alt: Travis-CI
33 .. image:: https://coveralls.io/repos/gweis/isodate/badge.svg?branch=master
34 :target: https://coveralls.io/r/gweis/isodate?branch=master
35 :alt: Coveralls
36 .. image:: https://img.shields.io/pypi/v/isodate.svg
37 :target: https://pypi.python.org/pypi/isodate/
38 :alt: Latest Version
39 .. image:: https://img.shields.io/pypi/l/isodate.svg
40 :target: https://pypi.python.org/pypi/isodate/
41 :alt: License
42
43
44 This module implements ISO 8601 date, time and duration parsing.
45 The implementation follows ISO8601:2004 standard, and implements only
46 date/time representations mentioned in the standard. If something is not
47 mentioned there, then it is treated as non existent, and not as an allowed
48 option.
49
50 For instance, ISO8601:2004 never mentions 2 digit years. So, it is not
51 intended by this module to support 2 digit years. (while it may still
52 be valid as ISO date, because it is not explicitly forbidden.)
53 Another example is, when no time zone information is given for a time,
54 then it should be interpreted as local time, and not UTC.
55
56 As this module maps ISO 8601 dates/times to standard Python data types, like
57 *date*, *time*, *datetime* and *timedelta*, it is not possible to convert
58 all possible ISO 8601 dates/times. For instance, dates before 0001-01-01 are
59 not allowed by the Python *date* and *datetime* classes. Additionally
60 fractional seconds are limited to microseconds. That means if the parser finds
61 for instance nanoseconds it will round it to microseconds.
62
63 Documentation
64 -------------
65
66 Currently there are four parsing methods available.
67 * parse_time:
68 parses an ISO 8601 time string into a *time* object
69 * parse_date:
70 parses an ISO 8601 date string into a *date* object
71 * parse_datetime:
72 parses an ISO 8601 date-time string into a *datetime* object
73 * parse_duration:
74 parses an ISO 8601 duration string into a *timedelta* or *Duration*
75 object.
76 * parse_tzinfo:
77 parses the time zone info part of an ISO 8601 string into a
78 *tzinfo* object.
79
80 As ISO 8601 allows to define durations in years and months, and *timedelta*
81 does not handle years and months, this module provides a *Duration* class,
82 which can be used almost like a *timedelta* object (with some limitations).
83 However, a *Duration* object can be converted into a *timedelta* object.
84
85 There are also ISO formatting methods for all supported data types. Each
86 *xxx_isoformat* method accepts a format parameter. The default format is
87 always the ISO 8601 expanded format. This is the same format used by
88 *datetime.isoformat*:
89
90 * time_isoformat:
91 Intended to create ISO time strings with default format
92 *hh:mm:ssZ*.
93 * date_isoformat:
94 Intended to create ISO date strings with default format
95 *yyyy-mm-dd*.
96 * datetime_isoformat:
97 Intended to create ISO date-time strings with default format
98 *yyyy-mm-ddThh:mm:ssZ*.
99 * duration_isoformat:
100 Intended to create ISO duration strings with default format
101 *PnnYnnMnnDTnnHnnMnnS*.
102 * tz_isoformat:
103 Intended to create ISO time zone strings with default format
104 *hh:mm*.
105 * strftime:
106 A re-implementation mostly compatible with Python's *strftime*, but
107 supports only those format strings, which can also be used for dates
108 prior 1900. This method also understands how to format *datetime* and
109 *Duration* instances.
110
111 Installation:
112 -------------
113
114 This module can easily be installed with Python standard installation methods.
115
116 Either use *python setup.py install* or in case you have *setuptools* or
117 *distribute* available, you can also use *easy_install*.
118
119 Limitations:
120 ------------
121
122 * The parser accepts several date/time representation which should be invalid
123 according to ISO 8601 standard.
124
125 1. for date and time together, this parser accepts a mixture of basic and extended format.
126 e.g. the date could be in basic format, while the time is accepted in extended format.
127 It also allows short dates and times in date-time strings.
128 2. For incomplete dates, the first day is chosen. e.g. 19th century results in a date of
129 1901-01-01.
130 3. negative *Duration* and *timedelta* value are not fully supported yet.
131
132 Further information:
133 --------------------
134
135 The doc strings and unit tests should provide rather detailed information about
136 the methods and their limitations.
137
138 The source release provides a *setup.py* script,
139 which can be used to run the unit tests included.
140
141 Source code is available at `<http://github.com/gweis/isodate>`_.
142
143 CHANGES
144 =======
145
146 0.6.1 (2021-12-13)
147 ------------------
148
149 - support python 3.10 ()
150 - last version to support py 2.7
151
152
153 0.6.0 (2017-10-13)
154 ------------------
155
156 - support incomplete month date (Fabien Loffredo)
157 - rely on duck typing when doing duration maths
158 - support ':' as separator in fractional time zones (usrenmae)
159
160
161 0.5.4 (2015-08-06)
162 ------------------
163
164 - Fix parsing of Periods (Fabien Bochu)
165 - Make Duration objects hashable (Geoffrey Fairchild)
166 - Add multiplication to duration (Reinoud Elhorst)
167
168
169 0.5.1 (2014-11-07)
170 ------------------
171
172 - fixed pickling of Duration objects
173 - raise ISO8601Error when there is no 'T' separator in datetime strings (Adrian Coveney)
174
175
176 0.5.0 (2014-02-23)
177 ------------------
178
179 - ISO8601Error are subclasses of ValueError now (Michael Hrivnak)
180 - improve compatibility across various python variants and versions
181 - raise exceptions when using fractional years and months in date
182 maths with durations
183 - renamed method todatetime on Duraction objects to totimedelta
184
185
186 0.4.9 (2012-10-30)
187 ------------------
188
189 - support pickling FixedOffset instances
190 - make sure parsed fractional seconds are in microseconds
191 - add leading zeros when formattig microseconds (Jarom Loveridge)
192
193
194 0.4.8 (2012-05-04)
195 ------------------
196
197 - fixed incompatibility of unittests with python 2.5 and 2.6 (runs fine on 2.7
198 and 3.2)
199
200
201 0.4.7 (2012-01-26)
202 ------------------
203
204 - fixed tzinfo formatting (never pass None into tzinfo.utcoffset())
205
206
207 0.4.6 (2012-01-06)
208 ------------------
209
210 - added Python 3 compatibility via 2to3
211
212 0.4.5 (2012-01-06)
213 ------------------
214
215 - made setuptools dependency optional
216
217 0.4.4 (2011-04-16)
218 ------------------
219
220 - Fixed formatting of microseconds for datetime objects
221
222 0.4.3 (2010-10-29)
223 ------------------
224
225 - Fixed problem with %P formating and fractions (supplied by David Brooks)
226
227 0.4.2 (2010-10-28)
228 ------------------
229
230 - Implemented unary - for Duration (supplied by David Brooks)
231 - Output fractional seconds with '%P' format. (partly supplied by David Brooks)
232
233 0.4.1 (2010-10-13)
234 ------------------
235
236 - fixed bug in comparison between timedelta and Duration.
237 - fixed precision problem with microseconds (reported by Tommi Virtanen)
238
239 0.4.0 (2009-02-09)
240 ------------------
241
242 - added method to parse ISO 8601 time zone strings
243 - added methods to create ISO 8601 conforming strings
244
245 0.3.0 (2009-1-05)
246 ------------------
247
248 - Initial release
249
250 TODOs
251 =====
252
253 This to do list contains some thoughts and ideas about missing features, and
254 parts to think about, whether to implement them or not. This list is probably
255 not complete.
256
257 Missing features:
258 -----------------
259
260 * time formating does not allow to create fractional representations.
261 * parser for ISO intervals.
262 * currently microseconds are always padded to a length of 6 characters.
263 trailing 0s should be optional
264
265 Documentation:
266 --------------
267
268 * parse_datetime:
269 - complete documentation to show what this function allows, but ISO forbids.
270 and vice verse.
271 - support other separators between date and time than 'T'
272
273 * parse_date:
274 - yeardigits should be always greater than 4
275 - dates before 0001-01-01 are not supported
276
277 * parse_duration:
278 - alternative formats are not fully supported due to parse_date restrictions
279 - standard duration format is fully supported but not very restrictive.
280
281 * Duration:
282 - support fractional years and month in calculations
283 - implement w3c order relation? (`<http://www.w3.org/TR/xmlschema-2/#duration-order>`_)
284 - refactor to have duration mathematics only at one place.
285 - localize __str__ method (does timedelta do this?)
286 - when is a Duration negative?
287 - normalize Durations. months [00-12] and years ]-inf,+inf[
288
289
3333
3434
3535 setup(name='isodate',
36 version='0.6.0',
36 version='0.6.1',
3737 packages=['isodate', 'isodate.tests'],
3838 package_dir={'': 'src'},
3939
6060 'License :: OSI Approved :: BSD License',
6161 'Operating System :: OS Independent',
6262 'Programming Language :: Python',
63 'Programming Language :: Python :: 2.6',
63 'Programming Language :: Python :: 2',
6464 'Programming Language :: Python :: 2.7',
65 'Programming Language :: Python :: 3.3',
66 'Programming Language :: Python :: 3.4',
67 'Programming Language :: Python :: 3.5',
65 'Programming Language :: Python :: 3',
6866 'Programming Language :: Python :: 3.6',
67 'Programming Language :: Python :: 3.7',
68 'Programming Language :: Python :: 3.8',
69 'Programming Language :: Python :: 3.9',
70 'Programming Language :: Python :: 3.10',
6971 'Programming Language :: Python :: Implementation :: PyPy',
7072 'Topic :: Internet',
7173 ('Topic :: Software Development :'
179179 newday = maxdays
180180 else:
181181 newday = other.day
182 newdt = other.replace(year=newyear, month=newmonth, day=newday)
182 newdt = other.replace(
183 year=int(newyear), month=int(newmonth), day=int(newday)
184 )
183185 # does a timedelta + date/datetime
184186 return self.tdelta + newdt
185187 except AttributeError:
263265 newday = maxdays
264266 else:
265267 newday = other.day
266 newdt = other.replace(year=newyear, month=newmonth, day=newday)
268 newdt = other.replace(
269 year=int(newyear), month=int(newmonth), day=int(newday)
270 )
267271 return newdt - self.tdelta
268272 except AttributeError:
269273 # other probably was not compatible with data/datetime
0 Metadata-Version: 1.1
0 Metadata-Version: 2.1
11 Name: isodate
2 Version: 0.6.0
2 Version: 0.6.1
33 Summary: An ISO 8601 date/time/duration parser and formatter
44 Home-page: https://github.com/gweis/isodate/
55 Author: Gerhard Weis
66 Author-email: gerhard.weis@proclos.com
77 License: BSD
8 Description:
9 ISO 8601 date/time parser
10 =========================
11
12 .. image:: https://travis-ci.org/gweis/isodate.svg?branch=master
13 :target: https://travis-ci.org/gweis/isodate
14 :alt: Travis-CI
15 .. image:: https://coveralls.io/repos/gweis/isodate/badge.svg?branch=master
16 :target: https://coveralls.io/r/gweis/isodate?branch=master
17 :alt: Coveralls
18 .. image:: https://img.shields.io/pypi/v/isodate.svg
19 :target: https://pypi.python.org/pypi/isodate/
20 :alt: Latest Version
21 .. image:: https://img.shields.io/pypi/l/isodate.svg
22 :target: https://pypi.python.org/pypi/isodate/
23 :alt: License
24
25
26 This module implements ISO 8601 date, time and duration parsing.
27 The implementation follows ISO8601:2004 standard, and implements only
28 date/time representations mentioned in the standard. If something is not
29 mentioned there, then it is treated as non existent, and not as an allowed
30 option.
31
32 For instance, ISO8601:2004 never mentions 2 digit years. So, it is not
33 intended by this module to support 2 digit years. (while it may still
34 be valid as ISO date, because it is not explicitly forbidden.)
35 Another example is, when no time zone information is given for a time,
36 then it should be interpreted as local time, and not UTC.
37
38 As this module maps ISO 8601 dates/times to standard Python data types, like
39 *date*, *time*, *datetime* and *timedelta*, it is not possible to convert
40 all possible ISO 8601 dates/times. For instance, dates before 0001-01-01 are
41 not allowed by the Python *date* and *datetime* classes. Additionally
42 fractional seconds are limited to microseconds. That means if the parser finds
43 for instance nanoseconds it will round it to microseconds.
44
45 Documentation
46 -------------
47
48 Currently there are four parsing methods available.
49 * parse_time:
50 parses an ISO 8601 time string into a *time* object
51 * parse_date:
52 parses an ISO 8601 date string into a *date* object
53 * parse_datetime:
54 parses an ISO 8601 date-time string into a *datetime* object
55 * parse_duration:
56 parses an ISO 8601 duration string into a *timedelta* or *Duration*
57 object.
58 * parse_tzinfo:
59 parses the time zone info part of an ISO 8601 string into a
60 *tzinfo* object.
61
62 As ISO 8601 allows to define durations in years and months, and *timedelta*
63 does not handle years and months, this module provides a *Duration* class,
64 which can be used almost like a *timedelta* object (with some limitations).
65 However, a *Duration* object can be converted into a *timedelta* object.
66
67 There are also ISO formatting methods for all supported data types. Each
68 *xxx_isoformat* method accepts a format parameter. The default format is
69 always the ISO 8601 expanded format. This is the same format used by
70 *datetime.isoformat*:
71
72 * time_isoformat:
73 Intended to create ISO time strings with default format
74 *hh:mm:ssZ*.
75 * date_isoformat:
76 Intended to create ISO date strings with default format
77 *yyyy-mm-dd*.
78 * datetime_isoformat:
79 Intended to create ISO date-time strings with default format
80 *yyyy-mm-ddThh:mm:ssZ*.
81 * duration_isoformat:
82 Intended to create ISO duration strings with default format
83 *PnnYnnMnnDTnnHnnMnnS*.
84 * tz_isoformat:
85 Intended to create ISO time zone strings with default format
86 *hh:mm*.
87 * strftime:
88 A re-implementation mostly compatible with Python's *strftime*, but
89 supports only those format strings, which can also be used for dates
90 prior 1900. This method also understands how to format *datetime* and
91 *Duration* instances.
92
93 Installation:
94 -------------
95
96 This module can easily be installed with Python standard installation methods.
97
98 Either use *python setup.py install* or in case you have *setuptools* or
99 *distribute* available, you can also use *easy_install*.
100
101 Limitations:
102 ------------
103
104 * The parser accepts several date/time representation which should be invalid
105 according to ISO 8601 standard.
106
107 1. for date and time together, this parser accepts a mixture of basic and extended format.
108 e.g. the date could be in basic format, while the time is accepted in extended format.
109 It also allows short dates and times in date-time strings.
110 2. For incomplete dates, the first day is chosen. e.g. 19th century results in a date of
111 1901-01-01.
112 3. negative *Duration* and *timedelta* value are not fully supported yet.
113
114 Further information:
115 --------------------
116
117 The doc strings and unit tests should provide rather detailed information about
118 the methods and their limitations.
119
120 The source release provides a *setup.py* script,
121 which can be used to run the unit tests included.
122
123 Source code is available at `<http://github.com/gweis/isodate>`_.
124
125 CHANGES
126 =======
127
128 0.6.0 (2017-10-13)
129 ------------------
130
131 - support incomplete month date (Fabien Loffredo)
132 - rely on duck typing when doing duration maths
133 - support ':' as separator in fractional time zones (usrenmae)
134
135
136 0.5.4 (2015-08-06)
137 ------------------
138
139 - Fix parsing of Periods (Fabien Bochu)
140 - Make Duration objects hashable (Geoffrey Fairchild)
141 - Add multiplication to duration (Reinoud Elhorst)
142
143
144 0.5.1 (2014-11-07)
145 ------------------
146
147 - fixed pickling of Duration objects
148 - raise ISO8601Error when there is no 'T' separator in datetime strings (Adrian Coveney)
149
150
151 0.5.0 (2014-02-23)
152 ------------------
153
154 - ISO8601Error are subclasses of ValueError now (Michael Hrivnak)
155 - improve compatibility across various python variants and versions
156 - raise exceptions when using fractional years and months in date
157 maths with durations
158 - renamed method todatetime on Duraction objects to totimedelta
159
160
161 0.4.9 (2012-10-30)
162 ------------------
163
164 - support pickling FixedOffset instances
165 - make sure parsed fractional seconds are in microseconds
166 - add leading zeros when formattig microseconds (Jarom Loveridge)
167
168
169 0.4.8 (2012-05-04)
170 ------------------
171
172 - fixed incompatibility of unittests with python 2.5 and 2.6 (runs fine on 2.7
173 and 3.2)
174
175
176 0.4.7 (2012-01-26)
177 ------------------
178
179 - fixed tzinfo formatting (never pass None into tzinfo.utcoffset())
180
181
182 0.4.6 (2012-01-06)
183 ------------------
184
185 - added Python 3 compatibility via 2to3
186
187 0.4.5 (2012-01-06)
188 ------------------
189
190 - made setuptools dependency optional
191
192 0.4.4 (2011-04-16)
193 ------------------
194
195 - Fixed formatting of microseconds for datetime objects
196
197 0.4.3 (2010-10-29)
198 ------------------
199
200 - Fixed problem with %P formating and fractions (supplied by David Brooks)
201
202 0.4.2 (2010-10-28)
203 ------------------
204
205 - Implemented unary - for Duration (supplied by David Brooks)
206 - Output fractional seconds with '%P' format. (partly supplied by David Brooks)
207
208 0.4.1 (2010-10-13)
209 ------------------
210
211 - fixed bug in comparison between timedelta and Duration.
212 - fixed precision problem with microseconds (reported by Tommi Virtanen)
213
214 0.4.0 (2009-02-09)
215 ------------------
216
217 - added method to parse ISO 8601 time zone strings
218 - added methods to create ISO 8601 conforming strings
219
220 0.3.0 (2009-1-05)
221 ------------------
222
223 - Initial release
224
225 TODOs
226 =====
227
228 This to do list contains some thoughts and ideas about missing features, and
229 parts to think about, whether to implement them or not. This list is probably
230 not complete.
231
232 Missing features:
233 -----------------
234
235 * time formating does not allow to create fractional representations.
236 * parser for ISO intervals.
237 * currently microseconds are always padded to a length of 6 characters.
238 trailing 0s should be optional
239
240 Documentation:
241 --------------
242
243 * parse_datetime:
244 - complete documentation to show what this function allows, but ISO forbids.
245 and vice verse.
246 - support other separators between date and time than 'T'
247
248 * parse_date:
249 - yeardigits should be always greater than 4
250 - dates before 0001-01-01 are not supported
251
252 * parse_duration:
253 - alternative formats are not fully supported due to parse_date restrictions
254 - standard duration format is fully supported but not very restrictive.
255
256 * Duration:
257 - support fractional years and month in calculations
258 - implement w3c order relation? (`<http://www.w3.org/TR/xmlschema-2/#duration-order>`_)
259 - refactor to have duration mathematics only at one place.
260 - localize __str__ method (does timedelta do this?)
261 - when is a Duration negative?
262 - normalize Durations. months [00-12] and years ]-inf,+inf[
263
2648 Platform: UNKNOWN
2659 Classifier: Development Status :: 4 - Beta
26610 Classifier: Intended Audience :: Developers
26711 Classifier: License :: OSI Approved :: BSD License
26812 Classifier: Operating System :: OS Independent
26913 Classifier: Programming Language :: Python
270 Classifier: Programming Language :: Python :: 2.6
14 Classifier: Programming Language :: Python :: 2
27115 Classifier: Programming Language :: Python :: 2.7
272 Classifier: Programming Language :: Python :: 3.3
273 Classifier: Programming Language :: Python :: 3.4
274 Classifier: Programming Language :: Python :: 3.5
16 Classifier: Programming Language :: Python :: 3
27517 Classifier: Programming Language :: Python :: 3.6
18 Classifier: Programming Language :: Python :: 3.7
19 Classifier: Programming Language :: Python :: 3.8
20 Classifier: Programming Language :: Python :: 3.9
21 Classifier: Programming Language :: Python :: 3.10
27622 Classifier: Programming Language :: Python :: Implementation :: PyPy
27723 Classifier: Topic :: Internet
27824 Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
26
27 ISO 8601 date/time parser
28 =========================
29
30 .. image:: https://travis-ci.org/gweis/isodate.svg?branch=master
31 :target: https://travis-ci.org/gweis/isodate
32 :alt: Travis-CI
33 .. image:: https://coveralls.io/repos/gweis/isodate/badge.svg?branch=master
34 :target: https://coveralls.io/r/gweis/isodate?branch=master
35 :alt: Coveralls
36 .. image:: https://img.shields.io/pypi/v/isodate.svg
37 :target: https://pypi.python.org/pypi/isodate/
38 :alt: Latest Version
39 .. image:: https://img.shields.io/pypi/l/isodate.svg
40 :target: https://pypi.python.org/pypi/isodate/
41 :alt: License
42
43
44 This module implements ISO 8601 date, time and duration parsing.
45 The implementation follows ISO8601:2004 standard, and implements only
46 date/time representations mentioned in the standard. If something is not
47 mentioned there, then it is treated as non existent, and not as an allowed
48 option.
49
50 For instance, ISO8601:2004 never mentions 2 digit years. So, it is not
51 intended by this module to support 2 digit years. (while it may still
52 be valid as ISO date, because it is not explicitly forbidden.)
53 Another example is, when no time zone information is given for a time,
54 then it should be interpreted as local time, and not UTC.
55
56 As this module maps ISO 8601 dates/times to standard Python data types, like
57 *date*, *time*, *datetime* and *timedelta*, it is not possible to convert
58 all possible ISO 8601 dates/times. For instance, dates before 0001-01-01 are
59 not allowed by the Python *date* and *datetime* classes. Additionally
60 fractional seconds are limited to microseconds. That means if the parser finds
61 for instance nanoseconds it will round it to microseconds.
62
63 Documentation
64 -------------
65
66 Currently there are four parsing methods available.
67 * parse_time:
68 parses an ISO 8601 time string into a *time* object
69 * parse_date:
70 parses an ISO 8601 date string into a *date* object
71 * parse_datetime:
72 parses an ISO 8601 date-time string into a *datetime* object
73 * parse_duration:
74 parses an ISO 8601 duration string into a *timedelta* or *Duration*
75 object.
76 * parse_tzinfo:
77 parses the time zone info part of an ISO 8601 string into a
78 *tzinfo* object.
79
80 As ISO 8601 allows to define durations in years and months, and *timedelta*
81 does not handle years and months, this module provides a *Duration* class,
82 which can be used almost like a *timedelta* object (with some limitations).
83 However, a *Duration* object can be converted into a *timedelta* object.
84
85 There are also ISO formatting methods for all supported data types. Each
86 *xxx_isoformat* method accepts a format parameter. The default format is
87 always the ISO 8601 expanded format. This is the same format used by
88 *datetime.isoformat*:
89
90 * time_isoformat:
91 Intended to create ISO time strings with default format
92 *hh:mm:ssZ*.
93 * date_isoformat:
94 Intended to create ISO date strings with default format
95 *yyyy-mm-dd*.
96 * datetime_isoformat:
97 Intended to create ISO date-time strings with default format
98 *yyyy-mm-ddThh:mm:ssZ*.
99 * duration_isoformat:
100 Intended to create ISO duration strings with default format
101 *PnnYnnMnnDTnnHnnMnnS*.
102 * tz_isoformat:
103 Intended to create ISO time zone strings with default format
104 *hh:mm*.
105 * strftime:
106 A re-implementation mostly compatible with Python's *strftime*, but
107 supports only those format strings, which can also be used for dates
108 prior 1900. This method also understands how to format *datetime* and
109 *Duration* instances.
110
111 Installation:
112 -------------
113
114 This module can easily be installed with Python standard installation methods.
115
116 Either use *python setup.py install* or in case you have *setuptools* or
117 *distribute* available, you can also use *easy_install*.
118
119 Limitations:
120 ------------
121
122 * The parser accepts several date/time representation which should be invalid
123 according to ISO 8601 standard.
124
125 1. for date and time together, this parser accepts a mixture of basic and extended format.
126 e.g. the date could be in basic format, while the time is accepted in extended format.
127 It also allows short dates and times in date-time strings.
128 2. For incomplete dates, the first day is chosen. e.g. 19th century results in a date of
129 1901-01-01.
130 3. negative *Duration* and *timedelta* value are not fully supported yet.
131
132 Further information:
133 --------------------
134
135 The doc strings and unit tests should provide rather detailed information about
136 the methods and their limitations.
137
138 The source release provides a *setup.py* script,
139 which can be used to run the unit tests included.
140
141 Source code is available at `<http://github.com/gweis/isodate>`_.
142
143 CHANGES
144 =======
145
146 0.6.1 (2021-12-13)
147 ------------------
148
149 - support python 3.10 ()
150 - last version to support py 2.7
151
152
153 0.6.0 (2017-10-13)
154 ------------------
155
156 - support incomplete month date (Fabien Loffredo)
157 - rely on duck typing when doing duration maths
158 - support ':' as separator in fractional time zones (usrenmae)
159
160
161 0.5.4 (2015-08-06)
162 ------------------
163
164 - Fix parsing of Periods (Fabien Bochu)
165 - Make Duration objects hashable (Geoffrey Fairchild)
166 - Add multiplication to duration (Reinoud Elhorst)
167
168
169 0.5.1 (2014-11-07)
170 ------------------
171
172 - fixed pickling of Duration objects
173 - raise ISO8601Error when there is no 'T' separator in datetime strings (Adrian Coveney)
174
175
176 0.5.0 (2014-02-23)
177 ------------------
178
179 - ISO8601Error are subclasses of ValueError now (Michael Hrivnak)
180 - improve compatibility across various python variants and versions
181 - raise exceptions when using fractional years and months in date
182 maths with durations
183 - renamed method todatetime on Duraction objects to totimedelta
184
185
186 0.4.9 (2012-10-30)
187 ------------------
188
189 - support pickling FixedOffset instances
190 - make sure parsed fractional seconds are in microseconds
191 - add leading zeros when formattig microseconds (Jarom Loveridge)
192
193
194 0.4.8 (2012-05-04)
195 ------------------
196
197 - fixed incompatibility of unittests with python 2.5 and 2.6 (runs fine on 2.7
198 and 3.2)
199
200
201 0.4.7 (2012-01-26)
202 ------------------
203
204 - fixed tzinfo formatting (never pass None into tzinfo.utcoffset())
205
206
207 0.4.6 (2012-01-06)
208 ------------------
209
210 - added Python 3 compatibility via 2to3
211
212 0.4.5 (2012-01-06)
213 ------------------
214
215 - made setuptools dependency optional
216
217 0.4.4 (2011-04-16)
218 ------------------
219
220 - Fixed formatting of microseconds for datetime objects
221
222 0.4.3 (2010-10-29)
223 ------------------
224
225 - Fixed problem with %P formating and fractions (supplied by David Brooks)
226
227 0.4.2 (2010-10-28)
228 ------------------
229
230 - Implemented unary - for Duration (supplied by David Brooks)
231 - Output fractional seconds with '%P' format. (partly supplied by David Brooks)
232
233 0.4.1 (2010-10-13)
234 ------------------
235
236 - fixed bug in comparison between timedelta and Duration.
237 - fixed precision problem with microseconds (reported by Tommi Virtanen)
238
239 0.4.0 (2009-02-09)
240 ------------------
241
242 - added method to parse ISO 8601 time zone strings
243 - added methods to create ISO 8601 conforming strings
244
245 0.3.0 (2009-1-05)
246 ------------------
247
248 - Initial release
249
250 TODOs
251 =====
252
253 This to do list contains some thoughts and ideas about missing features, and
254 parts to think about, whether to implement them or not. This list is probably
255 not complete.
256
257 Missing features:
258 -----------------
259
260 * time formating does not allow to create fractional representations.
261 * parser for ISO intervals.
262 * currently microseconds are always padded to a length of 6 characters.
263 trailing 0s should be optional
264
265 Documentation:
266 --------------
267
268 * parse_datetime:
269 - complete documentation to show what this function allows, but ISO forbids.
270 and vice verse.
271 - support other separators between date and time than 'T'
272
273 * parse_date:
274 - yeardigits should be always greater than 4
275 - dates before 0001-01-01 are not supported
276
277 * parse_duration:
278 - alternative formats are not fully supported due to parse_date restrictions
279 - standard duration format is fully supported but not very restrictive.
280
281 * Duration:
282 - support fractional years and month in calculations
283 - implement w3c order relation? (`<http://www.w3.org/TR/xmlschema-2/#duration-order>`_)
284 - refactor to have duration mathematics only at one place.
285 - localize __str__ method (does timedelta do this?)
286 - when is a Duration negative?
287 - normalize Durations. months [00-12] and years ]-inf,+inf[
288
289