jpayne@69
|
1 Metadata-Version: 2.1
|
jpayne@69
|
2 Name: DateTime
|
jpayne@69
|
3 Version: 5.5
|
jpayne@69
|
4 Summary: This package provides a DateTime data type, as known from Zope. Unless you need to communicate with Zope APIs, you're probably better off using Python's built-in datetime module.
|
jpayne@69
|
5 Home-page: https://github.com/zopefoundation/DateTime
|
jpayne@69
|
6 Author: Zope Foundation and Contributors
|
jpayne@69
|
7 Author-email: zope-dev@zope.org
|
jpayne@69
|
8 License: ZPL 2.1
|
jpayne@69
|
9 Classifier: Development Status :: 6 - Mature
|
jpayne@69
|
10 Classifier: Environment :: Web Environment
|
jpayne@69
|
11 Classifier: Framework :: Zope :: 4
|
jpayne@69
|
12 Classifier: License :: OSI Approved :: Zope Public License
|
jpayne@69
|
13 Classifier: Operating System :: OS Independent
|
jpayne@69
|
14 Classifier: Programming Language :: Python
|
jpayne@69
|
15 Classifier: Programming Language :: Python :: 3
|
jpayne@69
|
16 Classifier: Programming Language :: Python :: 3.7
|
jpayne@69
|
17 Classifier: Programming Language :: Python :: 3.8
|
jpayne@69
|
18 Classifier: Programming Language :: Python :: 3.9
|
jpayne@69
|
19 Classifier: Programming Language :: Python :: 3.10
|
jpayne@69
|
20 Classifier: Programming Language :: Python :: 3.11
|
jpayne@69
|
21 Classifier: Programming Language :: Python :: 3.12
|
jpayne@69
|
22 Classifier: Programming Language :: Python :: Implementation :: CPython
|
jpayne@69
|
23 Classifier: Programming Language :: Python :: Implementation :: PyPy
|
jpayne@69
|
24 Requires-Python: >=3.7
|
jpayne@69
|
25 License-File: LICENSE.txt
|
jpayne@69
|
26 Requires-Dist: zope.interface
|
jpayne@69
|
27 Requires-Dist: pytz
|
jpayne@69
|
28
|
jpayne@69
|
29 .. image:: https://github.com/zopefoundation/DateTime/workflows/tests/badge.svg
|
jpayne@69
|
30 :target: https://github.com/zopefoundation/DateTime/actions?query=workflow%3Atests
|
jpayne@69
|
31 :alt: CI status
|
jpayne@69
|
32
|
jpayne@69
|
33 .. image:: https://img.shields.io/pypi/v/DateTime.svg
|
jpayne@69
|
34 :target: https://pypi.org/project/DateTime/
|
jpayne@69
|
35 :alt: Current version on PyPI
|
jpayne@69
|
36
|
jpayne@69
|
37 .. image:: https://img.shields.io/pypi/pyversions/DateTime.svg
|
jpayne@69
|
38 :target: https://pypi.org/project/DateTime/
|
jpayne@69
|
39 :alt: Supported Python versions
|
jpayne@69
|
40
|
jpayne@69
|
41
|
jpayne@69
|
42 DateTime
|
jpayne@69
|
43 ========
|
jpayne@69
|
44
|
jpayne@69
|
45 This package provides a DateTime data type, as known from Zope.
|
jpayne@69
|
46
|
jpayne@69
|
47 Unless you need to communicate with Zope APIs, you're probably better
|
jpayne@69
|
48 off using Python's built-in datetime module.
|
jpayne@69
|
49
|
jpayne@69
|
50 For further documentation, please have a look at `src/DateTime/DateTime.txt`.
|
jpayne@69
|
51
|
jpayne@69
|
52
|
jpayne@69
|
53 .. contents::
|
jpayne@69
|
54
|
jpayne@69
|
55 The DateTime package
|
jpayne@69
|
56 ====================
|
jpayne@69
|
57
|
jpayne@69
|
58 Encapsulation of date/time values.
|
jpayne@69
|
59
|
jpayne@69
|
60
|
jpayne@69
|
61 Function Timezones()
|
jpayne@69
|
62 --------------------
|
jpayne@69
|
63
|
jpayne@69
|
64 Returns the list of recognized timezone names:
|
jpayne@69
|
65
|
jpayne@69
|
66 >>> from DateTime import Timezones
|
jpayne@69
|
67 >>> zones = set(Timezones())
|
jpayne@69
|
68
|
jpayne@69
|
69 Almost all of the standard pytz timezones are included, with the exception
|
jpayne@69
|
70 of some commonly-used but ambiguous abbreviations, where historical Zope
|
jpayne@69
|
71 usage conflicts with the name used by pytz:
|
jpayne@69
|
72
|
jpayne@69
|
73 >>> import pytz
|
jpayne@69
|
74 >>> [x for x in pytz.all_timezones if x not in zones]
|
jpayne@69
|
75 ['CET', 'EET', 'EST', 'MET', 'MST', 'WET']
|
jpayne@69
|
76
|
jpayne@69
|
77 Class DateTime
|
jpayne@69
|
78 --------------
|
jpayne@69
|
79
|
jpayne@69
|
80 DateTime objects represent instants in time and provide interfaces for
|
jpayne@69
|
81 controlling its representation without affecting the absolute value of
|
jpayne@69
|
82 the object.
|
jpayne@69
|
83
|
jpayne@69
|
84 DateTime objects may be created from a wide variety of string or
|
jpayne@69
|
85 numeric data, or may be computed from other DateTime objects.
|
jpayne@69
|
86 DateTimes support the ability to convert their representations to many
|
jpayne@69
|
87 major timezones, as well as the ability to create a DateTime object
|
jpayne@69
|
88 in the context of a given timezone.
|
jpayne@69
|
89
|
jpayne@69
|
90 DateTime objects provide partial numerical behavior:
|
jpayne@69
|
91
|
jpayne@69
|
92 * Two date-time objects can be subtracted to obtain a time, in days
|
jpayne@69
|
93 between the two.
|
jpayne@69
|
94
|
jpayne@69
|
95 * A date-time object and a positive or negative number may be added to
|
jpayne@69
|
96 obtain a new date-time object that is the given number of days later
|
jpayne@69
|
97 than the input date-time object.
|
jpayne@69
|
98
|
jpayne@69
|
99 * A positive or negative number and a date-time object may be added to
|
jpayne@69
|
100 obtain a new date-time object that is the given number of days later
|
jpayne@69
|
101 than the input date-time object.
|
jpayne@69
|
102
|
jpayne@69
|
103 * A positive or negative number may be subtracted from a date-time
|
jpayne@69
|
104 object to obtain a new date-time object that is the given number of
|
jpayne@69
|
105 days earlier than the input date-time object.
|
jpayne@69
|
106
|
jpayne@69
|
107 DateTime objects may be converted to integer, long, or float numbers
|
jpayne@69
|
108 of days since January 1, 1901, using the standard int, long, and float
|
jpayne@69
|
109 functions (Compatibility Note: int, long and float return the number
|
jpayne@69
|
110 of days since 1901 in GMT rather than local machine timezone).
|
jpayne@69
|
111 DateTime objects also provide access to their value in a float format
|
jpayne@69
|
112 usable with the Python time module, provided that the value of the
|
jpayne@69
|
113 object falls in the range of the epoch-based time module.
|
jpayne@69
|
114
|
jpayne@69
|
115 A DateTime object should be considered immutable; all conversion and numeric
|
jpayne@69
|
116 operations return a new DateTime object rather than modify the current object.
|
jpayne@69
|
117
|
jpayne@69
|
118 A DateTime object always maintains its value as an absolute UTC time,
|
jpayne@69
|
119 and is represented in the context of some timezone based on the
|
jpayne@69
|
120 arguments used to create the object. A DateTime object's methods
|
jpayne@69
|
121 return values based on the timezone context.
|
jpayne@69
|
122
|
jpayne@69
|
123 Note that in all cases the local machine timezone is used for
|
jpayne@69
|
124 representation if no timezone is specified.
|
jpayne@69
|
125
|
jpayne@69
|
126 Constructor for DateTime
|
jpayne@69
|
127 ------------------------
|
jpayne@69
|
128
|
jpayne@69
|
129 DateTime() returns a new date-time object. DateTimes may be created
|
jpayne@69
|
130 with from zero to seven arguments:
|
jpayne@69
|
131
|
jpayne@69
|
132 * If the function is called with no arguments, then the current date/
|
jpayne@69
|
133 time is returned, represented in the timezone of the local machine.
|
jpayne@69
|
134
|
jpayne@69
|
135 * If the function is invoked with a single string argument which is a
|
jpayne@69
|
136 recognized timezone name, an object representing the current time is
|
jpayne@69
|
137 returned, represented in the specified timezone.
|
jpayne@69
|
138
|
jpayne@69
|
139 * If the function is invoked with a single string argument
|
jpayne@69
|
140 representing a valid date/time, an object representing that date/
|
jpayne@69
|
141 time will be returned.
|
jpayne@69
|
142
|
jpayne@69
|
143 As a general rule, any date-time representation that is recognized
|
jpayne@69
|
144 and unambiguous to a resident of North America is acceptable. (The
|
jpayne@69
|
145 reason for this qualification is that in North America, a date like:
|
jpayne@69
|
146 2/1/1994 is interpreted as February 1, 1994, while in some parts of
|
jpayne@69
|
147 the world, it is interpreted as January 2, 1994.) A date/ time
|
jpayne@69
|
148 string consists of two components, a date component and an optional
|
jpayne@69
|
149 time component, separated by one or more spaces. If the time
|
jpayne@69
|
150 component is omitted, 12:00am is assumed.
|
jpayne@69
|
151
|
jpayne@69
|
152 Any recognized timezone name specified as the final element of the
|
jpayne@69
|
153 date/time string will be used for computing the date/time value.
|
jpayne@69
|
154 (If you create a DateTime with the string,
|
jpayne@69
|
155 "Mar 9, 1997 1:45pm US/Pacific", the value will essentially be the
|
jpayne@69
|
156 same as if you had captured time.time() at the specified date and
|
jpayne@69
|
157 time on a machine in that timezone). If no timezone is passed, then
|
jpayne@69
|
158 the timezone configured on the local machine will be used, **except**
|
jpayne@69
|
159 that if the date format matches ISO 8601 ('YYYY-MM-DD'), the instance
|
jpayne@69
|
160 will use UTC / GMT+0 as the timezone.
|
jpayne@69
|
161
|
jpayne@69
|
162 o Returns current date/time, represented in US/Eastern:
|
jpayne@69
|
163
|
jpayne@69
|
164 >>> from DateTime import DateTime
|
jpayne@69
|
165 >>> e = DateTime('US/Eastern')
|
jpayne@69
|
166 >>> e.timezone()
|
jpayne@69
|
167 'US/Eastern'
|
jpayne@69
|
168
|
jpayne@69
|
169 o Returns specified time, represented in local machine zone:
|
jpayne@69
|
170
|
jpayne@69
|
171 >>> x = DateTime('1997/3/9 1:45pm')
|
jpayne@69
|
172 >>> x.parts() # doctest: +ELLIPSIS
|
jpayne@69
|
173 (1997, 3, 9, 13, 45, ...)
|
jpayne@69
|
174
|
jpayne@69
|
175 o Specified time in local machine zone, verbose format:
|
jpayne@69
|
176
|
jpayne@69
|
177 >>> y = DateTime('Mar 9, 1997 13:45:00')
|
jpayne@69
|
178 >>> y.parts() # doctest: +ELLIPSIS
|
jpayne@69
|
179 (1997, 3, 9, 13, 45, ...)
|
jpayne@69
|
180 >>> y == x
|
jpayne@69
|
181 True
|
jpayne@69
|
182
|
jpayne@69
|
183 o Specified time in UTC via ISO 8601 rule:
|
jpayne@69
|
184
|
jpayne@69
|
185 >>> z = DateTime('2014-03-24')
|
jpayne@69
|
186 >>> z.parts() # doctest: +ELLIPSIS
|
jpayne@69
|
187 (2014, 3, 24, 0, 0, ...)
|
jpayne@69
|
188 >>> z.timezone()
|
jpayne@69
|
189 'GMT+0'
|
jpayne@69
|
190
|
jpayne@69
|
191 The date component consists of year, month, and day values. The
|
jpayne@69
|
192 year value must be a one-, two-, or four-digit integer. If a one-
|
jpayne@69
|
193 or two-digit year is used, the year is assumed to be in the
|
jpayne@69
|
194 twentieth century. The month may an integer, from 1 to 12, a month
|
jpayne@69
|
195 name, or a month abbreviation, where a period may optionally follow
|
jpayne@69
|
196 the abbreviation. The day must be an integer from 1 to the number of
|
jpayne@69
|
197 days in the month. The year, month, and day values may be separated
|
jpayne@69
|
198 by periods, hyphens, forward slashes, or spaces. Extra spaces are
|
jpayne@69
|
199 permitted around the delimiters. Year, month, and day values may be
|
jpayne@69
|
200 given in any order as long as it is possible to distinguish the
|
jpayne@69
|
201 components. If all three components are numbers that are less than
|
jpayne@69
|
202 13, then a month-day-year ordering is assumed.
|
jpayne@69
|
203
|
jpayne@69
|
204 The time component consists of hour, minute, and second values
|
jpayne@69
|
205 separated by colons. The hour value must be an integer between 0
|
jpayne@69
|
206 and 23 inclusively. The minute value must be an integer between 0
|
jpayne@69
|
207 and 59 inclusively. The second value may be an integer value
|
jpayne@69
|
208 between 0 and 59.999 inclusively. The second value or both the
|
jpayne@69
|
209 minute and second values may be omitted. The time may be followed
|
jpayne@69
|
210 by am or pm in upper or lower case, in which case a 12-hour clock is
|
jpayne@69
|
211 assumed.
|
jpayne@69
|
212
|
jpayne@69
|
213 * If the DateTime function is invoked with a single numeric argument,
|
jpayne@69
|
214 the number is assumed to be either a floating point value such as
|
jpayne@69
|
215 that returned by time.time(), or a number of days after January 1,
|
jpayne@69
|
216 1901 00:00:00 UTC.
|
jpayne@69
|
217
|
jpayne@69
|
218 A DateTime object is returned that represents either the GMT value
|
jpayne@69
|
219 of the time.time() float represented in the local machine's
|
jpayne@69
|
220 timezone, or that number of days after January 1, 1901. Note that
|
jpayne@69
|
221 the number of days after 1901 need to be expressed from the
|
jpayne@69
|
222 viewpoint of the local machine's timezone. A negative argument will
|
jpayne@69
|
223 yield a date-time value before 1901.
|
jpayne@69
|
224
|
jpayne@69
|
225 * If the function is invoked with two numeric arguments, then the
|
jpayne@69
|
226 first is taken to be an integer year and the second argument is
|
jpayne@69
|
227 taken to be an offset in days from the beginning of the year, in the
|
jpayne@69
|
228 context of the local machine timezone. The date-time value returned
|
jpayne@69
|
229 is the given offset number of days from the beginning of the given
|
jpayne@69
|
230 year, represented in the timezone of the local machine. The offset
|
jpayne@69
|
231 may be positive or negative. Two-digit years are assumed to be in
|
jpayne@69
|
232 the twentieth century.
|
jpayne@69
|
233
|
jpayne@69
|
234 * If the function is invoked with two arguments, the first a float
|
jpayne@69
|
235 representing a number of seconds past the epoch in GMT (such as
|
jpayne@69
|
236 those returned by time.time()) and the second a string naming a
|
jpayne@69
|
237 recognized timezone, a DateTime with a value of that GMT time will
|
jpayne@69
|
238 be returned, represented in the given timezone.
|
jpayne@69
|
239
|
jpayne@69
|
240 >>> import time
|
jpayne@69
|
241 >>> t = time.time()
|
jpayne@69
|
242
|
jpayne@69
|
243 Time t represented as US/Eastern:
|
jpayne@69
|
244
|
jpayne@69
|
245 >>> now_east = DateTime(t, 'US/Eastern')
|
jpayne@69
|
246
|
jpayne@69
|
247 Time t represented as US/Pacific:
|
jpayne@69
|
248
|
jpayne@69
|
249 >>> now_west = DateTime(t, 'US/Pacific')
|
jpayne@69
|
250
|
jpayne@69
|
251 Only their representations are different:
|
jpayne@69
|
252
|
jpayne@69
|
253 >>> now_east.equalTo(now_west)
|
jpayne@69
|
254 True
|
jpayne@69
|
255
|
jpayne@69
|
256 * If the function is invoked with three or more numeric arguments,
|
jpayne@69
|
257 then the first is taken to be an integer year, the second is taken
|
jpayne@69
|
258 to be an integer month, and the third is taken to be an integer day.
|
jpayne@69
|
259 If the combination of values is not valid, then a DateTimeError is
|
jpayne@69
|
260 raised. One- or two-digit years up to 69 are assumed to be in the
|
jpayne@69
|
261 21st century, whereas values 70-99 are assumed to be 20th century.
|
jpayne@69
|
262 The fourth, fifth, and sixth arguments are floating point, positive
|
jpayne@69
|
263 or negative offsets in units of hours, minutes, and days, and
|
jpayne@69
|
264 default to zero if not given. An optional string may be given as
|
jpayne@69
|
265 the final argument to indicate timezone (the effect of this is as if
|
jpayne@69
|
266 you had taken the value of time.time() at that time on a machine in
|
jpayne@69
|
267 the specified timezone).
|
jpayne@69
|
268
|
jpayne@69
|
269 If a string argument passed to the DateTime constructor cannot be
|
jpayne@69
|
270 parsed, it will raise SyntaxError. Invalid date, time, or
|
jpayne@69
|
271 timezone components will raise a DateTimeError.
|
jpayne@69
|
272
|
jpayne@69
|
273 The module function Timezones() will return a list of the timezones
|
jpayne@69
|
274 recognized by the DateTime module. Recognition of timezone names is
|
jpayne@69
|
275 case-insensitive.
|
jpayne@69
|
276
|
jpayne@69
|
277 Instance Methods for DateTime (IDateTime interface)
|
jpayne@69
|
278 ---------------------------------------------------
|
jpayne@69
|
279
|
jpayne@69
|
280 Conversion and comparison methods
|
jpayne@69
|
281 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
jpayne@69
|
282
|
jpayne@69
|
283 * ``timeTime()`` returns the date/time as a floating-point number in
|
jpayne@69
|
284 UTC, in the format used by the Python time module. Note that it is
|
jpayne@69
|
285 possible to create date /time values with DateTime that have no
|
jpayne@69
|
286 meaningful value to the time module, and in such cases a
|
jpayne@69
|
287 DateTimeError is raised. A DateTime object's value must generally
|
jpayne@69
|
288 be between Jan 1, 1970 (or your local machine epoch) and Jan 2038 to
|
jpayne@69
|
289 produce a valid time.time() style value.
|
jpayne@69
|
290
|
jpayne@69
|
291 >>> dt = DateTime('Mar 9, 1997 13:45:00 US/Eastern')
|
jpayne@69
|
292 >>> dt.timeTime()
|
jpayne@69
|
293 857933100.0
|
jpayne@69
|
294
|
jpayne@69
|
295 >>> DateTime('2040/01/01 UTC').timeTime()
|
jpayne@69
|
296 2208988800.0
|
jpayne@69
|
297
|
jpayne@69
|
298 >>> DateTime('1900/01/01 UTC').timeTime()
|
jpayne@69
|
299 -2208988800.0
|
jpayne@69
|
300
|
jpayne@69
|
301 * ``toZone(z)`` returns a DateTime with the value as the current
|
jpayne@69
|
302 object, represented in the indicated timezone:
|
jpayne@69
|
303
|
jpayne@69
|
304 >>> dt.toZone('UTC')
|
jpayne@69
|
305 DateTime('1997/03/09 18:45:00 UTC')
|
jpayne@69
|
306
|
jpayne@69
|
307 >>> dt.toZone('UTC').equalTo(dt)
|
jpayne@69
|
308 True
|
jpayne@69
|
309
|
jpayne@69
|
310 * ``isFuture()`` returns true if this object represents a date/time
|
jpayne@69
|
311 later than the time of the call:
|
jpayne@69
|
312
|
jpayne@69
|
313 >>> dt.isFuture()
|
jpayne@69
|
314 False
|
jpayne@69
|
315 >>> DateTime('Jan 1 3000').isFuture() # not time-machine safe!
|
jpayne@69
|
316 True
|
jpayne@69
|
317
|
jpayne@69
|
318 * ``isPast()`` returns true if this object represents a date/time
|
jpayne@69
|
319 earlier than the time of the call:
|
jpayne@69
|
320
|
jpayne@69
|
321 >>> dt.isPast()
|
jpayne@69
|
322 True
|
jpayne@69
|
323 >>> DateTime('Jan 1 3000').isPast() # not time-machine safe!
|
jpayne@69
|
324 False
|
jpayne@69
|
325
|
jpayne@69
|
326 * ``isCurrentYear()`` returns true if this object represents a
|
jpayne@69
|
327 date/time that falls within the current year, in the context of this
|
jpayne@69
|
328 object's timezone representation:
|
jpayne@69
|
329
|
jpayne@69
|
330 >>> dt.isCurrentYear()
|
jpayne@69
|
331 False
|
jpayne@69
|
332 >>> DateTime().isCurrentYear()
|
jpayne@69
|
333 True
|
jpayne@69
|
334
|
jpayne@69
|
335 * ``isCurrentMonth()`` returns true if this object represents a
|
jpayne@69
|
336 date/time that falls within the current month, in the context of
|
jpayne@69
|
337 this object's timezone representation:
|
jpayne@69
|
338
|
jpayne@69
|
339 >>> dt.isCurrentMonth()
|
jpayne@69
|
340 False
|
jpayne@69
|
341 >>> DateTime().isCurrentMonth()
|
jpayne@69
|
342 True
|
jpayne@69
|
343
|
jpayne@69
|
344 * ``isCurrentDay()`` returns true if this object represents a
|
jpayne@69
|
345 date/time that falls within the current day, in the context of this
|
jpayne@69
|
346 object's timezone representation:
|
jpayne@69
|
347
|
jpayne@69
|
348 >>> dt.isCurrentDay()
|
jpayne@69
|
349 False
|
jpayne@69
|
350 >>> DateTime().isCurrentDay()
|
jpayne@69
|
351 True
|
jpayne@69
|
352
|
jpayne@69
|
353 * ``isCurrentHour()`` returns true if this object represents a
|
jpayne@69
|
354 date/time that falls within the current hour, in the context of this
|
jpayne@69
|
355 object's timezone representation:
|
jpayne@69
|
356
|
jpayne@69
|
357 >>> dt.isCurrentHour()
|
jpayne@69
|
358 False
|
jpayne@69
|
359
|
jpayne@69
|
360 >>> DateTime().isCurrentHour()
|
jpayne@69
|
361 True
|
jpayne@69
|
362
|
jpayne@69
|
363 * ``isCurrentMinute()`` returns true if this object represents a
|
jpayne@69
|
364 date/time that falls within the current minute, in the context of
|
jpayne@69
|
365 this object's timezone representation:
|
jpayne@69
|
366
|
jpayne@69
|
367 >>> dt.isCurrentMinute()
|
jpayne@69
|
368 False
|
jpayne@69
|
369 >>> DateTime().isCurrentMinute()
|
jpayne@69
|
370 True
|
jpayne@69
|
371
|
jpayne@69
|
372 * ``isLeapYear()`` returns true if the current year (in the context of
|
jpayne@69
|
373 the object's timezone) is a leap year:
|
jpayne@69
|
374
|
jpayne@69
|
375 >>> dt.isLeapYear()
|
jpayne@69
|
376 False
|
jpayne@69
|
377 >>> DateTime('Mar 8 2004').isLeapYear()
|
jpayne@69
|
378 True
|
jpayne@69
|
379
|
jpayne@69
|
380 * ``earliestTime()`` returns a new DateTime object that represents the
|
jpayne@69
|
381 earliest possible time (in whole seconds) that still falls within
|
jpayne@69
|
382 the current object's day, in the object's timezone context:
|
jpayne@69
|
383
|
jpayne@69
|
384 >>> dt.earliestTime()
|
jpayne@69
|
385 DateTime('1997/03/09 00:00:00 US/Eastern')
|
jpayne@69
|
386
|
jpayne@69
|
387 * ``latestTime()`` return a new DateTime object that represents the
|
jpayne@69
|
388 latest possible time (in whole seconds) that still falls within the
|
jpayne@69
|
389 current object's day, in the object's timezone context
|
jpayne@69
|
390
|
jpayne@69
|
391 >>> dt.latestTime()
|
jpayne@69
|
392 DateTime('1997/03/09 23:59:59 US/Eastern')
|
jpayne@69
|
393
|
jpayne@69
|
394 Component access
|
jpayne@69
|
395 ~~~~~~~~~~~~~~~~
|
jpayne@69
|
396
|
jpayne@69
|
397 * ``parts()`` returns a tuple containing the calendar year, month,
|
jpayne@69
|
398 day, hour, minute second and timezone of the object
|
jpayne@69
|
399
|
jpayne@69
|
400 >>> dt.parts() # doctest: +ELLIPSIS
|
jpayne@69
|
401 (1997, 3, 9, 13, 45, ... 'US/Eastern')
|
jpayne@69
|
402
|
jpayne@69
|
403 * ``timezone()`` returns the timezone in which the object is represented:
|
jpayne@69
|
404
|
jpayne@69
|
405 >>> dt.timezone() in Timezones()
|
jpayne@69
|
406 True
|
jpayne@69
|
407
|
jpayne@69
|
408 * ``tzoffset()`` returns the timezone offset for the objects timezone:
|
jpayne@69
|
409
|
jpayne@69
|
410 >>> dt.tzoffset()
|
jpayne@69
|
411 -18000
|
jpayne@69
|
412
|
jpayne@69
|
413 * ``year()`` returns the calendar year of the object:
|
jpayne@69
|
414
|
jpayne@69
|
415 >>> dt.year()
|
jpayne@69
|
416 1997
|
jpayne@69
|
417
|
jpayne@69
|
418 * ``month()`` returns the month of the object as an integer:
|
jpayne@69
|
419
|
jpayne@69
|
420 >>> dt.month()
|
jpayne@69
|
421 3
|
jpayne@69
|
422
|
jpayne@69
|
423 * ``Month()`` returns the full month name:
|
jpayne@69
|
424
|
jpayne@69
|
425 >>> dt.Month()
|
jpayne@69
|
426 'March'
|
jpayne@69
|
427
|
jpayne@69
|
428 * ``aMonth()`` returns the abbreviated month name:
|
jpayne@69
|
429
|
jpayne@69
|
430 >>> dt.aMonth()
|
jpayne@69
|
431 'Mar'
|
jpayne@69
|
432
|
jpayne@69
|
433 * ``pMonth()`` returns the abbreviated (with period) month name:
|
jpayne@69
|
434
|
jpayne@69
|
435 >>> dt.pMonth()
|
jpayne@69
|
436 'Mar.'
|
jpayne@69
|
437
|
jpayne@69
|
438 * ``day()`` returns the integer day:
|
jpayne@69
|
439
|
jpayne@69
|
440 >>> dt.day()
|
jpayne@69
|
441 9
|
jpayne@69
|
442
|
jpayne@69
|
443 * ``Day()`` returns the full name of the day of the week:
|
jpayne@69
|
444
|
jpayne@69
|
445 >>> dt.Day()
|
jpayne@69
|
446 'Sunday'
|
jpayne@69
|
447
|
jpayne@69
|
448 * ``dayOfYear()`` returns the day of the year, in context of the
|
jpayne@69
|
449 timezone representation of the object:
|
jpayne@69
|
450
|
jpayne@69
|
451 >>> dt.dayOfYear()
|
jpayne@69
|
452 68
|
jpayne@69
|
453
|
jpayne@69
|
454 * ``aDay()`` returns the abbreviated name of the day of the week:
|
jpayne@69
|
455
|
jpayne@69
|
456 >>> dt.aDay()
|
jpayne@69
|
457 'Sun'
|
jpayne@69
|
458
|
jpayne@69
|
459 * ``pDay()`` returns the abbreviated (with period) name of the day of
|
jpayne@69
|
460 the week:
|
jpayne@69
|
461
|
jpayne@69
|
462 >>> dt.pDay()
|
jpayne@69
|
463 'Sun.'
|
jpayne@69
|
464
|
jpayne@69
|
465 * ``dow()`` returns the integer day of the week, where Sunday is 0:
|
jpayne@69
|
466
|
jpayne@69
|
467 >>> dt.dow()
|
jpayne@69
|
468 0
|
jpayne@69
|
469
|
jpayne@69
|
470 * ``dow_1()`` returns the integer day of the week, where sunday is 1:
|
jpayne@69
|
471
|
jpayne@69
|
472 >>> dt.dow_1()
|
jpayne@69
|
473 1
|
jpayne@69
|
474
|
jpayne@69
|
475 * ``h_12()`` returns the 12-hour clock representation of the hour:
|
jpayne@69
|
476
|
jpayne@69
|
477 >>> dt.h_12()
|
jpayne@69
|
478 1
|
jpayne@69
|
479
|
jpayne@69
|
480 * ``h_24()`` returns the 24-hour clock representation of the hour:
|
jpayne@69
|
481
|
jpayne@69
|
482 >>> dt.h_24()
|
jpayne@69
|
483 13
|
jpayne@69
|
484
|
jpayne@69
|
485 * ``ampm()`` returns the appropriate time modifier (am or pm):
|
jpayne@69
|
486
|
jpayne@69
|
487 >>> dt.ampm()
|
jpayne@69
|
488 'pm'
|
jpayne@69
|
489
|
jpayne@69
|
490 * ``hour()`` returns the 24-hour clock representation of the hour:
|
jpayne@69
|
491
|
jpayne@69
|
492 >>> dt.hour()
|
jpayne@69
|
493 13
|
jpayne@69
|
494
|
jpayne@69
|
495 * ``minute()`` returns the minute:
|
jpayne@69
|
496
|
jpayne@69
|
497 >>> dt.minute()
|
jpayne@69
|
498 45
|
jpayne@69
|
499
|
jpayne@69
|
500 * ``second()`` returns the second:
|
jpayne@69
|
501
|
jpayne@69
|
502 >>> dt.second() == 0
|
jpayne@69
|
503 True
|
jpayne@69
|
504
|
jpayne@69
|
505 * ``millis()`` returns the milliseconds since the epoch in GMT.
|
jpayne@69
|
506
|
jpayne@69
|
507 >>> dt.millis() == 857933100000
|
jpayne@69
|
508 True
|
jpayne@69
|
509
|
jpayne@69
|
510 strftime()
|
jpayne@69
|
511 ~~~~~~~~~~
|
jpayne@69
|
512
|
jpayne@69
|
513 See ``tests/test_datetime.py``.
|
jpayne@69
|
514
|
jpayne@69
|
515 General formats from previous DateTime
|
jpayne@69
|
516 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
jpayne@69
|
517
|
jpayne@69
|
518 * ``Date()`` return the date string for the object:
|
jpayne@69
|
519
|
jpayne@69
|
520 >>> dt.Date()
|
jpayne@69
|
521 '1997/03/09'
|
jpayne@69
|
522
|
jpayne@69
|
523 * ``Time()`` returns the time string for an object to the nearest
|
jpayne@69
|
524 second:
|
jpayne@69
|
525
|
jpayne@69
|
526 >>> dt.Time()
|
jpayne@69
|
527 '13:45:00'
|
jpayne@69
|
528
|
jpayne@69
|
529 * ``TimeMinutes()`` returns the time string for an object not showing
|
jpayne@69
|
530 seconds:
|
jpayne@69
|
531
|
jpayne@69
|
532 >>> dt.TimeMinutes()
|
jpayne@69
|
533 '13:45'
|
jpayne@69
|
534
|
jpayne@69
|
535 * ``AMPM()`` returns the time string for an object to the nearest second:
|
jpayne@69
|
536
|
jpayne@69
|
537 >>> dt.AMPM()
|
jpayne@69
|
538 '01:45:00 pm'
|
jpayne@69
|
539
|
jpayne@69
|
540 * ``AMPMMinutes()`` returns the time string for an object not showing
|
jpayne@69
|
541 seconds:
|
jpayne@69
|
542
|
jpayne@69
|
543 >>> dt.AMPMMinutes()
|
jpayne@69
|
544 '01:45 pm'
|
jpayne@69
|
545
|
jpayne@69
|
546 * ``PreciseTime()`` returns the time string for the object:
|
jpayne@69
|
547
|
jpayne@69
|
548 >>> dt.PreciseTime()
|
jpayne@69
|
549 '13:45:00.000'
|
jpayne@69
|
550
|
jpayne@69
|
551 * ``PreciseAMPM()`` returns the time string for the object:
|
jpayne@69
|
552
|
jpayne@69
|
553 >>> dt.PreciseAMPM()
|
jpayne@69
|
554 '01:45:00.000 pm'
|
jpayne@69
|
555
|
jpayne@69
|
556 * ``yy()`` returns the calendar year as a 2 digit string
|
jpayne@69
|
557
|
jpayne@69
|
558 >>> dt.yy()
|
jpayne@69
|
559 '97'
|
jpayne@69
|
560
|
jpayne@69
|
561 * ``mm()`` returns the month as a 2 digit string
|
jpayne@69
|
562
|
jpayne@69
|
563 >>> dt.mm()
|
jpayne@69
|
564 '03'
|
jpayne@69
|
565
|
jpayne@69
|
566 * ``dd()`` returns the day as a 2 digit string:
|
jpayne@69
|
567
|
jpayne@69
|
568 >>> dt.dd()
|
jpayne@69
|
569 '09'
|
jpayne@69
|
570
|
jpayne@69
|
571 * ``rfc822()`` returns the date in RFC 822 format:
|
jpayne@69
|
572
|
jpayne@69
|
573 >>> dt.rfc822()
|
jpayne@69
|
574 'Sun, 09 Mar 1997 13:45:00 -0500'
|
jpayne@69
|
575
|
jpayne@69
|
576 New formats
|
jpayne@69
|
577 ~~~~~~~~~~~
|
jpayne@69
|
578
|
jpayne@69
|
579 * ``fCommon()`` returns a string representing the object's value in
|
jpayne@69
|
580 the format: March 9, 1997 1:45 pm:
|
jpayne@69
|
581
|
jpayne@69
|
582 >>> dt.fCommon()
|
jpayne@69
|
583 'March 9, 1997 1:45 pm'
|
jpayne@69
|
584
|
jpayne@69
|
585 * ``fCommonZ()`` returns a string representing the object's value in
|
jpayne@69
|
586 the format: March 9, 1997 1:45 pm US/Eastern:
|
jpayne@69
|
587
|
jpayne@69
|
588 >>> dt.fCommonZ()
|
jpayne@69
|
589 'March 9, 1997 1:45 pm US/Eastern'
|
jpayne@69
|
590
|
jpayne@69
|
591 * ``aCommon()`` returns a string representing the object's value in
|
jpayne@69
|
592 the format: Mar 9, 1997 1:45 pm:
|
jpayne@69
|
593
|
jpayne@69
|
594 >>> dt.aCommon()
|
jpayne@69
|
595 'Mar 9, 1997 1:45 pm'
|
jpayne@69
|
596
|
jpayne@69
|
597 * ``aCommonZ()`` return a string representing the object's value in
|
jpayne@69
|
598 the format: Mar 9, 1997 1:45 pm US/Eastern:
|
jpayne@69
|
599
|
jpayne@69
|
600 >>> dt.aCommonZ()
|
jpayne@69
|
601 'Mar 9, 1997 1:45 pm US/Eastern'
|
jpayne@69
|
602
|
jpayne@69
|
603 * ``pCommon()`` returns a string representing the object's value in
|
jpayne@69
|
604 the format Mar. 9, 1997 1:45 pm:
|
jpayne@69
|
605
|
jpayne@69
|
606 >>> dt.pCommon()
|
jpayne@69
|
607 'Mar. 9, 1997 1:45 pm'
|
jpayne@69
|
608
|
jpayne@69
|
609 * ``pCommonZ()`` returns a string representing the object's value in
|
jpayne@69
|
610 the format: Mar. 9, 1997 1:45 pm US/Eastern:
|
jpayne@69
|
611
|
jpayne@69
|
612 >>> dt.pCommonZ()
|
jpayne@69
|
613 'Mar. 9, 1997 1:45 pm US/Eastern'
|
jpayne@69
|
614
|
jpayne@69
|
615 * ``ISO()`` returns a string with the date/time in ISO format. Note:
|
jpayne@69
|
616 this is not ISO 8601-format! See the ISO8601 and HTML4 methods below
|
jpayne@69
|
617 for ISO 8601-compliant output. Dates are output as: YYYY-MM-DD HH:MM:SS
|
jpayne@69
|
618
|
jpayne@69
|
619 >>> dt.ISO()
|
jpayne@69
|
620 '1997-03-09 13:45:00'
|
jpayne@69
|
621
|
jpayne@69
|
622 * ``ISO8601()`` returns the object in ISO 8601-compatible format
|
jpayne@69
|
623 containing the date, time with seconds-precision and the time zone
|
jpayne@69
|
624 identifier - see http://www.w3.org/TR/NOTE-datetime. Dates are
|
jpayne@69
|
625 output as: YYYY-MM-DDTHH:MM:SSTZD (T is a literal character, TZD is
|
jpayne@69
|
626 Time Zone Designator, format +HH:MM or -HH:MM).
|
jpayne@69
|
627
|
jpayne@69
|
628 The ``HTML4()`` method below offers the same formatting, but
|
jpayne@69
|
629 converts to UTC before returning the value and sets the TZD"Z"
|
jpayne@69
|
630
|
jpayne@69
|
631 >>> dt.ISO8601()
|
jpayne@69
|
632 '1997-03-09T13:45:00-05:00'
|
jpayne@69
|
633
|
jpayne@69
|
634
|
jpayne@69
|
635 * ``HTML4()`` returns the object in the format used in the HTML4.0
|
jpayne@69
|
636 specification, one of the standard forms in ISO8601. See
|
jpayne@69
|
637 http://www.w3.org/TR/NOTE-datetime. Dates are output as:
|
jpayne@69
|
638 YYYY-MM-DDTHH:MM:SSZ (T, Z are literal characters, the time is in
|
jpayne@69
|
639 UTC.):
|
jpayne@69
|
640
|
jpayne@69
|
641 >>> dt.HTML4()
|
jpayne@69
|
642 '1997-03-09T18:45:00Z'
|
jpayne@69
|
643
|
jpayne@69
|
644 * ``JulianDay()`` returns the Julian day according to
|
jpayne@69
|
645 http://www.tondering.dk/claus/cal/node3.html#sec-calcjd
|
jpayne@69
|
646
|
jpayne@69
|
647 >>> dt.JulianDay()
|
jpayne@69
|
648 2450517
|
jpayne@69
|
649
|
jpayne@69
|
650 * ``week()`` returns the week number according to ISO
|
jpayne@69
|
651 see http://www.tondering.dk/claus/cal/node6.html#SECTION00670000000000000000
|
jpayne@69
|
652
|
jpayne@69
|
653 >>> dt.week()
|
jpayne@69
|
654 10
|
jpayne@69
|
655
|
jpayne@69
|
656 Deprecated API
|
jpayne@69
|
657 ~~~~~~~~~~~~~~
|
jpayne@69
|
658
|
jpayne@69
|
659 * DayOfWeek(): see Day()
|
jpayne@69
|
660
|
jpayne@69
|
661 * Day_(): see pDay()
|
jpayne@69
|
662
|
jpayne@69
|
663 * Mon(): see aMonth()
|
jpayne@69
|
664
|
jpayne@69
|
665 * Mon_(): see pMonth
|
jpayne@69
|
666
|
jpayne@69
|
667 General Services Provided by DateTime
|
jpayne@69
|
668 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
jpayne@69
|
669
|
jpayne@69
|
670 DateTimes can be repr()'ed; the result will be a string indicating how
|
jpayne@69
|
671 to make a DateTime object like this:
|
jpayne@69
|
672
|
jpayne@69
|
673 >>> repr(dt)
|
jpayne@69
|
674 "DateTime('1997/03/09 13:45:00 US/Eastern')"
|
jpayne@69
|
675
|
jpayne@69
|
676 When we convert them into a string, we get a nicer string that could
|
jpayne@69
|
677 actually be shown to a user:
|
jpayne@69
|
678
|
jpayne@69
|
679 >>> str(dt)
|
jpayne@69
|
680 '1997/03/09 13:45:00 US/Eastern'
|
jpayne@69
|
681
|
jpayne@69
|
682 The hash value of a DateTime is based on the date and time and is
|
jpayne@69
|
683 equal for different representations of the DateTime:
|
jpayne@69
|
684
|
jpayne@69
|
685 >>> hash(dt)
|
jpayne@69
|
686 3618678
|
jpayne@69
|
687 >>> hash(dt.toZone('UTC'))
|
jpayne@69
|
688 3618678
|
jpayne@69
|
689
|
jpayne@69
|
690 DateTime objects can be compared to other DateTime objects OR floating
|
jpayne@69
|
691 point numbers such as the ones which are returned by the Python time
|
jpayne@69
|
692 module by using the equalTo method. Using this API, True is returned if the
|
jpayne@69
|
693 object represents a date/time equal to the specified DateTime or time module
|
jpayne@69
|
694 style time:
|
jpayne@69
|
695
|
jpayne@69
|
696 >>> dt.equalTo(dt)
|
jpayne@69
|
697 True
|
jpayne@69
|
698 >>> dt.equalTo(dt.toZone('UTC'))
|
jpayne@69
|
699 True
|
jpayne@69
|
700 >>> dt.equalTo(dt.timeTime())
|
jpayne@69
|
701 True
|
jpayne@69
|
702 >>> dt.equalTo(DateTime())
|
jpayne@69
|
703 False
|
jpayne@69
|
704
|
jpayne@69
|
705 Same goes for inequalities:
|
jpayne@69
|
706
|
jpayne@69
|
707 >>> dt.notEqualTo(dt)
|
jpayne@69
|
708 False
|
jpayne@69
|
709 >>> dt.notEqualTo(dt.toZone('UTC'))
|
jpayne@69
|
710 False
|
jpayne@69
|
711 >>> dt.notEqualTo(dt.timeTime())
|
jpayne@69
|
712 False
|
jpayne@69
|
713 >>> dt.notEqualTo(DateTime())
|
jpayne@69
|
714 True
|
jpayne@69
|
715
|
jpayne@69
|
716 Normal equality operations only work with DateTime objects and take the
|
jpayne@69
|
717 timezone setting into account:
|
jpayne@69
|
718
|
jpayne@69
|
719 >>> dt == dt
|
jpayne@69
|
720 True
|
jpayne@69
|
721 >>> dt == dt.toZone('UTC')
|
jpayne@69
|
722 False
|
jpayne@69
|
723 >>> dt == DateTime()
|
jpayne@69
|
724 False
|
jpayne@69
|
725
|
jpayne@69
|
726 >>> dt != dt
|
jpayne@69
|
727 False
|
jpayne@69
|
728 >>> dt != dt.toZone('UTC')
|
jpayne@69
|
729 True
|
jpayne@69
|
730 >>> dt != DateTime()
|
jpayne@69
|
731 True
|
jpayne@69
|
732
|
jpayne@69
|
733 But the other comparison operations compare the referenced moment in time and
|
jpayne@69
|
734 not the representation itself:
|
jpayne@69
|
735
|
jpayne@69
|
736 >>> dt > dt
|
jpayne@69
|
737 False
|
jpayne@69
|
738 >>> DateTime() > dt
|
jpayne@69
|
739 True
|
jpayne@69
|
740 >>> dt > DateTime().timeTime()
|
jpayne@69
|
741 False
|
jpayne@69
|
742 >>> DateTime().timeTime() > dt
|
jpayne@69
|
743 True
|
jpayne@69
|
744
|
jpayne@69
|
745 >>> dt.greaterThan(dt)
|
jpayne@69
|
746 False
|
jpayne@69
|
747 >>> DateTime().greaterThan(dt)
|
jpayne@69
|
748 True
|
jpayne@69
|
749 >>> dt.greaterThan(DateTime().timeTime())
|
jpayne@69
|
750 False
|
jpayne@69
|
751
|
jpayne@69
|
752 >>> dt >= dt
|
jpayne@69
|
753 True
|
jpayne@69
|
754 >>> DateTime() >= dt
|
jpayne@69
|
755 True
|
jpayne@69
|
756 >>> dt >= DateTime().timeTime()
|
jpayne@69
|
757 False
|
jpayne@69
|
758 >>> DateTime().timeTime() >= dt
|
jpayne@69
|
759 True
|
jpayne@69
|
760
|
jpayne@69
|
761 >>> dt.greaterThanEqualTo(dt)
|
jpayne@69
|
762 True
|
jpayne@69
|
763 >>> DateTime().greaterThanEqualTo(dt)
|
jpayne@69
|
764 True
|
jpayne@69
|
765 >>> dt.greaterThanEqualTo(DateTime().timeTime())
|
jpayne@69
|
766 False
|
jpayne@69
|
767
|
jpayne@69
|
768 >>> dt < dt
|
jpayne@69
|
769 False
|
jpayne@69
|
770 >>> DateTime() < dt
|
jpayne@69
|
771 False
|
jpayne@69
|
772 >>> dt < DateTime().timeTime()
|
jpayne@69
|
773 True
|
jpayne@69
|
774 >>> DateTime().timeTime() < dt
|
jpayne@69
|
775 False
|
jpayne@69
|
776
|
jpayne@69
|
777 >>> dt.lessThan(dt)
|
jpayne@69
|
778 False
|
jpayne@69
|
779 >>> DateTime().lessThan(dt)
|
jpayne@69
|
780 False
|
jpayne@69
|
781 >>> dt.lessThan(DateTime().timeTime())
|
jpayne@69
|
782 True
|
jpayne@69
|
783
|
jpayne@69
|
784 >>> dt <= dt
|
jpayne@69
|
785 True
|
jpayne@69
|
786 >>> DateTime() <= dt
|
jpayne@69
|
787 False
|
jpayne@69
|
788 >>> dt <= DateTime().timeTime()
|
jpayne@69
|
789 True
|
jpayne@69
|
790 >>> DateTime().timeTime() <= dt
|
jpayne@69
|
791 False
|
jpayne@69
|
792
|
jpayne@69
|
793 >>> dt.lessThanEqualTo(dt)
|
jpayne@69
|
794 True
|
jpayne@69
|
795 >>> DateTime().lessThanEqualTo(dt)
|
jpayne@69
|
796 False
|
jpayne@69
|
797 >>> dt.lessThanEqualTo(DateTime().timeTime())
|
jpayne@69
|
798 True
|
jpayne@69
|
799
|
jpayne@69
|
800 Numeric Services Provided by DateTime
|
jpayne@69
|
801 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
jpayne@69
|
802
|
jpayne@69
|
803 A DateTime may be added to a number and a number may be added to a
|
jpayne@69
|
804 DateTime:
|
jpayne@69
|
805
|
jpayne@69
|
806 >>> dt + 5
|
jpayne@69
|
807 DateTime('1997/03/14 13:45:00 US/Eastern')
|
jpayne@69
|
808 >>> 5 + dt
|
jpayne@69
|
809 DateTime('1997/03/14 13:45:00 US/Eastern')
|
jpayne@69
|
810
|
jpayne@69
|
811 Two DateTimes cannot be added:
|
jpayne@69
|
812
|
jpayne@69
|
813 >>> from DateTime.interfaces import DateTimeError
|
jpayne@69
|
814 >>> try:
|
jpayne@69
|
815 ... dt + dt
|
jpayne@69
|
816 ... print('fail')
|
jpayne@69
|
817 ... except DateTimeError:
|
jpayne@69
|
818 ... print('ok')
|
jpayne@69
|
819 ok
|
jpayne@69
|
820
|
jpayne@69
|
821 Either a DateTime or a number may be subtracted from a DateTime,
|
jpayne@69
|
822 however, a DateTime may not be subtracted from a number:
|
jpayne@69
|
823
|
jpayne@69
|
824 >>> DateTime('1997/03/10 13:45 US/Eastern') - dt
|
jpayne@69
|
825 1.0
|
jpayne@69
|
826 >>> dt - 1
|
jpayne@69
|
827 DateTime('1997/03/08 13:45:00 US/Eastern')
|
jpayne@69
|
828 >>> 1 - dt
|
jpayne@69
|
829 Traceback (most recent call last):
|
jpayne@69
|
830 ...
|
jpayne@69
|
831 TypeError: unsupported operand type(s) for -: 'int' and 'DateTime'
|
jpayne@69
|
832
|
jpayne@69
|
833 DateTimes can also be converted to integers (number of seconds since
|
jpayne@69
|
834 the epoch) and floats:
|
jpayne@69
|
835
|
jpayne@69
|
836 >>> int(dt)
|
jpayne@69
|
837 857933100
|
jpayne@69
|
838 >>> float(dt)
|
jpayne@69
|
839 857933100.0
|
jpayne@69
|
840
|
jpayne@69
|
841
|
jpayne@69
|
842 Changelog
|
jpayne@69
|
843 =========
|
jpayne@69
|
844
|
jpayne@69
|
845 5.5 (2024-03-21)
|
jpayne@69
|
846 ----------------
|
jpayne@69
|
847
|
jpayne@69
|
848 - Change pickle format to export the microseconds as an int, to
|
jpayne@69
|
849 solve a problem with dates after 2038.
|
jpayne@69
|
850 (`#56 <https://github.com/zopefoundation/DateTime/issues/56>`_)
|
jpayne@69
|
851
|
jpayne@69
|
852
|
jpayne@69
|
853 5.4 (2023-12-15)
|
jpayne@69
|
854 ----------------
|
jpayne@69
|
855
|
jpayne@69
|
856 - Fix ``UnknownTimeZoneError`` when unpickling ``DateTime.DateTime().asdatetime()``.
|
jpayne@69
|
857 (`#58 <https://github.com/zopefoundation/DateTime/issues/58>`_)
|
jpayne@69
|
858
|
jpayne@69
|
859 - Repair equality comparison between DateTime instances and other types.
|
jpayne@69
|
860 (`#60 <https://github.com/zopefoundation/DateTime/issues/60>`_)
|
jpayne@69
|
861
|
jpayne@69
|
862
|
jpayne@69
|
863 5.3 (2023-11-14)
|
jpayne@69
|
864 ----------------
|
jpayne@69
|
865
|
jpayne@69
|
866 - Add support for Python 3.12.
|
jpayne@69
|
867
|
jpayne@69
|
868 - Add preliminary support for Python 3.13a2.
|
jpayne@69
|
869
|
jpayne@69
|
870
|
jpayne@69
|
871 5.2 (2023-07-19)
|
jpayne@69
|
872 ----------------
|
jpayne@69
|
873
|
jpayne@69
|
874 - Cast int to float in compare methods.
|
jpayne@69
|
875 - Fix compare methods between DateTime instances and None.
|
jpayne@69
|
876 (`#52 <https://github.com/zopefoundation/DateTime/issues/52>`_)
|
jpayne@69
|
877
|
jpayne@69
|
878
|
jpayne@69
|
879 5.1 (2023-03-14)
|
jpayne@69
|
880 ----------------
|
jpayne@69
|
881
|
jpayne@69
|
882 - Add missing ``python_requires`` to ``setup.py``.
|
jpayne@69
|
883
|
jpayne@69
|
884
|
jpayne@69
|
885 5.0 (2023-01-12)
|
jpayne@69
|
886 ----------------
|
jpayne@69
|
887
|
jpayne@69
|
888 - Drop support for Python 2.7, 3.5, 3.6.
|
jpayne@69
|
889
|
jpayne@69
|
890
|
jpayne@69
|
891 4.8 (2022-12-16)
|
jpayne@69
|
892 ----------------
|
jpayne@69
|
893
|
jpayne@69
|
894 - Fix insidious buildout configuration bug that prevented tests on Python 2.7
|
jpayne@69
|
895 and 3.5, and fix test code that was incompatible with Python 3.5.
|
jpayne@69
|
896 (`#44 <https://github.com/zopefoundation/DateTime/issues/44>`_)
|
jpayne@69
|
897
|
jpayne@69
|
898 - Add support for Python 3.11.
|
jpayne@69
|
899
|
jpayne@69
|
900
|
jpayne@69
|
901 4.7 (2022-09-14)
|
jpayne@69
|
902 ----------------
|
jpayne@69
|
903
|
jpayne@69
|
904 - Fix rounding problem with `DateTime` addition beyond the year 2038
|
jpayne@69
|
905 (`#41 <https://github.com/zopefoundation/DateTime/issues/41>`_)
|
jpayne@69
|
906
|
jpayne@69
|
907
|
jpayne@69
|
908 4.6 (2022-09-10)
|
jpayne@69
|
909 ----------------
|
jpayne@69
|
910
|
jpayne@69
|
911 - Fix ``__format__`` method for DateTime objects
|
jpayne@69
|
912 (`#39 <https://github.com/zopefoundation/DateTime/issues/39>`_)
|
jpayne@69
|
913
|
jpayne@69
|
914
|
jpayne@69
|
915 4.5 (2022-07-04)
|
jpayne@69
|
916 ----------------
|
jpayne@69
|
917
|
jpayne@69
|
918 - Add ``__format__`` method for DateTime objects
|
jpayne@69
|
919 (`#35 <https://github.com/zopefoundation/DateTime/issues/35>`_)
|
jpayne@69
|
920
|
jpayne@69
|
921
|
jpayne@69
|
922 4.4 (2022-02-11)
|
jpayne@69
|
923 ----------------
|
jpayne@69
|
924
|
jpayne@69
|
925 - Fix WAT definition
|
jpayne@69
|
926 `#31 <https://github.com/zopefoundation/DateTime/issues/31>`_.
|
jpayne@69
|
927
|
jpayne@69
|
928 - Add support for Python 3.8, 3.9, and 3.10.
|
jpayne@69
|
929
|
jpayne@69
|
930 - Drop support for Python 3.4.
|
jpayne@69
|
931
|
jpayne@69
|
932 4.3 (2018-10-05)
|
jpayne@69
|
933 ----------------
|
jpayne@69
|
934
|
jpayne@69
|
935 - Add support for Python 3.7.
|
jpayne@69
|
936
|
jpayne@69
|
937 4.2 (2017-04-26)
|
jpayne@69
|
938 ----------------
|
jpayne@69
|
939
|
jpayne@69
|
940 - Add support for Python 3.6, drop support for Python 3.3.
|
jpayne@69
|
941
|
jpayne@69
|
942 4.1.1 (2016-04-30)
|
jpayne@69
|
943 ------------------
|
jpayne@69
|
944
|
jpayne@69
|
945 - Support unpickling instances having a numeric timezone like `+0430`.
|
jpayne@69
|
946
|
jpayne@69
|
947 4.1 (2016-04-03)
|
jpayne@69
|
948 ----------------
|
jpayne@69
|
949
|
jpayne@69
|
950 - Add support for Python 3.4 and 3.5.
|
jpayne@69
|
951
|
jpayne@69
|
952 - Drop support for Python 2.6 and 3.2.
|
jpayne@69
|
953
|
jpayne@69
|
954 4.0.1 (2013-10-15)
|
jpayne@69
|
955 ------------------
|
jpayne@69
|
956
|
jpayne@69
|
957 - Provide more backward compatible timezones.
|
jpayne@69
|
958 [vangheem]
|
jpayne@69
|
959
|
jpayne@69
|
960 4.0 (2013-02-23)
|
jpayne@69
|
961 ----------------
|
jpayne@69
|
962
|
jpayne@69
|
963 - Added support for Python 3.2 and 3.3 in addition to 2.6 and 2.7.
|
jpayne@69
|
964
|
jpayne@69
|
965 - Removed unused legacy pytz tests and the DateTimeZone module and renamed
|
jpayne@69
|
966 some test internals.
|
jpayne@69
|
967
|
jpayne@69
|
968 3.0.3 (2013-01-22)
|
jpayne@69
|
969 ------------------
|
jpayne@69
|
970
|
jpayne@69
|
971 - Allow timezone argument to be a Unicode string while creating a DateTime
|
jpayne@69
|
972 object using two arguments.
|
jpayne@69
|
973
|
jpayne@69
|
974 3.0.2 (2012-10-21)
|
jpayne@69
|
975 ------------------
|
jpayne@69
|
976
|
jpayne@69
|
977 - LP #1045233: Respect date format setting for parsing dates like `11-01-2001`.
|
jpayne@69
|
978
|
jpayne@69
|
979 3.0.1 (2012-09-23)
|
jpayne@69
|
980 ------------------
|
jpayne@69
|
981
|
jpayne@69
|
982 - Add `_dt_reconstructor` function introduced in DateTime 2.12.7 to provide
|
jpayne@69
|
983 forward compatibility with pickles that might reference this function.
|
jpayne@69
|
984
|
jpayne@69
|
985 3.0 (2011-12-09)
|
jpayne@69
|
986 ----------------
|
jpayne@69
|
987
|
jpayne@69
|
988 - No changes.
|
jpayne@69
|
989
|
jpayne@69
|
990 Backwards compatibility of DateTime 3
|
jpayne@69
|
991 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
jpayne@69
|
992
|
jpayne@69
|
993 DateTime 3 changes its pickle representation. DateTime instances pickled with
|
jpayne@69
|
994 former versions of DateTime can be read, but older DateTime versions cannot read
|
jpayne@69
|
995 DateTime instances pickled with version 3.
|
jpayne@69
|
996
|
jpayne@69
|
997 DateTime 3 changes DateTime to be a new-style class with slots instead of being
|
jpayne@69
|
998 an old-style class.
|
jpayne@69
|
999
|
jpayne@69
|
1000 DateTime 3 tries to preserve microsecond resolution throughout most of its API's
|
jpayne@69
|
1001 while former versions were often only accurate to millisecond resolution. Due to
|
jpayne@69
|
1002 the representation of float values in Python versions before Python 2.7 you
|
jpayne@69
|
1003 shouldn't compare string or float representations of DateTime instances if you
|
jpayne@69
|
1004 want high accuracy. The same is true for calculated values returned by methods
|
jpayne@69
|
1005 like `timeTime()`. You get the highest accuracy of comparing DateTime values by
|
jpayne@69
|
1006 calling its `micros()` methods. DateTime is not particular well suited to be
|
jpayne@69
|
1007 used in comparing timestamps of file systems - use the time and datetime objects
|
jpayne@69
|
1008 from the Python standard library instead.
|
jpayne@69
|
1009
|
jpayne@69
|
1010 3.0b3 (2011-10-19)
|
jpayne@69
|
1011 ------------------
|
jpayne@69
|
1012
|
jpayne@69
|
1013 - Allow comparison of DateTime objects against None.
|
jpayne@69
|
1014
|
jpayne@69
|
1015 3.0b2 (2011-10-19)
|
jpayne@69
|
1016 ------------------
|
jpayne@69
|
1017
|
jpayne@69
|
1018 - Reverted the single argument `None` special case handling for unpickling and
|
jpayne@69
|
1019 continue to treat it as meaning `now`.
|
jpayne@69
|
1020
|
jpayne@69
|
1021 3.0b1 (2011-05-07)
|
jpayne@69
|
1022 ------------------
|
jpayne@69
|
1023
|
jpayne@69
|
1024 - Restored `strftimeFormatter` as a class.
|
jpayne@69
|
1025
|
jpayne@69
|
1026 - Added tests for read-only class attributes and interface.
|
jpayne@69
|
1027
|
jpayne@69
|
1028 3.0a2 (2011-05-07)
|
jpayne@69
|
1029 ------------------
|
jpayne@69
|
1030
|
jpayne@69
|
1031 - Added back support for reading old DateTime pickles without a `_micros` value.
|
jpayne@69
|
1032
|
jpayne@69
|
1033 - Avoid storing `_t` representing the time as a float in seconds since the
|
jpayne@69
|
1034 epoch, as we already have `_micros` doing the same as a long. Memory use is
|
jpayne@69
|
1035 down to about 300 bytes per DateTime instance.
|
jpayne@69
|
1036
|
jpayne@69
|
1037 - Updated exception raising syntax to current style.
|
jpayne@69
|
1038
|
jpayne@69
|
1039 - Avoid storing `_aday`, `_fday`, `_pday`, `_amon`, `_fmon`, `_pmon`, `_pmhour`
|
jpayne@69
|
1040 and `_pm` in memory for every instance but look them up dynamically based on
|
jpayne@69
|
1041 `_dayoffset`, `_month` and `_hour`. This saves another 150 bytes of memory
|
jpayne@69
|
1042 per DateTime instance.
|
jpayne@69
|
1043
|
jpayne@69
|
1044 - Moved various internal parsing related class variables to module constants.
|
jpayne@69
|
1045
|
jpayne@69
|
1046 - No longer provide the `DateError`, `DateTimeError`, `SyntaxError` and
|
jpayne@69
|
1047 `TimeError` exceptions as class attributes, import them from their canonical
|
jpayne@69
|
1048 `DateTime.interfaces` location instead.
|
jpayne@69
|
1049
|
jpayne@69
|
1050 - Removed deprecated `_isDST` and `_localzone` class variables.
|
jpayne@69
|
1051
|
jpayne@69
|
1052 - Moved pytz cache from `DateTime._tzinfo` to a module global `_TZINFO`.
|
jpayne@69
|
1053
|
jpayne@69
|
1054 - Make DateTime a new-style class and limit its available attributes via a
|
jpayne@69
|
1055 slots definition. The pickle size increases to 110 bytes thanks to the
|
jpayne@69
|
1056 `ccopy_reg\n_reconstructor` stanza. But the memory size drops from 3kb to
|
jpayne@69
|
1057 500 bytes for each instance.
|
jpayne@69
|
1058
|
jpayne@69
|
1059 3.0a1 (2011-05-06)
|
jpayne@69
|
1060 ------------------
|
jpayne@69
|
1061
|
jpayne@69
|
1062 - Reordered some calculations in `_calcIndependentSecondEtc` to preserve more
|
jpayne@69
|
1063 floating point precision.
|
jpayne@69
|
1064
|
jpayne@69
|
1065 - Optimized the pickled data, by only storing a tuple of `_micros` and time
|
jpayne@69
|
1066 zone information - this reduces the pickle size from an average of 300 bytes
|
jpayne@69
|
1067 to just 60 bytes.
|
jpayne@69
|
1068
|
jpayne@69
|
1069 - Optimized un-pickling, by avoiding the creation of an intermediate DateTime
|
jpayne@69
|
1070 value representing the current time.
|
jpayne@69
|
1071
|
jpayne@69
|
1072 - Removed in-place migration of old DateTime pickles without a `_micros` value.
|
jpayne@69
|
1073
|
jpayne@69
|
1074 - Removed deprecated support for using `DateTime.__cmp__`.
|
jpayne@69
|
1075
|
jpayne@69
|
1076 - Take time zone settings into account when comparing two date times for
|
jpayne@69
|
1077 (non-) equality.
|
jpayne@69
|
1078
|
jpayne@69
|
1079 - Fixed (possibly unused) _parse_iso8601 function.
|
jpayne@69
|
1080
|
jpayne@69
|
1081 - Removed unused import of legacy DateTimeZone, strftime and re.
|
jpayne@69
|
1082 Remove trailing whitespace.
|
jpayne@69
|
1083
|
jpayne@69
|
1084 - Removed reference to missing version section from buildout.
|
jpayne@69
|
1085
|
jpayne@69
|
1086 2.12.7 (2012-08-11)
|
jpayne@69
|
1087 -------------------
|
jpayne@69
|
1088
|
jpayne@69
|
1089 - Added forward compatibility with DateTime 3 pickle format. DateTime
|
jpayne@69
|
1090 instances constructed under version 3 can be read and unpickled by this
|
jpayne@69
|
1091 version. The pickled data is converted to the current versions format
|
jpayne@69
|
1092 (old-style class / no slots). Once converted it will be stored again in the
|
jpayne@69
|
1093 old format. This should allow for a transparent upgrade/downgrade path
|
jpayne@69
|
1094 between DateTime 2 and 3.
|
jpayne@69
|
1095
|
jpayne@69
|
1096 2.12.6 (2010-10-17)
|
jpayne@69
|
1097 -------------------
|
jpayne@69
|
1098
|
jpayne@69
|
1099 - Changed ``testDayOfWeek`` test to be independent of OS locale.
|
jpayne@69
|
1100
|
jpayne@69
|
1101 2.12.5 (2010-07-29)
|
jpayne@69
|
1102 -------------------
|
jpayne@69
|
1103
|
jpayne@69
|
1104 - Launchpad #143269: Corrected the documentation for year value
|
jpayne@69
|
1105 behavior when constructing a DateTime object with three numeric
|
jpayne@69
|
1106 arguments.
|
jpayne@69
|
1107
|
jpayne@69
|
1108 - Launchpad #142521: Removed confusing special case in
|
jpayne@69
|
1109 DateTime.__str__ where DateTime instances for midnight
|
jpayne@69
|
1110 (e.g. '2010-07-27 00:00:00 US/Eastern') values would
|
jpayne@69
|
1111 render only their date and nothing else.
|
jpayne@69
|
1112
|
jpayne@69
|
1113 2.12.4 (2010-07-12)
|
jpayne@69
|
1114 -------------------
|
jpayne@69
|
1115
|
jpayne@69
|
1116 - Fixed mapping of EDT (was -> 'GMT-0400', now 'GMT-4').
|
jpayne@69
|
1117
|
jpayne@69
|
1118 2.12.3 (2010-07-09)
|
jpayne@69
|
1119 -------------------
|
jpayne@69
|
1120
|
jpayne@69
|
1121 - Added EDT timezone support. Addresses bug #599856.
|
jpayne@69
|
1122 [vangheem]
|
jpayne@69
|
1123
|
jpayne@69
|
1124 2.12.2 (2010-05-05)
|
jpayne@69
|
1125 -------------------
|
jpayne@69
|
1126
|
jpayne@69
|
1127 - Launchpad #572715: Relaxed pin on pytz, after applying a patch from
|
jpayne@69
|
1128 Marius Gedminus which fixes the apparent API breakage.
|
jpayne@69
|
1129
|
jpayne@69
|
1130 2.12.1 (2010-04-30)
|
jpayne@69
|
1131 -------------------
|
jpayne@69
|
1132
|
jpayne@69
|
1133 - Removed an undeclared testing dependency on zope.testing.doctest in favor of
|
jpayne@69
|
1134 the standard libraries doctest module.
|
jpayne@69
|
1135
|
jpayne@69
|
1136 - Added a maximum version requirement on pytz <= 2010b. Later versions produce
|
jpayne@69
|
1137 test failures related to timezone changes.
|
jpayne@69
|
1138
|
jpayne@69
|
1139 2.12.0 (2009-03-04)
|
jpayne@69
|
1140 -------------------
|
jpayne@69
|
1141
|
jpayne@69
|
1142 - Launchpad #290254: Forward-ported fix for '_micros'-less pickles from
|
jpayne@69
|
1143 the Zope 2.11 branch version.
|
jpayne@69
|
1144
|
jpayne@69
|
1145 2.11.2 (2009-02-02)
|
jpayne@69
|
1146 -------------------
|
jpayne@69
|
1147
|
jpayne@69
|
1148 - Include *all* pytz zone names, not just "common" ones.
|
jpayne@69
|
1149
|
jpayne@69
|
1150 - Fix one fragile doctest, band-aid another.
|
jpayne@69
|
1151
|
jpayne@69
|
1152 - Fix for launchpad #267545: DateTime(DateTime()) should preserve the
|
jpayne@69
|
1153 correct hour.
|
jpayne@69
|
1154
|
jpayne@69
|
1155 2.11.1 (2008-08-05)
|
jpayne@69
|
1156 -------------------
|
jpayne@69
|
1157
|
jpayne@69
|
1158 - DateTime conversion of datetime objects with non-pytz tzinfo. Timezones()
|
jpayne@69
|
1159 returns a copy of the timezone list (allows tests to run).
|
jpayne@69
|
1160
|
jpayne@69
|
1161 - Merged the slinkp-datetime-200007 branch: fix the DateTime(anotherDateTime)
|
jpayne@69
|
1162 constructor to preserve timezones.
|
jpayne@69
|
1163
|
jpayne@69
|
1164 2.11.0b1 (2008-01-06)
|
jpayne@69
|
1165 ---------------------
|
jpayne@69
|
1166
|
jpayne@69
|
1167 - Split off from the Zope2 main source code tree.
|