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
Show 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 @@
...
@@ -12,7 +12,7 @@
##############################################################################
##############################################################################
"""Encapsulation of date/time values"""
"""Encapsulation of date/time values"""
__version__
=
'$Revision: 1.9
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.9
7
$'
[
11
:
-
2
]
import
os
,
re
,
math
,
DateTimeZone
import
os
,
re
,
math
,
DateTimeZone
...
@@ -410,7 +410,7 @@ def safegmtime(t):
...
@@ -410,7 +410,7 @@ def safegmtime(t):
if
isinstance
(
t_int
,
long
):
if
isinstance
(
t_int
,
long
):
raise
OverflowError
# Python 2.3 fix: int can return a long!
raise
OverflowError
# Python 2.3 fix: int can return a long!
return
gmtime
(
t_int
)
return
gmtime
(
t_int
)
except
(
IO
Error
,
OverflowError
):
except
(
Value
Error
,
OverflowError
):
raise
TimeError
,
'The time %f is beyond the range '
\
raise
TimeError
,
'The time %f is beyond the range '
\
'of this Python implementation.'
%
float
(
t
)
'of this Python implementation.'
%
float
(
t
)
...
@@ -420,11 +420,10 @@ def safelocaltime(t):
...
@@ -420,11 +420,10 @@ def safelocaltime(t):
t_int
=
int
(
t
)
t_int
=
int
(
t
)
if
isinstance
(
t_int
,
long
):
if
isinstance
(
t_int
,
long
):
raise
OverflowError
# Python 2.3 fix: int can return a 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 '
\
raise
TimeError
,
'The time %f is beyond the range '
\
'of this Python implementation.'
%
float
(
t
)
'of this Python implementation.'
%
float
(
t
)
rval
=
localtime
(
t_int
)
return
rval
def
_tzoffset2rfc822zone
(
seconds
):
def
_tzoffset2rfc822zone
(
seconds
):
"""Takes an offset, such as from _tzoffset(), and returns an rfc822
"""Takes an offset, such as from _tzoffset(), and returns an rfc822
...
@@ -891,6 +890,11 @@ class DateTime:
...
@@ -891,6 +890,11 @@ class DateTime:
yr
=
((
yr
-
1970
)
%
28
)
+
1970
yr
=
((
yr
-
1970
)
%
28
)
+
1970
x
=
_calcDependentSecond2
(
yr
,
mo
,
dy
,
hr
,
mn
,
sc
)
x
=
_calcDependentSecond2
(
yr
,
mo
,
dy
,
hr
,
mn
,
sc
)
nearTime
=
x
-
fsetAtEpoch
-
long
(
EPOCH
)
+
86400L
+
ms
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
)
ltm
=
safelocaltime
(
nearTime
)
tz
=
self
.
localZone
(
ltm
)
tz
=
self
.
localZone
(
ltm
)
return
tz
return
tz
...
...
lib/python/DateTime/tests/testDateTime.py
View file @
40f11577
...
@@ -245,10 +245,8 @@ class DateTimeTests(unittest.TestCase):
...
@@ -245,10 +245,8 @@ class DateTimeTests(unittest.TestCase):
dt
=
DateTime
(
'Tue, 24 Jul 2001 09:41:03 +0425'
)
dt
=
DateTime
(
'Tue, 24 Jul 2001 09:41:03 +0425'
)
self
.
assertEqual
(
dt
.
tzoffset
(),
15900
)
self
.
assertEqual
(
dt
.
tzoffset
(),
15900
)
def
testISO8601
(
self
):
def
testISO8601
(
self
):
''' iso 8601 dates '''
''' iso 8601 dates '''
from
DateTime.DateTime
import
SyntaxError
ref0
=
DateTime
(
'2002/5/2 8:00am GMT'
)
ref0
=
DateTime
(
'2002/5/2 8:00am GMT'
)
ref1
=
DateTime
(
'2002/5/2 8:00am US/Eastern'
)
ref1
=
DateTime
(
'2002/5/2 8:00am US/Eastern'
)
...
@@ -264,10 +262,10 @@ class DateTimeTests(unittest.TestCase):
...
@@ -264,10 +262,10 @@ class DateTimeTests(unittest.TestCase):
dgood
=
'2002-05-02'
dgood
=
'2002-05-02'
tgood
=
'T08:00:00-04:00'
tgood
=
'T08:00:00-04:00'
for
dbad
in
'2002-5-2'
,
'2002-10-2'
,
'2002-2-10'
,
'02-2-10'
:
for
dbad
in
'2002-5-2'
,
'2002-10-2'
,
'2002-2-10'
,
'02-2-10'
:
self
.
assertRaises
(
SyntaxError
,
DateTime
,
dbad
)
self
.
assertRaises
(
DateTime
.
SyntaxError
,
DateTime
,
dbad
)
self
.
assertRaises
(
SyntaxError
,
DateTime
,
dbad
+
tgood
)
self
.
assertRaises
(
DateTime
.
SyntaxError
,
DateTime
,
dbad
+
tgood
)
for
tbad
in
'08:00'
,
'T8:00'
:
#, 'T08:00Z-04:00':
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
):
def
testJulianWeek
(
self
):
""" check JulianDayWeek function """
""" check JulianDayWeek function """
...
@@ -329,6 +327,14 @@ class DateTimeTests(unittest.TestCase):
...
@@ -329,6 +327,14 @@ class DateTimeTests(unittest.TestCase):
d_int
=
DateTime
(
"%d/%d/%d"
%
(
day
,
month
,
year
),
datefmt
=
"international"
)
d_int
=
DateTime
(
"%d/%d/%d"
%
(
day
,
month
,
year
),
datefmt
=
"international"
)
self
.
assertEqual
(
d_us
,
d_int
)
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
():
def
test_suite
():
return
unittest
.
makeSuite
(
DateTimeTests
)
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