Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
19fae1a9
Kaydet (Commit)
19fae1a9
authored
Tem 31, 2015
tarafından
Robert Collins
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #22932: Fix timezones in email.utils.formatdate.
Patch from Dmitry Shachnev.
üst
a7a4c414
2080dc97
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
23 deletions
+31
-23
utils.py
Lib/email/utils.py
+7
-23
test_utils.py
Lib/test/test_email/test_utils.py
+20
-0
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/email/utils.py
Dosyayı görüntüle @
19fae1a9
...
...
@@ -155,30 +155,14 @@ def formatdate(timeval=None, localtime=False, usegmt=False):
# 2822 requires that day and month names be the English abbreviations.
if
timeval
is
None
:
timeval
=
time
.
time
()
if
localtime
:
now
=
time
.
localtime
(
timeval
)
# Calculate timezone offset, based on whether the local zone has
# daylight savings time, and whether DST is in effect.
if
time
.
daylight
and
now
[
-
1
]:
offset
=
time
.
altzone
else
:
offset
=
time
.
timezone
hours
,
minutes
=
divmod
(
abs
(
offset
),
3600
)
# Remember offset is in seconds west of UTC, but the timezone is in
# minutes east of UTC, so the signs differ.
if
offset
>
0
:
sign
=
'-'
else
:
sign
=
'+'
zone
=
'
%
s
%02
d
%02
d'
%
(
sign
,
hours
,
minutes
//
60
)
if
localtime
or
usegmt
:
dt
=
datetime
.
datetime
.
fromtimestamp
(
timeval
,
datetime
.
timezone
.
utc
)
else
:
now
=
time
.
gmtime
(
timeval
)
# Timezone offset is always -0000
if
usegmt
:
zone
=
'GMT'
else
:
zone
=
'-0000'
return
_format_timetuple_and_zone
(
now
,
zone
)
dt
=
datetime
.
datetime
.
utcfromtimestamp
(
timeval
)
if
localtime
:
dt
=
dt
.
astimezone
()
usegmt
=
False
return
format_datetime
(
dt
,
usegmt
)
def
format_datetime
(
dt
,
usegmt
=
False
):
"""Turn a datetime into a date string as specified in RFC 2822.
...
...
Lib/test/test_email/test_utils.py
Dosyayı görüntüle @
19fae1a9
...
...
@@ -136,5 +136,25 @@ class LocaltimeTests(unittest.TestCase):
t1
=
utils
.
localtime
(
t0
)
self
.
assertEqual
(
t1
.
tzname
(),
'EET'
)
class
FormatDateTests
(
unittest
.
TestCase
):
@test.support.run_with_tz
(
'Europe/Minsk'
)
def
test_formatdate
(
self
):
timeval
=
time
.
mktime
((
2011
,
12
,
1
,
18
,
0
,
0
,
4
,
335
,
0
))
string
=
utils
.
formatdate
(
timeval
,
localtime
=
False
,
usegmt
=
False
)
self
.
assertEqual
(
string
,
'Thu, 01 Dec 2011 15:00:00 -0000'
)
string
=
utils
.
formatdate
(
timeval
,
localtime
=
False
,
usegmt
=
True
)
self
.
assertEqual
(
string
,
'Thu, 01 Dec 2011 15:00:00 GMT'
)
@test.support.run_with_tz
(
'Europe/Minsk'
)
def
test_formatdate_with_localtime
(
self
):
timeval
=
time
.
mktime
((
2011
,
1
,
1
,
18
,
0
,
0
,
6
,
1
,
0
))
string
=
utils
.
formatdate
(
timeval
,
localtime
=
True
)
self
.
assertEqual
(
string
,
'Sat, 01 Jan 2011 18:00:00 +0200'
)
# Minsk moved from +0200 (with DST) to +0300 (without DST) in 2011
timeval
=
time
.
mktime
((
2011
,
12
,
1
,
18
,
0
,
0
,
4
,
335
,
0
))
string
=
utils
.
formatdate
(
timeval
,
localtime
=
True
)
self
.
assertEqual
(
string
,
'Thu, 01 Dec 2011 18:00:00 +0300'
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Misc/ACKS
Dosyayı görüntüle @
19fae1a9
...
...
@@ -1282,6 +1282,7 @@ Jerry Seutter
Pete Sevander
Denis Severson
Ian Seyer
Dmitry Shachnev
Daniel Shahaf
Ha Shao
Mark Shannon
...
...
Misc/NEWS
Dosyayı görüntüle @
19fae1a9
...
...
@@ -13,6 +13,9 @@ Core and Builtins
Library
-------
- Issue #22932: Fix timezones in email.utils.formatdate.
Patch from Dmitry Shachnev.
- Issue #23779: imaplib raises TypeError if authenticator tries to abort.
Patch from Craig Holmquist.
...
...
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