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
72a80e85
Kaydet (Commit)
72a80e85
authored
Haz 26, 2012
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
issue13666 - Fixing datetime documentation example when using tzinfo
üst
f21804ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
datetime.rst
Doc/library/datetime.rst
+9
-10
No files found.
Doc/library/datetime.rst
Dosyayı görüntüle @
72a80e85
...
@@ -1127,14 +1127,14 @@ Using datetime with tzinfo:
...
@@ -1127,14 +1127,14 @@ Using datetime with tzinfo:
>>> from datetime import timedelta, datetime, tzinfo
>>> from datetime import timedelta, datetime, tzinfo
>>> class GMT1(tzinfo):
>>> class GMT1(tzinfo):
... def __init__(self): # DST starts last Sunday in March
... def utcoffset(self, dt):
... return timedelta(hours=1) + self.dst(dt)
... def dst(self, dt):
... # DST starts last Sunday in March
... d = datetime(dt.year, 4, 1) # ends last Sunday in October
... d = datetime(dt.year, 4, 1) # ends last Sunday in October
... self.dston = d - timedelta(days=d.weekday() + 1)
... self.dston = d - timedelta(days=d.weekday() + 1)
... d = datetime(dt.year, 11, 1)
... d = datetime(dt.year, 11, 1)
... self.dstoff = d - timedelta(days=d.weekday() + 1)
... self.dstoff = d - timedelta(days=d.weekday() + 1)
... def utcoffset(self, dt):
... return timedelta(hours=1) + self.dst(dt)
... def dst(self, dt):
... if self.dston <= dt.replace(tzinfo=None) < self.dstoff:
... if self.dston <= dt.replace(tzinfo=None) < self.dstoff:
... return timedelta(hours=1)
... return timedelta(hours=1)
... else:
... else:
...
@@ -1143,16 +1143,15 @@ Using datetime with tzinfo:
...
@@ -1143,16 +1143,15 @@ Using datetime with tzinfo:
... return "GMT +1"
... return "GMT +1"
...
...
>>> class GMT2(tzinfo):
>>> class GMT2(tzinfo):
... def __init__(self):
... def utcoffset(self, dt):
... return timedelta(hours=2) + self.dst(dt)
... def dst(self, dt):
... d = datetime(dt.year, 4, 1)
... d = datetime(dt.year, 4, 1)
... self.dston = d - timedelta(days=d.weekday() + 1)
... self.dston = d - timedelta(days=d.weekday() + 1)
... d = datetime(dt.year, 11, 1)
... d = datetime(dt.year, 11, 1)
... self.dstoff = d - timedelta(days=d.weekday() + 1)
... self.dstoff = d - timedelta(days=d.weekday() + 1)
... def utcoffset(self, dt):
... return timedelta(hours=1) + self.dst(dt)
... def dst(self, dt):
... if self.dston <= dt.replace(tzinfo=None) < self.dstoff:
... if self.dston <= dt.replace(tzinfo=None) < self.dstoff:
... return timedelta(hours=
2
)
... return timedelta(hours=
1
)
... else:
... else:
... return timedelta(0)
... return timedelta(0)
... def tzname(self,dt):
... def tzname(self,dt):
...
@@ -1545,7 +1544,7 @@ When DST starts (the "start" line), the local wall clock leaps from 1:59 to
...
@@ -1545,7 +1544,7 @@ When DST starts (the "start" line), the local wall clock leaps from 1:59 to
3:00. A wall time of the form 2:MM doesn't really make sense on that day, so
3:00. A wall time of the form 2:MM doesn't really make sense on that day, so
``astimezone(Eastern)`` won't deliver a result with ``hour == 2`` on the day DST
``astimezone(Eastern)`` won't deliver a result with ``hour == 2`` on the day DST
begins. In order for :meth:`astimezone` to make this guarantee, the
begins. In order for :meth:`astimezone` to make this guarantee, the
:meth:`
r
zinfo.dst` method must consider times in the "missing hour" (2:MM for
:meth:`
t
zinfo.dst` method must consider times in the "missing hour" (2:MM for
Eastern) to be in daylight time.
Eastern) to be in daylight time.
When DST ends (the "end" line), there's a potentially worse problem: there's an
When DST ends (the "end" line), there's a potentially worse problem: there's an
...
...
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