time: change type of duration constants from i64 to Duration (#7435)

pull/7444/head
zakuro 2020-12-21 17:27:06 +09:00 committed by GitHub
parent 9f964c9ce0
commit c69947160b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -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)
)

View File

@ -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