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
40f11577
Commit
40f11577
authored
Jan 01, 2004
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merged changes from Zope-2_7-branch
parent
303d014e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
17 deletions
+27
-17
lib/python/DateTime/DateTime.py
lib/python/DateTime/DateTime.py
+14
-10
lib/python/DateTime/tests/testDateTime.py
lib/python/DateTime/tests/testDateTime.py
+13
-7
No files found.
lib/python/DateTime/DateTime.py
View file @
40f11577
...
...
@@ -12,7 +12,7 @@
##############################################################################
"""Encapsulation of date/time values"""
__version__
=
'$Revision: 1.9
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.9
7
$'
[
11
:
-
2
]
import
os
,
re
,
math
,
DateTimeZone
...
...
@@ -409,8 +409,8 @@ def safegmtime(t):
t_int
=
int
(
t
)
if
isinstance
(
t_int
,
long
):
raise
OverflowError
# Python 2.3 fix: int can return a long!
return
gmtime
(
t_int
)
except
(
IO
Error
,
OverflowError
):
return
gmtime
(
t_int
)
except
(
Value
Error
,
OverflowError
):
raise
TimeError
,
'The time %f is beyond the range '
\
'of this Python implementation.'
%
float
(
t
)
...
...
@@ -420,11 +420,10 @@ def safelocaltime(t):
t_int
=
int
(
t
)
if
isinstance
(
t_int
,
long
):
raise
OverflowError
# Python 2.3 fix: int can return a long!
except
OverflowError
:
return
localtime
(
t_int
)
except
(
ValueError
,
OverflowError
):
raise
TimeError
,
'The time %f is beyond the range '
\
'of this Python implementation.'
%
float
(
t
)
rval
=
localtime
(
t_int
)
return
rval
def
_tzoffset2rfc822zone
(
seconds
):
"""Takes an offset, such as from _tzoffset(), and returns an rfc822
...
...
@@ -891,6 +890,11 @@ class DateTime:
yr
=
((
yr
-
1970
)
%
28
)
+
1970
x
=
_calcDependentSecond2
(
yr
,
mo
,
dy
,
hr
,
mn
,
sc
)
nearTime
=
x
-
fsetAtEpoch
-
long
(
EPOCH
)
+
86400L
+
ms
# nearTime might still be negative if we are east of Greenwich.
# But we can asume on 1969/12/31 were no timezone changes.
nearTime
=
max
(
0
,
nearTime
)
ltm
=
safelocaltime
(
nearTime
)
tz
=
self
.
localZone
(
ltm
)
return
tz
...
...
@@ -1028,7 +1032,7 @@ class DateTime:
else
:
day
=
ints
[
0
]
month
=
ints
[
1
]
elif
ints
[
0
]
<=
12
:
month
=
ints
[
0
]
day
=
ints
[
1
]
...
...
@@ -1489,7 +1493,7 @@ class DateTime:
def rfc822(self):
"""Return the date in RFC 822 format"""
tzoffset = _tzoffset2rfc822zone(_tzoffset(self._tz, self._t))
return '
%
s
,
%
2.2
d
%
s
%
d
%
2.2
d
:
%
2.2
d
:
%
2.2
d
%
s
' % (
self._aday,self._day,self._amon,self._year,
self._hour,self._minute,self._nearsec,tzoffset)
...
...
@@ -1686,8 +1690,8 @@ class DateTime:
if
fields
[
5
]:
seconds
=
int
(
fields
[
5
])
if
fields
[
6
]:
seconds
=
seconds
+
float
(
fields
[
6
])
z
=
fields
[
7
]
if
z
and
z
.
startswith
(
'Z'
):
if
z
and
z
.
startswith
(
'Z'
):
# Waaaa! This is wrong, since 'Z' and '+HH:MM'
# are supposed to be mutually exclusive.
# It's only here to prevent breaking 2.7 beta.
...
...
lib/python/DateTime/tests/testDateTime.py
View file @
40f11577
...
...
@@ -232,11 +232,11 @@ class DateTimeTests(unittest.TestCase):
# A negative numerical timezone
dt
=
DateTime
(
'Tue, 24 Jul 2001 09:41:03 -0400'
)
self
.
assertEqual
(
dt
.
tzoffset
(),
-
14400
)
# A positive numerical timzone
dt
=
DateTime
(
'Tue, 6 Dec 1966 01:41:03 +0200'
)
self
.
assertEqual
(
dt
.
tzoffset
(),
7200
)
# A negative numerical timezone with minutes.
dt
=
DateTime
(
'Tue, 24 Jul 2001 09:41:03 -0637'
)
self
.
assertEqual
(
dt
.
tzoffset
(),
-
23820
)
...
...
@@ -244,11 +244,9 @@ class DateTimeTests(unittest.TestCase):
# A positive numerical timezone with minutes.
dt
=
DateTime
(
'Tue, 24 Jul 2001 09:41:03 +0425'
)
self
.
assertEqual
(
dt
.
tzoffset
(),
15900
)
def
testISO8601
(
self
):
''' iso 8601 dates '''
from
DateTime.DateTime
import
SyntaxError
ref0
=
DateTime
(
'2002/5/2 8:00am GMT'
)
ref1
=
DateTime
(
'2002/5/2 8:00am US/Eastern'
)
...
...
@@ -264,10 +262,10 @@ class DateTimeTests(unittest.TestCase):
dgood
=
'2002-05-02'
tgood
=
'T08:00:00-04:00'
for
dbad
in
'2002-5-2'
,
'2002-10-2'
,
'2002-2-10'
,
'02-2-10'
:
self
.
assertRaises
(
SyntaxError
,
DateTime
,
dbad
)
self
.
assertRaises
(
SyntaxError
,
DateTime
,
dbad
+
tgood
)
self
.
assertRaises
(
DateTime
.
SyntaxError
,
DateTime
,
dbad
)
self
.
assertRaises
(
DateTime
.
SyntaxError
,
DateTime
,
dbad
+
tgood
)
for
tbad
in
'08:00'
,
'T8:00'
:
#, 'T08:00Z-04:00':
self
.
assertRaises
(
SyntaxError
,
DateTime
,
dgood
+
tbad
)
self
.
assertRaises
(
DateTime
.
SyntaxError
,
DateTime
,
dgood
+
tbad
)
def
testJulianWeek
(
self
):
""" check JulianDayWeek function """
...
...
@@ -329,6 +327,14 @@ class DateTimeTests(unittest.TestCase):
d_int
=
DateTime
(
"%d/%d/%d"
%
(
day
,
month
,
year
),
datefmt
=
"international"
)
self
.
assertEqual
(
d_us
,
d_int
)
def
test_calcTimezoneName
(
self
):
timezone_dependent_epoch
=
2177452800L
try
:
DateTime
().
_calcTimezoneName
(
timezone_dependent_epoch
,
0
)
except
DateTime
.
TimeError
:
self
.
fail
(
'Zope Collector issue #484 (negative time bug): '
'TimeError raised'
)
def
test_suite
():
return
unittest
.
makeSuite
(
DateTimeTests
)
...
...
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