time: change type of duration constants from i64 to Duration (#7435)
parent
9f964c9ce0
commit
c69947160b
|
@ -380,11 +380,11 @@ pub type Duration = i64
|
||||||
|
|
||||||
pub const (
|
pub const (
|
||||||
nanosecond = Duration(1)
|
nanosecond = Duration(1)
|
||||||
microsecond = Duration(1000) * nanosecond
|
microsecond = Duration(1000 * nanosecond)
|
||||||
millisecond = Duration(1000) * microsecond
|
millisecond = Duration(1000 * microsecond)
|
||||||
second = Duration(1000) * millisecond
|
second = Duration(1000 * millisecond)
|
||||||
minute = Duration(60) * second
|
minute = Duration(60 * second)
|
||||||
hour = Duration(60) * minute
|
hour = Duration(60 * minute)
|
||||||
infinite = Duration(-1)
|
infinite = Duration(-1)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -108,8 +108,8 @@ pub fn (d Duration) timespec() C.timespec {
|
||||||
d_nsec := d % second
|
d_nsec := d % second
|
||||||
ts.tv_sec += d_sec
|
ts.tv_sec += d_sec
|
||||||
ts.tv_nsec += d_nsec
|
ts.tv_nsec += d_nsec
|
||||||
if ts.tv_nsec > second {
|
if ts.tv_nsec > i64(second) {
|
||||||
ts.tv_nsec -= second
|
ts.tv_nsec -= i64(second)
|
||||||
ts.tv_sec++
|
ts.tv_sec++
|
||||||
}
|
}
|
||||||
return ts
|
return ts
|
||||||
|
|
Loading…
Reference in New Issue