Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b54b674f
Commit
b54b674f
authored
Feb 19, 1998
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature added by Bill van Melle: when no timezone is present, assume
local time -- that's better than failure.
parent
e3d80d4e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
9 deletions
+20
-9
Doc/lib/librfc822.tex
Doc/lib/librfc822.tex
+3
-1
Doc/librfc822.tex
Doc/librfc822.tex
+3
-1
Lib/rfc822.py
Lib/rfc822.py
+14
-7
No files found.
Doc/lib/librfc822.tex
View file @
b54b674f
...
@@ -47,11 +47,13 @@ offset of the date's timezone from UTC (which is the official term
...
@@ -47,11 +47,13 @@ offset of the date's timezone from UTC (which is the official term
for Greenwich Mean Time). (Note that the sign of the timezone offset
for Greenwich Mean Time). (Note that the sign of the timezone offset
is the opposite of the sign of the
\code
{
time.timezone
}
variable for
is the opposite of the sign of the
\code
{
time.timezone
}
variable for
the same timezone; the latter variable follows the
\POSIX
{}
standard
the same timezone; the latter variable follows the
\POSIX
{}
standard
while this module follows
\rfc
{
822
}
.)
while this module follows
\rfc
{
822
}
.) If the input string has no
timezone, the last element of the tuple returned is
\code
{
None
}
.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
mktime
_
tz
}{
tuple
}
\begin{funcdesc}
{
mktime
_
tz
}{
tuple
}
Turn a 10-tuple as returned by
\code
{
parsedate
_
tz()
}
into a UTC timestamp.
Turn a 10-tuple as returned by
\code
{
parsedate
_
tz()
}
into a UTC timestamp.
It the timezone item in the tuple is
\code
{
None
}
, assume local time.
Minor deficiency: this first interprets the first 8 elements as a
Minor deficiency: this first interprets the first 8 elements as a
local time and then compensates for the timezone difference;
local time and then compensates for the timezone difference;
this may yield a slight error around daylight savings time
this may yield a slight error around daylight savings time
...
...
Doc/librfc822.tex
View file @
b54b674f
...
@@ -47,11 +47,13 @@ offset of the date's timezone from UTC (which is the official term
...
@@ -47,11 +47,13 @@ offset of the date's timezone from UTC (which is the official term
for Greenwich Mean Time). (Note that the sign of the timezone offset
for Greenwich Mean Time). (Note that the sign of the timezone offset
is the opposite of the sign of the
\code
{
time.timezone
}
variable for
is the opposite of the sign of the
\code
{
time.timezone
}
variable for
the same timezone; the latter variable follows the
\POSIX
{}
standard
the same timezone; the latter variable follows the
\POSIX
{}
standard
while this module follows
\rfc
{
822
}
.)
while this module follows
\rfc
{
822
}
.) If the input string has no
timezone, the last element of the tuple returned is
\code
{
None
}
.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
mktime
_
tz
}{
tuple
}
\begin{funcdesc}
{
mktime
_
tz
}{
tuple
}
Turn a 10-tuple as returned by
\code
{
parsedate
_
tz()
}
into a UTC timestamp.
Turn a 10-tuple as returned by
\code
{
parsedate
_
tz()
}
into a UTC timestamp.
It the timezone item in the tuple is
\code
{
None
}
, assume local time.
Minor deficiency: this first interprets the first 8 elements as a
Minor deficiency: this first interprets the first 8 elements as a
local time and then compensates for the timezone difference;
local time and then compensates for the timezone difference;
this may yield a slight error around daylight savings time
this may yield a slight error around daylight savings time
...
...
Lib/rfc822.py
View file @
b54b674f
...
@@ -660,7 +660,7 @@ def parsedate_tz(data):
...
@@ -660,7 +660,7 @@ def parsedate_tz(data):
tss
=
string
.
atoi
(
tss
)
tss
=
string
.
atoi
(
tss
)
except
string
.
atoi_error
:
except
string
.
atoi_error
:
return
None
return
None
tzoffset
=
0
tzoffset
=
None
tz
=
string
.
upper
(
tz
)
tz
=
string
.
upper
(
tz
)
if
_timezones
.
has_key
(
tz
):
if
_timezones
.
has_key
(
tz
):
tzoffset
=
_timezones
[
tz
]
tzoffset
=
_timezones
[
tz
]
...
@@ -670,9 +670,12 @@ def parsedate_tz(data):
...
@@ -670,9 +670,12 @@ def parsedate_tz(data):
except
string
.
atoi_error
:
except
string
.
atoi_error
:
pass
pass
# Convert a timezone offset into seconds ; -0500 -> -18000
# Convert a timezone offset into seconds ; -0500 -> -18000
if
tzoffset
<
0
:
tzsign
=-
1
if
tzoffset
:
else
:
tzsign
=
1
if
tzoffset
<
0
:
tzoffset
=
tzoffset
*
tzsign
tzsign
=
-
1
tzoffset
=
-
tzoffset
else
:
tzsign
=
1
tzoffset
=
tzsign
*
(
(
tzoffset
/
100
)
*
3600
+
(
tzoffset
%
100
)
*
60
)
tzoffset
=
tzsign
*
(
(
tzoffset
/
100
)
*
3600
+
(
tzoffset
%
100
)
*
60
)
tuple
=
(
yy
,
mm
,
dd
,
thh
,
tmm
,
tss
,
0
,
0
,
0
,
tzoffset
)
tuple
=
(
yy
,
mm
,
dd
,
thh
,
tmm
,
tss
,
0
,
0
,
0
,
tzoffset
)
return
tuple
return
tuple
...
@@ -695,6 +698,10 @@ def mktime_tz(data):
...
@@ -695,6 +698,10 @@ def mktime_tz(data):
switch dates. Not enough to worry about for common use.
switch dates. Not enough to worry about for common use.
"""
"""
if
data
[
9
]
is
None
:
# No zone info, so localtime is better assumption than GMT
return
time
.
mktime
(
data
[:
8
]
+
(
-
1
,))
else
:
t
=
time
.
mktime
(
data
[:
8
]
+
(
0
,))
t
=
time
.
mktime
(
data
[:
8
]
+
(
0
,))
return
t
-
data
[
9
]
-
time
.
timezone
return
t
-
data
[
9
]
-
time
.
timezone
...
...
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