Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
cf2f9c02
Commit
cf2f9c02
authored
Oct 18, 2007
by
Amos Latteier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed pytz support not to check for the presence of pytz. We know pytz
will be present. Changes as per Andreas's request.
parent
a5ca27d7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
47 deletions
+24
-47
doc/CHANGES.txt
doc/CHANGES.txt
+3
-3
lib/python/DateTime/DateTime.py
lib/python/DateTime/DateTime.py
+4
-13
lib/python/DateTime/pytz.txt
lib/python/DateTime/pytz.txt
+11
-17
lib/python/DateTime/tests/testDateTime.py
lib/python/DateTime/tests/testDateTime.py
+6
-14
No files found.
doc/CHANGES.txt
View file @
cf2f9c02
...
...
@@ -173,9 +173,9 @@ Zope Changes
view to work. (patch by Sidnei da Silva from Enfold,
integration by Martijn Faassen (Startifact) for Infrae)
- DateTime now uses pytz for time zone data
if available. This
means support for more time zones and up to date daylight
saving time
information.
- DateTime now uses pytz for time zone data
. This means support
for more time zones and up to date daylight saving time
information.
Bugs Fixed
...
...
lib/python/DateTime/DateTime.py
View file @
cf2f9c02
...
...
@@ -22,11 +22,7 @@ from datetime import datetime
from
interfaces
import
IDateTime
from
interfaces
import
DateTimeError
,
SyntaxError
,
DateError
,
TimeError
from
zope.interface
import
implements
try
:
from
pytz_support
import
PytzCache
except
ImportError
:
# pytz not available, use legacy timezone support
PytzCache
=
None
from
pytz_support
import
PytzCache
default_datefmt
=
None
...
...
@@ -992,11 +988,7 @@ class DateTime:
# For backward compatibility only:
_isDST
=
localtime
(
time
())[
8
]
_localzone
=
_isDST
and
_localzone1
or
_localzone0
if
PytzCache
is
not
None
:
_tzinfo
=
PytzCache
(
_cache
())
else
:
_tzinfo
=
_cache
()
def
localZone
(
self
,
ltm
=
None
):
'''Returns the time zone on the given date. The time zone
...
...
@@ -2049,6 +2041,5 @@ class strftimeFormatter:
# Module methods
def
Timezones
():
"""Return the list of recognized timezone names"""
if
PytzCache
is
not
None
:
return
list
(
PytzCache
(
_cache
()).
_zlst
)
return
_cache
.
_zlst
lib/python/DateTime/pytz.txt
View file @
cf2f9c02
Pytz Support
============
If the pytz package is importable, it will be used for time zone
information, otherwise, DateTime's own time zone database is used
. The
Allows the pytz package to be used for time zone information
. The
advantage of using pytz is that it has a more complete and up to date
time zone and daylight savings time database.
This test assumes that pytz is available.
>>> import pytz
Usage
-----
If pytz is available, then DateTime will use it. You don't have to do
anything special to make it work.
You don't have to do anything special to make it work.
>>> from DateTime import DateTime, Timezones
>>> d = DateTime('March 11, 2007 US/Eastern')
...
...
@@ -53,9 +48,9 @@ Let's compare this to 2006.
-18000
Time Zones
---------
-
When pytz is available, DateTime can use its large database of ti
me
zones. Here are some
examples:
---------
DateTime can use pytz's large database of time zones. Here are so
me
examples:
>>> d = DateTime('Pacific/Kwajalein')
>>> d = DateTime('America/Shiprock')
...
...
@@ -75,13 +70,12 @@ the pytz database.
>>> d = DateTime('iceland')
These time zones use DateTimes database. So it's preferable to use the
official time zone name
when you have pytz installed
.
official time zone name.
One trickiness is that DateTime supports some zone name
abbreviations. Some of these map to pytz names, so when pytz is
present these abbreviations will give you time zone date from
pytz. Notable among abbreviations that work this way are 'est', 'cst',
'mst', and 'pst'.
abbreviations. Some of these map to pytz names, so these abbreviations
will give you time zone date from pytz. Notable among abbreviations
that work this way are 'est', 'cst', 'mst', and 'pst'.
Let's verify that 'est' picks up the 2007 daylight savings time changes.
...
...
@@ -115,7 +109,7 @@ The following are tests of internal components.
Cache
~~~~~
When pytz is present, the DateTime class uses a different
time zone cache.
The DateTime class uses a new
time zone cache.
>>> DateTime._tzinfo #doctest: +ELLIPSIS
<DateTime.pytz_support.PytzCache instance at ...>
...
...
lib/python/DateTime/tests/testDateTime.py
View file @
cf2f9c02
...
...
@@ -509,20 +509,12 @@ class DateTimeTests(unittest.TestCase):
def
test_suite
():
from
zope.testing
import
doctest
try
:
# if pytz is available include a test for it
import
pytz
return
unittest
.
TestSuite
([
unittest
.
makeSuite
(
DateTimeTests
),
doctest
.
DocFileSuite
(
'DateTime.txt'
,
package
=
'DateTime'
),
doctest
.
DocFileSuite
(
'pytz.txt'
,
package
=
'DateTime'
),
])
except
ImportError
:
return
unittest
.
TestSuite
([
unittest
.
makeSuite
(
DateTimeTests
),
doctest
.
DocFileSuite
(
'DateTime.txt'
,
package
=
'DateTime'
)
])
if
__name__
==
"__main__"
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment