From cc8948efcffe1a9013a135117ab3e3739e798b19 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 5 Apr 2021 15:31:29 +0300 Subject: [PATCH] time: fix compilation on macos --- vlib/time/time.v | 2 ++ vlib/time/time_darwin.c.v | 3 ++- vlib/time/time_nix.c.v | 2 -- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/vlib/time/time.v b/vlib/time/time.v index 0b80b26aac..c6e4503f1f 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -5,6 +5,8 @@ module time #include +type time_t = i64 + pub const ( days_string = 'MonTueWedThuFriSatSun' month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] diff --git a/vlib/time/time_darwin.c.v b/vlib/time/time_darwin.c.v index dc92c02175..7adf87da5b 100644 --- a/vlib/time/time_darwin.c.v +++ b/vlib/time/time_darwin.c.v @@ -67,7 +67,8 @@ fn darwin_now() Time { tv := C.timeval{} C.gettimeofday(&tv, 0) loc_tm := C.tm{} - C.localtime_r(&tv.tv_sec, &loc_tm) + asec := voidptr(&tv.tv_sec) + C.localtime_r(&time_t(asec), &loc_tm) return convert_ctime(loc_tm, int(tv.tv_usec)) } diff --git a/vlib/time/time_nix.c.v b/vlib/time/time_nix.c.v index c94a73b50c..2e274b9726 100644 --- a/vlib/time/time_nix.c.v +++ b/vlib/time/time_nix.c.v @@ -34,8 +34,6 @@ pub fn (t Time) local() Time { return convert_ctime(loc_tm, t.microsecond) } -type time_t = i64 - // in most systems, these are __quad_t, which is an i64 struct C.timespec { mut: