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
6d78a582
Kaydet (Commit)
6d78a582
authored
Nis 28, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bug #1478429: make datetime.datetime.fromtimestamp accept every float,
possibly "rounding up" to the next whole second.
üst
6a907d8b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
test_datetime.py
Lib/test/test_datetime.py
+6
-0
datetimemodule.c
Modules/datetimemodule.c
+7
-0
No files found.
Lib/test/test_datetime.py
Dosyayı görüntüle @
6d78a582
...
...
@@ -1400,6 +1400,12 @@ class TestDateTime(TestDate):
got
=
self
.
theclass
.
utcfromtimestamp
(
ts
)
self
.
verify_field_equality
(
expected
,
got
)
def
test_microsecond_rounding
(
self
):
# Test whether fromtimestamp "rounds up" floats that are less
# than one microsecond smaller than an integer.
self
.
assertEquals
(
self
.
theclass
.
fromtimestamp
(
0.9999999
),
self
.
theclass
.
fromtimestamp
(
1
))
def
test_insane_fromtimestamp
(
self
):
# It's possible that some platform maps time_t to double,
# and that this test will fail there. This test should
...
...
Modules/datetimemodule.c
Dosyayı görüntüle @
6d78a582
...
...
@@ -3683,6 +3683,13 @@ datetime_from_timestamp(PyObject *cls, TM_FUNC f, double timestamp,
return
NULL
;
fraction
=
timestamp
-
(
double
)
timet
;
us
=
(
int
)
round_to_long
(
fraction
*
1e6
);
/* If timestamp is less than one microsecond smaller than a
* full second, round up. Otherwise, ValueErrors are raised
* for some floats. */
if
(
us
==
1000000
)
{
timet
+=
1
;
us
=
0
;
}
return
datetime_from_timet_and_us
(
cls
,
f
,
timet
,
us
,
tzinfo
);
}
...
...
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