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
93c9cd07
Kaydet (Commit)
93c9cd07
authored
Haz 22, 2012
tarafından
Alexander Belopolsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #9527: tm_gmtoff has 'correct' sign.
üst
5f6213be
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
13 deletions
+11
-13
time.rst
Doc/library/time.rst
+1
-1
datetime.py
Lib/datetime.py
+3
-3
datetimetester.py
Lib/test/datetimetester.py
+4
-2
_datetimemodule.c
Modules/_datetimemodule.c
+3
-7
No files found.
Doc/library/time.rst
Dosyayı görüntüle @
93c9cd07
...
...
@@ -545,7 +545,7 @@ The module defines the following functions and data items:
+-------+-------------------+---------------------------------+
| N/A | :attr:`tm_zone` | abbreviation of timezone name |
+-------+-------------------+---------------------------------+
| N/A | :attr:`tm_gmtoff` | offset
from UTC in seconds
|
| N/A | :attr:`tm_gmtoff` | offset
east of UTC in seconds
|
+-------+-------------------+---------------------------------+
Note that unlike the C structure, the month value is a range of [1, 12], not
...
...
Lib/datetime.py
Dosyayı görüntüle @
93c9cd07
...
...
@@ -1510,13 +1510,13 @@ class datetime(date):
# implied by tm_isdst.
delta
=
local
-
datetime
(
*
_time
.
gmtime
(
ts
)[:
6
])
dst
=
_time
.
daylight
and
localtm
.
tm_isdst
>
0
gmtoff
=
_time
.
altzone
if
dst
else
_time
.
timezone
if
delta
==
timedelta
(
seconds
=
-
gmtoff
):
gmtoff
=
-
(
_time
.
altzone
if
dst
else
_time
.
timezone
)
if
delta
==
timedelta
(
seconds
=
gmtoff
):
tz
=
timezone
(
delta
,
_time
.
tzname
[
dst
])
else
:
tz
=
timezone
(
delta
)
else
:
tz
=
timezone
(
timedelta
(
seconds
=
-
gmtoff
),
zone
)
tz
=
timezone
(
timedelta
(
seconds
=
gmtoff
),
zone
)
elif
not
isinstance
(
tz
,
tzinfo
):
raise
TypeError
(
"tz argument must be an instance of tzinfo"
)
...
...
Lib/test/datetimetester.py
Dosyayı görüntüle @
93c9cd07
...
...
@@ -3278,16 +3278,18 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
self
.
assertEqual
(
dt
.
astimezone
(
None
),
dt
)
self
.
assertEqual
(
dt
.
astimezone
(),
dt
)
# Note that offset in TZ variable has the opposite sign to that
# produced by %z directive.
@support.run_with_tz
(
'EST+05EDT,M3.2.0,M11.1.0'
)
def
test_astimezone_default_eastern
(
self
):
dt
=
self
.
theclass
(
2012
,
11
,
4
,
6
,
30
,
tzinfo
=
timezone
.
utc
)
local
=
dt
.
astimezone
()
self
.
assertEqual
(
dt
,
local
)
self
.
assertEqual
(
local
.
strftime
(
"
%
z
%
Z"
),
"
+
0500 EST"
)
self
.
assertEqual
(
local
.
strftime
(
"
%
z
%
Z"
),
"
-
0500 EST"
)
dt
=
self
.
theclass
(
2012
,
11
,
4
,
5
,
30
,
tzinfo
=
timezone
.
utc
)
local
=
dt
.
astimezone
()
self
.
assertEqual
(
dt
,
local
)
self
.
assertEqual
(
local
.
strftime
(
"
%
z
%
Z"
),
"
+
0400 EDT"
)
self
.
assertEqual
(
local
.
strftime
(
"
%
z
%
Z"
),
"
-
0400 EDT"
)
def
test_aware_subtract
(
self
):
cls
=
self
.
theclass
...
...
Modules/_datetimemodule.c
Dosyayı görüntüle @
93c9cd07
...
...
@@ -4717,12 +4717,8 @@ local_timezone(PyDateTime_DateTime *utc_time)
return
NULL
;
timep
=
localtime
(
&
timestamp
);
#ifdef HAVE_STRUCT_TM_TM_ZONE
{
long
offset
;
offset
=
timep
->
tm_gmtoff
;
zone
=
timep
->
tm_zone
;
delta
=
new_delta
(
0
,
-
offset
,
0
,
0
);
}
zone
=
timep
->
tm_zone
;
delta
=
new_delta
(
0
,
timep
->
tm_gmtoff
,
0
,
1
);
#else
/* HAVE_STRUCT_TM_TM_ZONE */
{
PyObject
*
local_time
;
...
...
@@ -4732,7 +4728,7 @@ local_timezone(PyDateTime_DateTime *utc_time)
utc_time
->
tzinfo
);
if
(
local_time
==
NULL
)
goto
error
;
delta
=
datetime_subtract
(
(
PyObject
*
)
utc_time
,
local
_time
);
delta
=
datetime_subtract
(
local_time
,
(
PyObject
*
)
utc
_time
);
/* XXX: before relying on tzname, we should compare delta
to the offset implied by timezone/altzone */
if
(
daylight
&&
timep
->
tm_isdst
>=
0
)
...
...
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