Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
f3fdd7d1
Commit
f3fdd7d1
authored
May 21, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hack: DateTime.latestTime patch for 2013/03/31
parent
482f2f41
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
product/ERP5Type/patches/DateTimePatch.py
product/ERP5Type/patches/DateTimePatch.py
+20
-0
No files found.
product/ERP5Type/patches/DateTimePatch.py
View file @
f3fdd7d1
...
...
@@ -248,6 +248,26 @@ def DateTime_parse(self, st, datefmt=getDefaultDateFormat()):
DateTimeKlass
.
_parse
=
DateTime_parse
def
DateTime_latestTime
(
self
):
"""Return a new DateTime object that represents the latest
possible time (in whole seconds) that still falls within
the current object
\
'
s day, in the object
\
'
s timezone context.
Patched to return a date in the "natural time zone" when called on the day
of DST change.
An example problematic day is 2013/03/31, where DST switched at 2h00
2013/03/31 00:00:00 is GMT+1 but 2013/03/31 23:59:59 is GMT+2
The default behaviour of this method would be to return 2013/03/31 23:59:59
still in GMT+1, which is 22h59 local time.
"""
if
self
.
_hour
==
self
.
_minute
==
self
.
_second
==
0
:
return
self
.
__class__
(
self
.
_year
,
self
.
_month
,
self
.
_day
,
23
,
59
,
59
)
return
self
.
__class__
(
self
.
_year
,
self
.
_month
,
self
.
_day
,
23
,
59
,
59
,
self
.
_tz
)
DateTimeKlass
.
latestTime
=
DateTime_latestTime
if
__name__
==
'__main__'
:
for
i
in
(
'2007/01/02 12:34:56.789'
,
'2007/01/02 12:34:56.789 GMT+0200'
,
...
...
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