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
9c397df3
Commit
9c397df3
authored
May 18, 2005
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Collector #1780: DateTime.strftime() now handles dates <= 1900 or >= 2038
parent
52e2f970
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
doc/CHANGES.txt
doc/CHANGES.txt
+5
-0
lib/python/DateTime/DateTime.py
lib/python/DateTime/DateTime.py
+10
-1
lib/python/DateTime/tests/testDateTime.py
lib/python/DateTime/tests/testDateTime.py
+14
-0
No files found.
doc/CHANGES.txt
View file @
9c397df3
...
...
@@ -31,6 +31,11 @@ Zope Changes
Bugs fixed
- Collector #1780: DateTime.strftime() now handles dates <= 1900 or
>= 2038
- Collector #1775: turning off debug mode by default
- Collector #1784: fixed handling of multiple attributes in ZCTextIndex
- Don't copy '.svn' directories from skeleton into an instance
...
...
lib/python/DateTime/DateTime.py
View file @
9c397df3
...
...
@@ -18,6 +18,7 @@ __version__='$Revision: 1.99 $'[11:-2]
import
re
,
math
,
DateTimeZone
from
time
import
time
,
gmtime
,
localtime
from
time
import
daylight
,
timezone
,
altzone
,
strftime
from
datetime
import
datetime
default_datefmt
=
None
...
...
@@ -1481,7 +1482,15 @@ class DateTime:
def
strftime
(
self
,
format
):
# Format the date/time using the *current timezone representation*.
return
strftime
(
format
,
safelocaltime
(
self
.
timeTime
()))
x
=
_calcDependentSecond2
(
self
.
_year
,
self
.
_month
,
self
.
_day
,
self
.
_hour
,
self
.
_minute
,
self
.
_second
)
ltz
=
self
.
_calcTimezoneName
(
x
,
0
)
tzdiff
=
_tzoffset
(
ltz
,
self
.
_t
)
-
_tzoffset
(
self
.
_tz
,
self
.
_t
)
zself
=
self
+
tzdiff
/
86400.0
microseconds
=
int
((
zself
.
_second
-
zself
.
_nearsec
)
*
1000000
)
return
datetime
(
zself
.
_year
,
zself
.
_month
,
zself
.
_day
,
zself
.
_hour
,
zself
.
_minute
,
int
(
zself
.
_nearsec
),
microseconds
).
strftime
(
format
)
# General formats from previous DateTime
def
Date
(
self
):
...
...
lib/python/DateTime/tests/testDateTime.py
View file @
9c397df3
...
...
@@ -360,6 +360,20 @@ class DateTimeTests(unittest.TestCase):
dt_localstring
=
dt_local
.
strftime
(
format
)
self
.
assertEqual
(
dt_string
,
dt_localstring
)
def
testStrftimeFarDates
(
self
):
'''Checks strftime in dates <= 1900 or >= 2038'''
dt
=
DateTime
(
'1900/01/30'
)
self
.
assertEqual
(
dt
.
strftime
(
'%d/%m/%Y'
),
'30/01/1900'
)
dt
=
DateTime
(
'2040/01/30'
)
self
.
assertEqual
(
dt
.
strftime
(
'%d/%m/%Y'
),
'30/01/2040'
)
def
testZoneInFarDates
(
self
):
'''Checks time zone in dates <= 1900 or >= 2038'''
dt1
=
DateTime
(
'2040/01/30 14:33 GMT+1'
)
dt2
=
DateTime
(
'2040/01/30 11:33 GMT-2'
)
self
.
assertEqual
(
dt1
.
strftime
(
'%d/%m/%Y %H:%M'
),
dt2
.
strftime
(
'%d/%m/%Y %H:%M'
))
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