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
aeb03986
Kaydet (Commit)
aeb03986
authored
Tem 26, 2010
tarafından
Alexander Belopolsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make python version of fromtimestamp behave more like C.
üst
0f0c3320
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
datetime.py
Lib/datetime.py
+13
-9
datetimetester.py
Lib/test/datetimetester.py
+7
-1
No files found.
Lib/datetime.py
Dosyayı görüntüle @
aeb03986
...
...
@@ -1356,16 +1356,20 @@ class datetime(date):
"""
_check_tzinfo_arg
(
tz
)
if
tz
is
None
:
converter
=
_time
.
localtime
else
:
converter
=
_time
.
gmtime
if
1
-
(
t
%
1.0
)
<
0.000001
:
t
=
float
(
int
(
t
))
+
1
if
t
<
0
:
t
-=
1
converter
=
_time
.
localtime
if
tz
is
None
else
_time
.
gmtime
t
,
frac
=
divmod
(
t
,
1.0
)
us
=
round
(
frac
*
1e6
)
# If timestamp is less than one microsecond smaller than a
# full second, us can be rounded up to 1000000. In this case,
# roll over to seconds, otherwise, ValueError is raised
# by the constructor.
if
us
==
1000000
:
t
+=
1
us
=
0
y
,
m
,
d
,
hh
,
mm
,
ss
,
weekday
,
jday
,
dst
=
converter
(
t
)
us
=
int
((
t
%
1.0
)
*
1000000
)
ss
=
min
(
ss
,
59
)
# clamp out leap seconds if the platform has them
result
=
cls
(
y
,
m
,
d
,
hh
,
mm
,
ss
,
us
,
tz
)
if
tz
is
not
None
:
...
...
Lib/test/datetimetester.py
Dosyayı görüntüle @
aeb03986
...
...
@@ -1728,9 +1728,15 @@ class TestDateTime(TestDate):
def
test_microsecond_rounding
(
self
):
# Test whether fromtimestamp "rounds up" floats that are less
# than
one
microsecond smaller than an integer.
# than
1/2
microsecond smaller than an integer.
self
.
assertEqual
(
self
.
theclass
.
fromtimestamp
(
0.9999999
),
self
.
theclass
.
fromtimestamp
(
1
))
self
.
assertEqual
(
self
.
theclass
.
fromtimestamp
(
0.99999949
)
.
microsecond
,
999999
)
# XXX Arguably incorrect behavior. Since round(0.6112295, 6)
# returns 0.611229, we should see 611229 us below, not 611230
self
.
assertEqual
(
self
.
theclass
.
fromtimestamp
(
0.6112295
)
.
microsecond
,
611230
)
def
test_insane_fromtimestamp
(
self
):
# It's possible that some platform maps time_t to double,
...
...
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