comparison mercurial/thirdparty/zope/interface/common/idatetime.py @ 37178:68ee61822182

thirdparty: port zope.interface to relative imports By using relative imports, we're guaranteed to get modules vendored with Mercurial rather than other random modules that might be in sys.path. My editor strips trailing whitespace on save. So some minor source code cleanup was also performed as part of this commit. # no-check-commit because some modified lines have double newlines Differential Revision: https://phab.mercurial-scm.org/D2930
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 21 Mar 2018 19:52:30 -0700
parents 943d77fc07a3
children
comparison
equal deleted inserted replaced
37177:338367d44d34 37178:68ee61822182
1 ############################################################################## 1 ##############################################################################
2 # Copyright (c) 2002 Zope Foundation and Contributors. 2 # Copyright (c) 2002 Zope Foundation and Contributors.
3 # All Rights Reserved. 3 # All Rights Reserved.
4 # 4 #
5 # This software is subject to the provisions of the Zope Public License, 5 # This software is subject to the provisions of the Zope Public License,
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. 6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED 7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS 9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
13 13
14 This module is called idatetime because if it were called datetime the import 14 This module is called idatetime because if it were called datetime the import
15 of the real datetime would fail. 15 of the real datetime would fail.
16 """ 16 """
17 17
18 from zope.interface import Interface, Attribute 18 from __future__ import absolute_import
19 from zope.interface import classImplements 19
20 from .. import Interface, Attribute
21 from .. import classImplements
20 22
21 from datetime import timedelta, date, datetime, time, tzinfo 23 from datetime import timedelta, date, datetime, time, tzinfo
22 24
23 25
24 class ITimeDeltaClass(Interface): 26 class ITimeDeltaClass(Interface):
110 def replace(year, month, day): 112 def replace(year, month, day):
111 """Return a date with the same value. 113 """Return a date with the same value.
112 114
113 Except for those members given new values by whichever keyword 115 Except for those members given new values by whichever keyword
114 arguments are specified. For example, if d == date(2002, 12, 31), then 116 arguments are specified. For example, if d == date(2002, 12, 31), then
115 d.replace(day=26) == date(2000, 12, 26). 117 d.replace(day=26) == date(2000, 12, 26).
116 """ 118 """
117 119
118 def timetuple(): 120 def timetuple():
119 """Return a 9-element tuple of the form returned by time.localtime(). 121 """Return a 9-element tuple of the form returned by time.localtime().
120 122
230 232
231 def utcnow(): 233 def utcnow():
232 """Return the current UTC date and time, with tzinfo None. 234 """Return the current UTC date and time, with tzinfo None.
233 235
234 This is like now(), but returns the current UTC date and time, as a 236 This is like now(), but returns the current UTC date and time, as a
235 naive datetime object. 237 naive datetime object.
236 238
237 See also now(). 239 See also now().
238 """ 240 """
239 241
240 def fromtimestamp(timestamp, tz=None): 242 def fromtimestamp(timestamp, tz=None):
355 if tz models both standard and daylight time). 357 if tz models both standard and daylight time).
356 358
357 If you merely want to attach a time zone object tz to a datetime dt 359 If you merely want to attach a time zone object tz to a datetime dt
358 without adjustment of date and time members, use dt.replace(tzinfo=tz). 360 without adjustment of date and time members, use dt.replace(tzinfo=tz).
359 If you merely want to remove the time zone object from an aware 361 If you merely want to remove the time zone object from an aware
360 datetime dt without conversion of date and time members, use 362 datetime dt without conversion of date and time members, use
361 dt.replace(tzinfo=None). 363 dt.replace(tzinfo=None).
362 364
363 Note that the default tzinfo.fromutc() method can be overridden in a 365 Note that the default tzinfo.fromutc() method can be overridden in a
364 tzinfo subclass to effect the result returned by astimezone(). 366 tzinfo subclass to effect the result returned by astimezone().
365 """ 367 """