From c69947160b453aa40a46eb880e31be94d6b83ff8 Mon Sep 17 00:00:00 2001 From: zakuro Date: Mon, 21 Dec 2020 17:27:06 +0900 Subject: [PATCH] time: change type of duration constants from i64 to Duration (#7435) --- vlib/time/time.v | 10 +++++----- vlib/time/time_nix.c.v | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/vlib/time/time.v b/vlib/time/time.v index 2cc8bf3f76..371f633437 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -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) ) diff --git a/vlib/time/time_nix.c.v b/vlib/time/time_nix.c.v index 49efe0ab46..0e7e630e62 100644 --- a/vlib/time/time_nix.c.v +++ b/vlib/time/time_nix.c.v @@ -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