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 (
|
||||
nanosecond = Duration(1)
|
||||
microsecond = Duration(1000) * nanosecond
|
||||
millisecond = Duration(1000) * microsecond
|
||||
second = Duration(1000) * millisecond
|
||||
minute = Duration(60) * second
|
||||
hour = Duration(60) * minute
|
||||
microsecond = Duration(1000 * nanosecond)
|
||||
millisecond = Duration(1000 * microsecond)
|
||||
second = Duration(1000 * millisecond)
|
||||
minute = Duration(60 * second)
|
||||
hour = Duration(60 * minute)
|
||||
infinite = Duration(-1)
|
||||
)
|
||||
|
||||
|
|
|
@ -108,8 +108,8 @@ pub fn (d Duration) timespec() C.timespec {
|
|||
d_nsec := d % second
|
||||
ts.tv_sec += d_sec
|
||||
ts.tv_nsec += d_nsec
|
||||
if ts.tv_nsec > second {
|
||||
ts.tv_nsec -= second
|
||||
if ts.tv_nsec > i64(second) {
|
||||
ts.tv_nsec -= i64(second)
|
||||
ts.tv_sec++
|
||||
}
|
||||
return ts
|
||||
|
|
Loading…
Reference in New Issue