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
fa09beb1
Kaydet (Commit)
fa09beb1
authored
Mar 30, 2015
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23485: Add _PyTime_FromMillisecondsObject() function
üst
749a6a85
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
pytime.h
Include/pytime.h
+7
-1
pytime.c
Python/pytime.c
+18
-5
No files found.
Include/pytime.h
Dosyayı görüntüle @
fa09beb1
...
...
@@ -69,12 +69,18 @@ PyAPI_FUNC(int) _PyTime_ObjectToTimespec(
/* Create a timestamp from a number of nanoseconds (C long). */
PyAPI_FUNC
(
_PyTime_t
)
_PyTime_FromNanoseconds
(
PY_LONG_LONG
ns
);
/* Convert a
Python float or int
to a timetamp.
/* Convert a
number of seconds (Python float or int)
to a timetamp.
Raise an exception and return -1 on error, return 0 on success. */
PyAPI_FUNC
(
int
)
_PyTime_FromSecondsObject
(
_PyTime_t
*
t
,
PyObject
*
obj
,
_PyTime_round_t
round
);
/* Convert a number of milliseconds (Python float or int, 10^-3) to a timetamp.
Raise an exception and return -1 on error, return 0 on success. */
PyAPI_FUNC
(
int
)
_PyTime_FromMillisecondsObject
(
_PyTime_t
*
t
,
PyObject
*
obj
,
_PyTime_round_t
round
);
/* Convert a timestamp to a number of seconds as a C double. */
PyAPI_FUNC
(
double
)
_PyTime_AsSecondsDouble
(
_PyTime_t
t
);
...
...
Python/pytime.c
Dosyayı görüntüle @
fa09beb1
...
...
@@ -203,8 +203,9 @@ _PyTime_FromTimeval(_PyTime_t *tp, struct timeval *tv, int raise)
}
#endif
int
_PyTime_FromSecondsObject
(
_PyTime_t
*
t
,
PyObject
*
obj
,
_PyTime_round_t
round
)
static
int
_PyTime_FromObject
(
_PyTime_t
*
t
,
PyObject
*
obj
,
_PyTime_round_t
round
,
long
to_nanoseconds
)
{
if
(
PyFloat_Check
(
obj
))
{
/* volatile avoids unsafe optimization on float enabled by gcc -O3 */
...
...
@@ -212,7 +213,7 @@ _PyTime_FromSecondsObject(_PyTime_t *t, PyObject *obj, _PyTime_round_t round)
/* convert to a number of nanoseconds */
d
=
PyFloat_AsDouble
(
obj
);
d
*=
1e9
;
d
*=
to_nanoseconds
;
if
(
round
==
_PyTime_ROUND_CEILING
)
d
=
ceil
(
d
);
...
...
@@ -242,8 +243,8 @@ _PyTime_FromSecondsObject(_PyTime_t *t, PyObject *obj, _PyTime_round_t round)
_PyTime_overflow
();
return
-
1
;
}
*
t
=
sec
*
SEC_TO_NS
;
if
(
*
t
/
SEC_TO_NS
!=
sec
)
{
*
t
=
sec
*
to_nanoseconds
;
if
(
*
t
/
to_nanoseconds
!=
sec
)
{
_PyTime_overflow
();
return
-
1
;
}
...
...
@@ -251,6 +252,18 @@ _PyTime_FromSecondsObject(_PyTime_t *t, PyObject *obj, _PyTime_round_t round)
}
}
int
_PyTime_FromSecondsObject
(
_PyTime_t
*
t
,
PyObject
*
obj
,
_PyTime_round_t
round
)
{
return
_PyTime_FromObject
(
t
,
obj
,
round
,
SEC_TO_NS
);
}
int
_PyTime_FromMillisecondsObject
(
_PyTime_t
*
t
,
PyObject
*
obj
,
_PyTime_round_t
round
)
{
return
_PyTime_FromObject
(
t
,
obj
,
round
,
MS_TO_NS
);
}
double
_PyTime_AsSecondsDouble
(
_PyTime_t
t
)
{
...
...
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