comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/site-packages/DateTime/DateTime.txt @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
comparison
equal deleted inserted replaced
67:0e9998148a16 69:33d812a61356
1 The DateTime package
2 ====================
3
4 Encapsulation of date/time values.
5
6
7 Function Timezones()
8 --------------------
9
10 Returns the list of recognized timezone names:
11
12 >>> from DateTime import Timezones
13 >>> zones = set(Timezones())
14
15 Almost all of the standard pytz timezones are included, with the exception
16 of some commonly-used but ambiguous abbreviations, where historical Zope
17 usage conflicts with the name used by pytz:
18
19 >>> import pytz
20 >>> [x for x in pytz.all_timezones if x not in zones]
21 ['CET', 'EET', 'EST', 'MET', 'MST', 'WET']
22
23 Class DateTime
24 --------------
25
26 DateTime objects represent instants in time and provide interfaces for
27 controlling its representation without affecting the absolute value of
28 the object.
29
30 DateTime objects may be created from a wide variety of string or
31 numeric data, or may be computed from other DateTime objects.
32 DateTimes support the ability to convert their representations to many
33 major timezones, as well as the ability to create a DateTime object
34 in the context of a given timezone.
35
36 DateTime objects provide partial numerical behavior:
37
38 * Two date-time objects can be subtracted to obtain a time, in days
39 between the two.
40
41 * A date-time object and a positive or negative number may be added to
42 obtain a new date-time object that is the given number of days later
43 than the input date-time object.
44
45 * A positive or negative number and a date-time object may be added to
46 obtain a new date-time object that is the given number of days later
47 than the input date-time object.
48
49 * A positive or negative number may be subtracted from a date-time
50 object to obtain a new date-time object that is the given number of
51 days earlier than the input date-time object.
52
53 DateTime objects may be converted to integer, long, or float numbers
54 of days since January 1, 1901, using the standard int, long, and float
55 functions (Compatibility Note: int, long and float return the number
56 of days since 1901 in GMT rather than local machine timezone).
57 DateTime objects also provide access to their value in a float format
58 usable with the Python time module, provided that the value of the
59 object falls in the range of the epoch-based time module.
60
61 A DateTime object should be considered immutable; all conversion and numeric
62 operations return a new DateTime object rather than modify the current object.
63
64 A DateTime object always maintains its value as an absolute UTC time,
65 and is represented in the context of some timezone based on the
66 arguments used to create the object. A DateTime object's methods
67 return values based on the timezone context.
68
69 Note that in all cases the local machine timezone is used for
70 representation if no timezone is specified.
71
72 Constructor for DateTime
73 ------------------------
74
75 DateTime() returns a new date-time object. DateTimes may be created
76 with from zero to seven arguments:
77
78 * If the function is called with no arguments, then the current date/
79 time is returned, represented in the timezone of the local machine.
80
81 * If the function is invoked with a single string argument which is a
82 recognized timezone name, an object representing the current time is
83 returned, represented in the specified timezone.
84
85 * If the function is invoked with a single string argument
86 representing a valid date/time, an object representing that date/
87 time will be returned.
88
89 As a general rule, any date-time representation that is recognized
90 and unambiguous to a resident of North America is acceptable. (The
91 reason for this qualification is that in North America, a date like:
92 2/1/1994 is interpreted as February 1, 1994, while in some parts of
93 the world, it is interpreted as January 2, 1994.) A date/ time
94 string consists of two components, a date component and an optional
95 time component, separated by one or more spaces. If the time
96 component is omitted, 12:00am is assumed.
97
98 Any recognized timezone name specified as the final element of the
99 date/time string will be used for computing the date/time value.
100 (If you create a DateTime with the string,
101 "Mar 9, 1997 1:45pm US/Pacific", the value will essentially be the
102 same as if you had captured time.time() at the specified date and
103 time on a machine in that timezone). If no timezone is passed, then
104 the timezone configured on the local machine will be used, **except**
105 that if the date format matches ISO 8601 ('YYYY-MM-DD'), the instance
106 will use UTC / GMT+0 as the timezone.
107
108 o Returns current date/time, represented in US/Eastern:
109
110 >>> from DateTime import DateTime
111 >>> e = DateTime('US/Eastern')
112 >>> e.timezone()
113 'US/Eastern'
114
115 o Returns specified time, represented in local machine zone:
116
117 >>> x = DateTime('1997/3/9 1:45pm')
118 >>> x.parts() # doctest: +ELLIPSIS
119 (1997, 3, 9, 13, 45, ...)
120
121 o Specified time in local machine zone, verbose format:
122
123 >>> y = DateTime('Mar 9, 1997 13:45:00')
124 >>> y.parts() # doctest: +ELLIPSIS
125 (1997, 3, 9, 13, 45, ...)
126 >>> y == x
127 True
128
129 o Specified time in UTC via ISO 8601 rule:
130
131 >>> z = DateTime('2014-03-24')
132 >>> z.parts() # doctest: +ELLIPSIS
133 (2014, 3, 24, 0, 0, ...)
134 >>> z.timezone()
135 'GMT+0'
136
137 The date component consists of year, month, and day values. The
138 year value must be a one-, two-, or four-digit integer. If a one-
139 or two-digit year is used, the year is assumed to be in the
140 twentieth century. The month may an integer, from 1 to 12, a month
141 name, or a month abbreviation, where a period may optionally follow
142 the abbreviation. The day must be an integer from 1 to the number of
143 days in the month. The year, month, and day values may be separated
144 by periods, hyphens, forward slashes, or spaces. Extra spaces are
145 permitted around the delimiters. Year, month, and day values may be
146 given in any order as long as it is possible to distinguish the
147 components. If all three components are numbers that are less than
148 13, then a month-day-year ordering is assumed.
149
150 The time component consists of hour, minute, and second values
151 separated by colons. The hour value must be an integer between 0
152 and 23 inclusively. The minute value must be an integer between 0
153 and 59 inclusively. The second value may be an integer value
154 between 0 and 59.999 inclusively. The second value or both the
155 minute and second values may be omitted. The time may be followed
156 by am or pm in upper or lower case, in which case a 12-hour clock is
157 assumed.
158
159 * If the DateTime function is invoked with a single numeric argument,
160 the number is assumed to be either a floating point value such as
161 that returned by time.time(), or a number of days after January 1,
162 1901 00:00:00 UTC.
163
164 A DateTime object is returned that represents either the GMT value
165 of the time.time() float represented in the local machine's
166 timezone, or that number of days after January 1, 1901. Note that
167 the number of days after 1901 need to be expressed from the
168 viewpoint of the local machine's timezone. A negative argument will
169 yield a date-time value before 1901.
170
171 * If the function is invoked with two numeric arguments, then the
172 first is taken to be an integer year and the second argument is
173 taken to be an offset in days from the beginning of the year, in the
174 context of the local machine timezone. The date-time value returned
175 is the given offset number of days from the beginning of the given
176 year, represented in the timezone of the local machine. The offset
177 may be positive or negative. Two-digit years are assumed to be in
178 the twentieth century.
179
180 * If the function is invoked with two arguments, the first a float
181 representing a number of seconds past the epoch in GMT (such as
182 those returned by time.time()) and the second a string naming a
183 recognized timezone, a DateTime with a value of that GMT time will
184 be returned, represented in the given timezone.
185
186 >>> import time
187 >>> t = time.time()
188
189 Time t represented as US/Eastern:
190
191 >>> now_east = DateTime(t, 'US/Eastern')
192
193 Time t represented as US/Pacific:
194
195 >>> now_west = DateTime(t, 'US/Pacific')
196
197 Only their representations are different:
198
199 >>> now_east.equalTo(now_west)
200 True
201
202 * If the function is invoked with three or more numeric arguments,
203 then the first is taken to be an integer year, the second is taken
204 to be an integer month, and the third is taken to be an integer day.
205 If the combination of values is not valid, then a DateTimeError is
206 raised. One- or two-digit years up to 69 are assumed to be in the
207 21st century, whereas values 70-99 are assumed to be 20th century.
208 The fourth, fifth, and sixth arguments are floating point, positive
209 or negative offsets in units of hours, minutes, and days, and
210 default to zero if not given. An optional string may be given as
211 the final argument to indicate timezone (the effect of this is as if
212 you had taken the value of time.time() at that time on a machine in
213 the specified timezone).
214
215 If a string argument passed to the DateTime constructor cannot be
216 parsed, it will raise SyntaxError. Invalid date, time, or
217 timezone components will raise a DateTimeError.
218
219 The module function Timezones() will return a list of the timezones
220 recognized by the DateTime module. Recognition of timezone names is
221 case-insensitive.
222
223 Instance Methods for DateTime (IDateTime interface)
224 ---------------------------------------------------
225
226 Conversion and comparison methods
227 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
228
229 * ``timeTime()`` returns the date/time as a floating-point number in
230 UTC, in the format used by the Python time module. Note that it is
231 possible to create date /time values with DateTime that have no
232 meaningful value to the time module, and in such cases a
233 DateTimeError is raised. A DateTime object's value must generally
234 be between Jan 1, 1970 (or your local machine epoch) and Jan 2038 to
235 produce a valid time.time() style value.
236
237 >>> dt = DateTime('Mar 9, 1997 13:45:00 US/Eastern')
238 >>> dt.timeTime()
239 857933100.0
240
241 >>> DateTime('2040/01/01 UTC').timeTime()
242 2208988800.0
243
244 >>> DateTime('1900/01/01 UTC').timeTime()
245 -2208988800.0
246
247 * ``toZone(z)`` returns a DateTime with the value as the current
248 object, represented in the indicated timezone:
249
250 >>> dt.toZone('UTC')
251 DateTime('1997/03/09 18:45:00 UTC')
252
253 >>> dt.toZone('UTC').equalTo(dt)
254 True
255
256 * ``isFuture()`` returns true if this object represents a date/time
257 later than the time of the call:
258
259 >>> dt.isFuture()
260 False
261 >>> DateTime('Jan 1 3000').isFuture() # not time-machine safe!
262 True
263
264 * ``isPast()`` returns true if this object represents a date/time
265 earlier than the time of the call:
266
267 >>> dt.isPast()
268 True
269 >>> DateTime('Jan 1 3000').isPast() # not time-machine safe!
270 False
271
272 * ``isCurrentYear()`` returns true if this object represents a
273 date/time that falls within the current year, in the context of this
274 object's timezone representation:
275
276 >>> dt.isCurrentYear()
277 False
278 >>> DateTime().isCurrentYear()
279 True
280
281 * ``isCurrentMonth()`` returns true if this object represents a
282 date/time that falls within the current month, in the context of
283 this object's timezone representation:
284
285 >>> dt.isCurrentMonth()
286 False
287 >>> DateTime().isCurrentMonth()
288 True
289
290 * ``isCurrentDay()`` returns true if this object represents a
291 date/time that falls within the current day, in the context of this
292 object's timezone representation:
293
294 >>> dt.isCurrentDay()
295 False
296 >>> DateTime().isCurrentDay()
297 True
298
299 * ``isCurrentHour()`` returns true if this object represents a
300 date/time that falls within the current hour, in the context of this
301 object's timezone representation:
302
303 >>> dt.isCurrentHour()
304 False
305
306 >>> DateTime().isCurrentHour()
307 True
308
309 * ``isCurrentMinute()`` returns true if this object represents a
310 date/time that falls within the current minute, in the context of
311 this object's timezone representation:
312
313 >>> dt.isCurrentMinute()
314 False
315 >>> DateTime().isCurrentMinute()
316 True
317
318 * ``isLeapYear()`` returns true if the current year (in the context of
319 the object's timezone) is a leap year:
320
321 >>> dt.isLeapYear()
322 False
323 >>> DateTime('Mar 8 2004').isLeapYear()
324 True
325
326 * ``earliestTime()`` returns a new DateTime object that represents the
327 earliest possible time (in whole seconds) that still falls within
328 the current object's day, in the object's timezone context:
329
330 >>> dt.earliestTime()
331 DateTime('1997/03/09 00:00:00 US/Eastern')
332
333 * ``latestTime()`` return a new DateTime object that represents the
334 latest possible time (in whole seconds) that still falls within the
335 current object's day, in the object's timezone context
336
337 >>> dt.latestTime()
338 DateTime('1997/03/09 23:59:59 US/Eastern')
339
340 Component access
341 ~~~~~~~~~~~~~~~~
342
343 * ``parts()`` returns a tuple containing the calendar year, month,
344 day, hour, minute second and timezone of the object
345
346 >>> dt.parts() # doctest: +ELLIPSIS
347 (1997, 3, 9, 13, 45, ... 'US/Eastern')
348
349 * ``timezone()`` returns the timezone in which the object is represented:
350
351 >>> dt.timezone() in Timezones()
352 True
353
354 * ``tzoffset()`` returns the timezone offset for the objects timezone:
355
356 >>> dt.tzoffset()
357 -18000
358
359 * ``year()`` returns the calendar year of the object:
360
361 >>> dt.year()
362 1997
363
364 * ``month()`` returns the month of the object as an integer:
365
366 >>> dt.month()
367 3
368
369 * ``Month()`` returns the full month name:
370
371 >>> dt.Month()
372 'March'
373
374 * ``aMonth()`` returns the abbreviated month name:
375
376 >>> dt.aMonth()
377 'Mar'
378
379 * ``pMonth()`` returns the abbreviated (with period) month name:
380
381 >>> dt.pMonth()
382 'Mar.'
383
384 * ``day()`` returns the integer day:
385
386 >>> dt.day()
387 9
388
389 * ``Day()`` returns the full name of the day of the week:
390
391 >>> dt.Day()
392 'Sunday'
393
394 * ``dayOfYear()`` returns the day of the year, in context of the
395 timezone representation of the object:
396
397 >>> dt.dayOfYear()
398 68
399
400 * ``aDay()`` returns the abbreviated name of the day of the week:
401
402 >>> dt.aDay()
403 'Sun'
404
405 * ``pDay()`` returns the abbreviated (with period) name of the day of
406 the week:
407
408 >>> dt.pDay()
409 'Sun.'
410
411 * ``dow()`` returns the integer day of the week, where Sunday is 0:
412
413 >>> dt.dow()
414 0
415
416 * ``dow_1()`` returns the integer day of the week, where sunday is 1:
417
418 >>> dt.dow_1()
419 1
420
421 * ``h_12()`` returns the 12-hour clock representation of the hour:
422
423 >>> dt.h_12()
424 1
425
426 * ``h_24()`` returns the 24-hour clock representation of the hour:
427
428 >>> dt.h_24()
429 13
430
431 * ``ampm()`` returns the appropriate time modifier (am or pm):
432
433 >>> dt.ampm()
434 'pm'
435
436 * ``hour()`` returns the 24-hour clock representation of the hour:
437
438 >>> dt.hour()
439 13
440
441 * ``minute()`` returns the minute:
442
443 >>> dt.minute()
444 45
445
446 * ``second()`` returns the second:
447
448 >>> dt.second() == 0
449 True
450
451 * ``millis()`` returns the milliseconds since the epoch in GMT.
452
453 >>> dt.millis() == 857933100000
454 True
455
456 strftime()
457 ~~~~~~~~~~
458
459 See ``tests/test_datetime.py``.
460
461 General formats from previous DateTime
462 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
463
464 * ``Date()`` return the date string for the object:
465
466 >>> dt.Date()
467 '1997/03/09'
468
469 * ``Time()`` returns the time string for an object to the nearest
470 second:
471
472 >>> dt.Time()
473 '13:45:00'
474
475 * ``TimeMinutes()`` returns the time string for an object not showing
476 seconds:
477
478 >>> dt.TimeMinutes()
479 '13:45'
480
481 * ``AMPM()`` returns the time string for an object to the nearest second:
482
483 >>> dt.AMPM()
484 '01:45:00 pm'
485
486 * ``AMPMMinutes()`` returns the time string for an object not showing
487 seconds:
488
489 >>> dt.AMPMMinutes()
490 '01:45 pm'
491
492 * ``PreciseTime()`` returns the time string for the object:
493
494 >>> dt.PreciseTime()
495 '13:45:00.000'
496
497 * ``PreciseAMPM()`` returns the time string for the object:
498
499 >>> dt.PreciseAMPM()
500 '01:45:00.000 pm'
501
502 * ``yy()`` returns the calendar year as a 2 digit string
503
504 >>> dt.yy()
505 '97'
506
507 * ``mm()`` returns the month as a 2 digit string
508
509 >>> dt.mm()
510 '03'
511
512 * ``dd()`` returns the day as a 2 digit string:
513
514 >>> dt.dd()
515 '09'
516
517 * ``rfc822()`` returns the date in RFC 822 format:
518
519 >>> dt.rfc822()
520 'Sun, 09 Mar 1997 13:45:00 -0500'
521
522 New formats
523 ~~~~~~~~~~~
524
525 * ``fCommon()`` returns a string representing the object's value in
526 the format: March 9, 1997 1:45 pm:
527
528 >>> dt.fCommon()
529 'March 9, 1997 1:45 pm'
530
531 * ``fCommonZ()`` returns a string representing the object's value in
532 the format: March 9, 1997 1:45 pm US/Eastern:
533
534 >>> dt.fCommonZ()
535 'March 9, 1997 1:45 pm US/Eastern'
536
537 * ``aCommon()`` returns a string representing the object's value in
538 the format: Mar 9, 1997 1:45 pm:
539
540 >>> dt.aCommon()
541 'Mar 9, 1997 1:45 pm'
542
543 * ``aCommonZ()`` return a string representing the object's value in
544 the format: Mar 9, 1997 1:45 pm US/Eastern:
545
546 >>> dt.aCommonZ()
547 'Mar 9, 1997 1:45 pm US/Eastern'
548
549 * ``pCommon()`` returns a string representing the object's value in
550 the format Mar. 9, 1997 1:45 pm:
551
552 >>> dt.pCommon()
553 'Mar. 9, 1997 1:45 pm'
554
555 * ``pCommonZ()`` returns a string representing the object's value in
556 the format: Mar. 9, 1997 1:45 pm US/Eastern:
557
558 >>> dt.pCommonZ()
559 'Mar. 9, 1997 1:45 pm US/Eastern'
560
561 * ``ISO()`` returns a string with the date/time in ISO format. Note:
562 this is not ISO 8601-format! See the ISO8601 and HTML4 methods below
563 for ISO 8601-compliant output. Dates are output as: YYYY-MM-DD HH:MM:SS
564
565 >>> dt.ISO()
566 '1997-03-09 13:45:00'
567
568 * ``ISO8601()`` returns the object in ISO 8601-compatible format
569 containing the date, time with seconds-precision and the time zone
570 identifier - see http://www.w3.org/TR/NOTE-datetime. Dates are
571 output as: YYYY-MM-DDTHH:MM:SSTZD (T is a literal character, TZD is
572 Time Zone Designator, format +HH:MM or -HH:MM).
573
574 The ``HTML4()`` method below offers the same formatting, but
575 converts to UTC before returning the value and sets the TZD"Z"
576
577 >>> dt.ISO8601()
578 '1997-03-09T13:45:00-05:00'
579
580
581 * ``HTML4()`` returns the object in the format used in the HTML4.0
582 specification, one of the standard forms in ISO8601. See
583 http://www.w3.org/TR/NOTE-datetime. Dates are output as:
584 YYYY-MM-DDTHH:MM:SSZ (T, Z are literal characters, the time is in
585 UTC.):
586
587 >>> dt.HTML4()
588 '1997-03-09T18:45:00Z'
589
590 * ``JulianDay()`` returns the Julian day according to
591 http://www.tondering.dk/claus/cal/node3.html#sec-calcjd
592
593 >>> dt.JulianDay()
594 2450517
595
596 * ``week()`` returns the week number according to ISO
597 see http://www.tondering.dk/claus/cal/node6.html#SECTION00670000000000000000
598
599 >>> dt.week()
600 10
601
602 Deprecated API
603 ~~~~~~~~~~~~~~
604
605 * DayOfWeek(): see Day()
606
607 * Day_(): see pDay()
608
609 * Mon(): see aMonth()
610
611 * Mon_(): see pMonth
612
613 General Services Provided by DateTime
614 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
615
616 DateTimes can be repr()'ed; the result will be a string indicating how
617 to make a DateTime object like this:
618
619 >>> repr(dt)
620 "DateTime('1997/03/09 13:45:00 US/Eastern')"
621
622 When we convert them into a string, we get a nicer string that could
623 actually be shown to a user:
624
625 >>> str(dt)
626 '1997/03/09 13:45:00 US/Eastern'
627
628 The hash value of a DateTime is based on the date and time and is
629 equal for different representations of the DateTime:
630
631 >>> hash(dt)
632 3618678
633 >>> hash(dt.toZone('UTC'))
634 3618678
635
636 DateTime objects can be compared to other DateTime objects OR floating
637 point numbers such as the ones which are returned by the Python time
638 module by using the equalTo method. Using this API, True is returned if the
639 object represents a date/time equal to the specified DateTime or time module
640 style time:
641
642 >>> dt.equalTo(dt)
643 True
644 >>> dt.equalTo(dt.toZone('UTC'))
645 True
646 >>> dt.equalTo(dt.timeTime())
647 True
648 >>> dt.equalTo(DateTime())
649 False
650
651 Same goes for inequalities:
652
653 >>> dt.notEqualTo(dt)
654 False
655 >>> dt.notEqualTo(dt.toZone('UTC'))
656 False
657 >>> dt.notEqualTo(dt.timeTime())
658 False
659 >>> dt.notEqualTo(DateTime())
660 True
661
662 Normal equality operations only work with DateTime objects and take the
663 timezone setting into account:
664
665 >>> dt == dt
666 True
667 >>> dt == dt.toZone('UTC')
668 False
669 >>> dt == DateTime()
670 False
671
672 >>> dt != dt
673 False
674 >>> dt != dt.toZone('UTC')
675 True
676 >>> dt != DateTime()
677 True
678
679 But the other comparison operations compare the referenced moment in time and
680 not the representation itself:
681
682 >>> dt > dt
683 False
684 >>> DateTime() > dt
685 True
686 >>> dt > DateTime().timeTime()
687 False
688 >>> DateTime().timeTime() > dt
689 True
690
691 >>> dt.greaterThan(dt)
692 False
693 >>> DateTime().greaterThan(dt)
694 True
695 >>> dt.greaterThan(DateTime().timeTime())
696 False
697
698 >>> dt >= dt
699 True
700 >>> DateTime() >= dt
701 True
702 >>> dt >= DateTime().timeTime()
703 False
704 >>> DateTime().timeTime() >= dt
705 True
706
707 >>> dt.greaterThanEqualTo(dt)
708 True
709 >>> DateTime().greaterThanEqualTo(dt)
710 True
711 >>> dt.greaterThanEqualTo(DateTime().timeTime())
712 False
713
714 >>> dt < dt
715 False
716 >>> DateTime() < dt
717 False
718 >>> dt < DateTime().timeTime()
719 True
720 >>> DateTime().timeTime() < dt
721 False
722
723 >>> dt.lessThan(dt)
724 False
725 >>> DateTime().lessThan(dt)
726 False
727 >>> dt.lessThan(DateTime().timeTime())
728 True
729
730 >>> dt <= dt
731 True
732 >>> DateTime() <= dt
733 False
734 >>> dt <= DateTime().timeTime()
735 True
736 >>> DateTime().timeTime() <= dt
737 False
738
739 >>> dt.lessThanEqualTo(dt)
740 True
741 >>> DateTime().lessThanEqualTo(dt)
742 False
743 >>> dt.lessThanEqualTo(DateTime().timeTime())
744 True
745
746 Numeric Services Provided by DateTime
747 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
748
749 A DateTime may be added to a number and a number may be added to a
750 DateTime:
751
752 >>> dt + 5
753 DateTime('1997/03/14 13:45:00 US/Eastern')
754 >>> 5 + dt
755 DateTime('1997/03/14 13:45:00 US/Eastern')
756
757 Two DateTimes cannot be added:
758
759 >>> from DateTime.interfaces import DateTimeError
760 >>> try:
761 ... dt + dt
762 ... print('fail')
763 ... except DateTimeError:
764 ... print('ok')
765 ok
766
767 Either a DateTime or a number may be subtracted from a DateTime,
768 however, a DateTime may not be subtracted from a number:
769
770 >>> DateTime('1997/03/10 13:45 US/Eastern') - dt
771 1.0
772 >>> dt - 1
773 DateTime('1997/03/08 13:45:00 US/Eastern')
774 >>> 1 - dt
775 Traceback (most recent call last):
776 ...
777 TypeError: unsupported operand type(s) for -: 'int' and 'DateTime'
778
779 DateTimes can also be converted to integers (number of seconds since
780 the epoch) and floats:
781
782 >>> int(dt)
783 857933100
784 >>> float(dt)
785 857933100.0