Mercurial > hg
annotate mercurial/thirdparty/zope/interface/common/idatetime.py @ 51809:45270e286bdc default tip
typing: hide the interface version of `dirstate` during type checking
As noted in the previous commit, the `dirstate` type is still inferred as `Any`
by pytype, including where it is used as a base class for the largefiles
dirstate. That effectively disables most type checking. The problems fixed two
commits ago were flagged by this change.
I'm not at all clear what the benefit of the original type is, but that was what
was used at runtime, so I don't want to change the largefiles base class to the
raw class. Having both a lowercase and camelcase name for the same thing isn't
great, but given that this trivially finds problems without worrying about which
symbol clients may be using, and the non-raw type is useless to pytype anyway,
I'm not going to worry about it.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 16 Aug 2024 18:11:52 -0400 |
parents | 68ee61822182 |
children |
rev | line source |
---|---|
37176
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 ############################################################################## |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 # Copyright (c) 2002 Zope Foundation and Contributors. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # All Rights Reserved. |
37178
68ee61822182
thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37176
diff
changeset
|
4 # |
37176
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 # This software is subject to the provisions of the Zope Public License, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 # FOR A PARTICULAR PURPOSE. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 ############################################################################## |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 """Datetime interfaces. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 This module is called idatetime because if it were called datetime the import |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 of the real datetime would fail. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 |
37178
68ee61822182
thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37176
diff
changeset
|
18 from __future__ import absolute_import |
68ee61822182
thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37176
diff
changeset
|
19 |
68ee61822182
thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37176
diff
changeset
|
20 from .. import Interface, Attribute |
68ee61822182
thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37176
diff
changeset
|
21 from .. import classImplements |
37176
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
22 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
23 from datetime import timedelta, date, datetime, time, tzinfo |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 class ITimeDeltaClass(Interface): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
27 """This is the timedelta class interface.""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
28 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 min = Attribute("The most negative timedelta object") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 max = Attribute("The most positive timedelta object") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 resolution = Attribute( |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 "The smallest difference between non-equal timedelta objects") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 class ITimeDelta(ITimeDeltaClass): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 """Represent the difference between two datetime objects. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 Supported operators: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 - add, subtract timedelta |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 - unary plus, minus, abs |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 - compare to timedelta |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 - multiply, divide by int/long |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 In addition, datetime supports subtraction of two datetime objects |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
48 returning a timedelta, and addition or subtraction of a datetime |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 and a timedelta giving a datetime. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
50 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
51 Representation: (days, seconds, microseconds). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
52 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
53 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
54 days = Attribute("Days between -999999999 and 999999999 inclusive") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
55 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
56 seconds = Attribute("Seconds between 0 and 86399 inclusive") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
57 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
58 microseconds = Attribute("Microseconds between 0 and 999999 inclusive") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
59 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
60 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
61 class IDateClass(Interface): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
62 """This is the date class interface.""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
63 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
64 min = Attribute("The earliest representable date") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
65 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
66 max = Attribute("The latest representable date") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
67 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
68 resolution = Attribute( |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
69 "The smallest difference between non-equal date objects") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
70 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
71 def today(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
72 """Return the current local time. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
73 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
74 This is equivalent to date.fromtimestamp(time.time())""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
75 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
76 def fromtimestamp(timestamp): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
77 """Return the local date from a POSIX timestamp (like time.time()) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
78 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
79 This may raise ValueError, if the timestamp is out of the range of |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
80 values supported by the platform C localtime() function. It's common |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
81 for this to be restricted to years from 1970 through 2038. Note that |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
82 on non-POSIX systems that include leap seconds in their notion of a |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
83 timestamp, leap seconds are ignored by fromtimestamp(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
84 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
85 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
86 def fromordinal(ordinal): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
87 """Return the date corresponding to the proleptic Gregorian ordinal. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
88 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
89 January 1 of year 1 has ordinal 1. ValueError is raised unless |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 1 <= ordinal <= date.max.toordinal(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
91 For any date d, date.fromordinal(d.toordinal()) == d. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
92 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
93 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
94 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
95 class IDate(IDateClass): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 """Represents a date (year, month and day) in an idealized calendar. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 Operators: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
99 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 __repr__, __str__ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 __cmp__, __hash__ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
102 __add__, __radd__, __sub__ (add/radd only with timedelta arg) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
104 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
105 year = Attribute("Between MINYEAR and MAXYEAR inclusive.") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
106 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
107 month = Attribute("Between 1 and 12 inclusive") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
108 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
109 day = Attribute( |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
110 "Between 1 and the number of days in the given month of the given year.") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
111 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
112 def replace(year, month, day): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
113 """Return a date with the same value. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
114 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
115 Except for those members given new values by whichever keyword |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
116 arguments are specified. For example, if d == date(2002, 12, 31), then |
37178
68ee61822182
thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37176
diff
changeset
|
117 d.replace(day=26) == date(2000, 12, 26). |
37176
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
118 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
119 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
120 def timetuple(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
121 """Return a 9-element tuple of the form returned by time.localtime(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
122 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
123 The hours, minutes and seconds are 0, and the DST flag is -1. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
124 d.timetuple() is equivalent to |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
125 (d.year, d.month, d.day, 0, 0, 0, d.weekday(), d.toordinal() - |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
126 date(d.year, 1, 1).toordinal() + 1, -1) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
127 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
128 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
129 def toordinal(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
130 """Return the proleptic Gregorian ordinal of the date |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
131 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
132 January 1 of year 1 has ordinal 1. For any date object d, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
133 date.fromordinal(d.toordinal()) == d. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
134 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
135 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
136 def weekday(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
137 """Return the day of the week as an integer. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
138 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
139 Monday is 0 and Sunday is 6. For example, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
140 date(2002, 12, 4).weekday() == 2, a Wednesday. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
141 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
142 See also isoweekday(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
143 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
144 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
145 def isoweekday(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
146 """Return the day of the week as an integer. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
147 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
148 Monday is 1 and Sunday is 7. For example, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
149 date(2002, 12, 4).isoweekday() == 3, a Wednesday. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
150 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
151 See also weekday(), isocalendar(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
152 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
153 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
154 def isocalendar(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
155 """Return a 3-tuple, (ISO year, ISO week number, ISO weekday). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
156 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
157 The ISO calendar is a widely used variant of the Gregorian calendar. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
158 See http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm for a good |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
159 explanation. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
160 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
161 The ISO year consists of 52 or 53 full weeks, and where a week starts |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
162 on a Monday and ends on a Sunday. The first week of an ISO year is the |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
163 first (Gregorian) calendar week of a year containing a Thursday. This |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
164 is called week number 1, and the ISO year of that Thursday is the same |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
165 as its Gregorian year. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
166 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
167 For example, 2004 begins on a Thursday, so the first week of ISO year |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
168 2004 begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan 2004, so |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
169 that date(2003, 12, 29).isocalendar() == (2004, 1, 1) and |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
170 date(2004, 1, 4).isocalendar() == (2004, 1, 7). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
171 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
172 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
173 def isoformat(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
174 """Return a string representing the date in ISO 8601 format. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
175 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
176 This is 'YYYY-MM-DD'. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
177 For example, date(2002, 12, 4).isoformat() == '2002-12-04'. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
178 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
179 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
180 def __str__(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
181 """For a date d, str(d) is equivalent to d.isoformat().""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
182 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
183 def ctime(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
184 """Return a string representing the date. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
185 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
186 For example date(2002, 12, 4).ctime() == 'Wed Dec 4 00:00:00 2002'. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
187 d.ctime() is equivalent to time.ctime(time.mktime(d.timetuple())) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
188 on platforms where the native C ctime() function |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
189 (which time.ctime() invokes, but which date.ctime() does not invoke) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
190 conforms to the C standard. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
191 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
192 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
193 def strftime(format): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
194 """Return a string representing the date. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
195 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
196 Controlled by an explicit format string. Format codes referring to |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
197 hours, minutes or seconds will see 0 values. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
198 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
199 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
200 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
201 class IDateTimeClass(Interface): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
202 """This is the datetime class interface.""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
203 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
204 min = Attribute("The earliest representable datetime") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
205 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
206 max = Attribute("The latest representable datetime") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
207 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
208 resolution = Attribute( |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
209 "The smallest possible difference between non-equal datetime objects") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
210 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
211 def today(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
212 """Return the current local datetime, with tzinfo None. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
213 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
214 This is equivalent to datetime.fromtimestamp(time.time()). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
215 See also now(), fromtimestamp(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
216 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
217 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
218 def now(tz=None): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
219 """Return the current local date and time. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
220 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
221 If optional argument tz is None or not specified, this is like today(), |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
222 but, if possible, supplies more precision than can be gotten from going |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
223 through a time.time() timestamp (for example, this may be possible on |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
224 platforms supplying the C gettimeofday() function). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
225 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
226 Else tz must be an instance of a class tzinfo subclass, and the current |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
227 date and time are converted to tz's time zone. In this case the result |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
228 is equivalent to tz.fromutc(datetime.utcnow().replace(tzinfo=tz)). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
229 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
230 See also today(), utcnow(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
231 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
232 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
233 def utcnow(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
234 """Return the current UTC date and time, with tzinfo None. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
235 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
236 This is like now(), but returns the current UTC date and time, as a |
37178
68ee61822182
thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37176
diff
changeset
|
237 naive datetime object. |
37176
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
238 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
239 See also now(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
240 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
241 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
242 def fromtimestamp(timestamp, tz=None): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
243 """Return the local date and time corresponding to the POSIX timestamp. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
244 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
245 Same as is returned by time.time(). If optional argument tz is None or |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
246 not specified, the timestamp is converted to the platform's local date |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
247 and time, and the returned datetime object is naive. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
248 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
249 Else tz must be an instance of a class tzinfo subclass, and the |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
250 timestamp is converted to tz's time zone. In this case the result is |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
251 equivalent to |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
252 tz.fromutc(datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz)). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
253 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
254 fromtimestamp() may raise ValueError, if the timestamp is out of the |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
255 range of values supported by the platform C localtime() or gmtime() |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
256 functions. It's common for this to be restricted to years in 1970 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
257 through 2038. Note that on non-POSIX systems that include leap seconds |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
258 in their notion of a timestamp, leap seconds are ignored by |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
259 fromtimestamp(), and then it's possible to have two timestamps |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
260 differing by a second that yield identical datetime objects. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
261 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
262 See also utcfromtimestamp(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
263 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
264 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
265 def utcfromtimestamp(timestamp): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
266 """Return the UTC datetime from the POSIX timestamp with tzinfo None. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
267 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
268 This may raise ValueError, if the timestamp is out of the range of |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
269 values supported by the platform C gmtime() function. It's common for |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
270 this to be restricted to years in 1970 through 2038. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
271 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
272 See also fromtimestamp(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
273 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
274 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
275 def fromordinal(ordinal): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
276 """Return the datetime from the proleptic Gregorian ordinal. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
277 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
278 January 1 of year 1 has ordinal 1. ValueError is raised unless |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
279 1 <= ordinal <= datetime.max.toordinal(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
280 The hour, minute, second and microsecond of the result are all 0, and |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
281 tzinfo is None. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
282 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
283 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
284 def combine(date, time): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
285 """Return a new datetime object. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
286 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
287 Its date members are equal to the given date object's, and whose time |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
288 and tzinfo members are equal to the given time object's. For any |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
289 datetime object d, d == datetime.combine(d.date(), d.timetz()). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
290 If date is a datetime object, its time and tzinfo members are ignored. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
291 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
292 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
293 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
294 class IDateTime(IDate, IDateTimeClass): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
295 """Object contains all the information from a date object and a time object. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
296 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
297 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
298 year = Attribute("Year between MINYEAR and MAXYEAR inclusive") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
299 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
300 month = Attribute("Month between 1 and 12 inclusive") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
301 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
302 day = Attribute( |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
303 "Day between 1 and the number of days in the given month of the year") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
304 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
305 hour = Attribute("Hour in range(24)") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
306 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
307 minute = Attribute("Minute in range(60)") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
308 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
309 second = Attribute("Second in range(60)") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
310 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
311 microsecond = Attribute("Microsecond in range(1000000)") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
312 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
313 tzinfo = Attribute( |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
314 """The object passed as the tzinfo argument to the datetime constructor |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
315 or None if none was passed""") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
316 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
317 def date(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
318 """Return date object with same year, month and day.""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
319 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
320 def time(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
321 """Return time object with same hour, minute, second, microsecond. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
322 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
323 tzinfo is None. See also method timetz(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
324 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
325 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
326 def timetz(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
327 """Return time object with same hour, minute, second, microsecond, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
328 and tzinfo. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
329 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
330 See also method time(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
331 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
332 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
333 def replace(year, month, day, hour, minute, second, microsecond, tzinfo): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
334 """Return a datetime with the same members, except for those members |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
335 given new values by whichever keyword arguments are specified. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
336 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
337 Note that tzinfo=None can be specified to create a naive datetime from |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
338 an aware datetime with no conversion of date and time members. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
339 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
340 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
341 def astimezone(tz): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
342 """Return a datetime object with new tzinfo member tz, adjusting the |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
343 date and time members so the result is the same UTC time as self, but |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
344 in tz's local time. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
345 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
346 tz must be an instance of a tzinfo subclass, and its utcoffset() and |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
347 dst() methods must not return None. self must be aware (self.tzinfo |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
348 must not be None, and self.utcoffset() must not return None). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
349 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
350 If self.tzinfo is tz, self.astimezone(tz) is equal to self: no |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
351 adjustment of date or time members is performed. Else the result is |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
352 local time in time zone tz, representing the same UTC time as self: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
353 after astz = dt.astimezone(tz), astz - astz.utcoffset() |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
354 will usually have the same date and time members as dt - dt.utcoffset(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
355 The discussion of class tzinfo explains the cases at Daylight Saving |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
356 Time transition boundaries where this cannot be achieved (an issue only |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
357 if tz models both standard and daylight time). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
358 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
359 If you merely want to attach a time zone object tz to a datetime dt |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
360 without adjustment of date and time members, use dt.replace(tzinfo=tz). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
361 If you merely want to remove the time zone object from an aware |
37178
68ee61822182
thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37176
diff
changeset
|
362 datetime dt without conversion of date and time members, use |
37176
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
363 dt.replace(tzinfo=None). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
364 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
365 Note that the default tzinfo.fromutc() method can be overridden in a |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
366 tzinfo subclass to effect the result returned by astimezone(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
367 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
368 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
369 def utcoffset(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
370 """Return the timezone offset in minutes east of UTC (negative west of |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
371 UTC).""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
372 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
373 def dst(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
374 """Return 0 if DST is not in effect, or the DST offset (in minutes |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
375 eastward) if DST is in effect. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
376 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
377 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
378 def tzname(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
379 """Return the timezone name.""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
380 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
381 def timetuple(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
382 """Return a 9-element tuple of the form returned by time.localtime().""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
383 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
384 def utctimetuple(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
385 """Return UTC time tuple compatilble with time.gmtimr().""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
386 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
387 def toordinal(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
388 """Return the proleptic Gregorian ordinal of the date. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
389 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
390 The same as self.date().toordinal(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
391 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
392 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
393 def weekday(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
394 """Return the day of the week as an integer. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
395 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
396 Monday is 0 and Sunday is 6. The same as self.date().weekday(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
397 See also isoweekday(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
398 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
399 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
400 def isoweekday(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
401 """Return the day of the week as an integer. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
402 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
403 Monday is 1 and Sunday is 7. The same as self.date().isoweekday. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
404 See also weekday(), isocalendar(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
405 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
406 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
407 def isocalendar(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
408 """Return a 3-tuple, (ISO year, ISO week number, ISO weekday). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
409 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
410 The same as self.date().isocalendar(). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
411 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
412 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
413 def isoformat(sep='T'): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
414 """Return a string representing the date and time in ISO 8601 format. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
415 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
416 YYYY-MM-DDTHH:MM:SS.mmmmmm or YYYY-MM-DDTHH:MM:SS if microsecond is 0 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
417 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
418 If utcoffset() does not return None, a 6-character string is appended, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
419 giving the UTC offset in (signed) hours and minutes: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
420 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
421 YYYY-MM-DDTHH:MM:SS.mmmmmm+HH:MM or YYYY-MM-DDTHH:MM:SS+HH:MM |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
422 if microsecond is 0. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
423 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
424 The optional argument sep (default 'T') is a one-character separator, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
425 placed between the date and time portions of the result. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
426 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
427 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
428 def __str__(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
429 """For a datetime instance d, str(d) is equivalent to d.isoformat(' '). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
430 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
431 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
432 def ctime(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
433 """Return a string representing the date and time. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
434 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
435 datetime(2002, 12, 4, 20, 30, 40).ctime() == 'Wed Dec 4 20:30:40 2002'. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
436 d.ctime() is equivalent to time.ctime(time.mktime(d.timetuple())) on |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
437 platforms where the native C ctime() function (which time.ctime() |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
438 invokes, but which datetime.ctime() does not invoke) conforms to the |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
439 C standard. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
440 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
441 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
442 def strftime(format): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
443 """Return a string representing the date and time. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
444 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
445 This is controlled by an explicit format string. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
446 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
447 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
448 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
449 class ITimeClass(Interface): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
450 """This is the time class interface.""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
451 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
452 min = Attribute("The earliest representable time") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
453 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
454 max = Attribute("The latest representable time") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
455 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
456 resolution = Attribute( |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
457 "The smallest possible difference between non-equal time objects") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
458 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
459 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
460 class ITime(ITimeClass): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
461 """Represent time with time zone. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
462 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
463 Operators: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
464 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
465 __repr__, __str__ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
466 __cmp__, __hash__ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
467 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
468 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
469 hour = Attribute("Hour in range(24)") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
470 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
471 minute = Attribute("Minute in range(60)") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
472 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
473 second = Attribute("Second in range(60)") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
474 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
475 microsecond = Attribute("Microsecond in range(1000000)") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
476 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
477 tzinfo = Attribute( |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
478 """The object passed as the tzinfo argument to the time constructor |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
479 or None if none was passed.""") |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
480 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
481 def replace(hour, minute, second, microsecond, tzinfo): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
482 """Return a time with the same value. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
483 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
484 Except for those members given new values by whichever keyword |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
485 arguments are specified. Note that tzinfo=None can be specified |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
486 to create a naive time from an aware time, without conversion of the |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
487 time members. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
488 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
489 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
490 def isoformat(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
491 """Return a string representing the time in ISO 8601 format. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
492 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
493 That is HH:MM:SS.mmmmmm or, if self.microsecond is 0, HH:MM:SS |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
494 If utcoffset() does not return None, a 6-character string is appended, |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
495 giving the UTC offset in (signed) hours and minutes: |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
496 HH:MM:SS.mmmmmm+HH:MM or, if self.microsecond is 0, HH:MM:SS+HH:MM |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
497 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
498 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
499 def __str__(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
500 """For a time t, str(t) is equivalent to t.isoformat().""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
501 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
502 def strftime(format): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
503 """Return a string representing the time. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
504 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
505 This is controlled by an explicit format string. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
506 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
507 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
508 def utcoffset(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
509 """Return the timezone offset in minutes east of UTC (negative west of |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
510 UTC). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
511 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
512 If tzinfo is None, returns None, else returns |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
513 self.tzinfo.utcoffset(None), and raises an exception if the latter |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
514 doesn't return None or a timedelta object representing a whole number |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
515 of minutes with magnitude less than one day. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
516 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
517 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
518 def dst(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
519 """Return 0 if DST is not in effect, or the DST offset (in minutes |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
520 eastward) if DST is in effect. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
521 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
522 If tzinfo is None, returns None, else returns self.tzinfo.dst(None), |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
523 and raises an exception if the latter doesn't return None, or a |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
524 timedelta object representing a whole number of minutes with |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
525 magnitude less than one day. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
526 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
527 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
528 def tzname(): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
529 """Return the timezone name. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
530 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
531 If tzinfo is None, returns None, else returns self.tzinfo.tzname(None), |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
532 or raises an exception if the latter doesn't return None or a string |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
533 object. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
534 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
535 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
536 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
537 class ITZInfo(Interface): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
538 """Time zone info class. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
539 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
540 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
541 def utcoffset(dt): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
542 """Return offset of local time from UTC, in minutes east of UTC. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
543 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
544 If local time is west of UTC, this should be negative. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
545 Note that this is intended to be the total offset from UTC; |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
546 for example, if a tzinfo object represents both time zone and DST |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
547 adjustments, utcoffset() should return their sum. If the UTC offset |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
548 isn't known, return None. Else the value returned must be a timedelta |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
549 object specifying a whole number of minutes in the range -1439 to 1439 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
550 inclusive (1440 = 24*60; the magnitude of the offset must be less |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
551 than one day). |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
552 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
553 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
554 def dst(dt): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
555 """Return the daylight saving time (DST) adjustment, in minutes east |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
556 of UTC, or None if DST information isn't known. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
557 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
558 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
559 def tzname(dt): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
560 """Return the time zone name corresponding to the datetime object as |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
561 a string. |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
562 """ |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
563 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
564 def fromutc(dt): |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
565 """Return an equivalent datetime in self's local time.""" |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
566 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
567 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
568 classImplements(timedelta, ITimeDelta) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
569 classImplements(date, IDate) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
570 classImplements(datetime, IDateTime) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
571 classImplements(time, ITime) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
572 classImplements(tzinfo, ITZInfo) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
573 |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
574 ## directlyProvides(timedelta, ITimeDeltaClass) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
575 ## directlyProvides(date, IDateClass) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
576 ## directlyProvides(datetime, IDateTimeClass) |
943d77fc07a3
thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
577 ## directlyProvides(time, ITimeClass) |