From 2f8969c604e76a0a322803c8760ee33f42de8a59 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 1 Jan 2020 12:01:03 +0100 Subject: [PATCH] time: Windows fix --- vlib/time/time.v | 22 ---------------------- vlib/time/time_nix.v | 29 +++++++++++++++++++++++++++++ vlib/time/time_windows.v | 27 +++++++++++++++++++++++++++ vlib/v/parser/parser.v | 6 ++---- 4 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 vlib/time/time_nix.v create mode 100644 vlib/time/time_windows.v diff --git a/vlib/time/time.v b/vlib/time/time.v index 37ae039fe9..26a4478350 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -72,16 +72,6 @@ fn remove_me_when_c_bug_is_fixed() { pub struct C.time_t { } -struct C.tm { - tm_year int - tm_mon int - tm_mday int - tm_hour int - tm_min int - tm_sec int - tm_gmtoff int // seconds -} - fn C.time(int) C.time_t @@ -98,18 +88,6 @@ pub fn random() Time { return time.unix(rand_unix) } -pub fn convert_ctime(t tm) Time { - return Time{ - year: t.tm_year + 1900 - month: t.tm_mon + 1 - day: t.tm_mday - hour: t.tm_hour - minute: t.tm_min - second: t.tm_sec - unix: C.mktime(&t) - }.add_seconds(t.tm_gmtoff) -} - // format_ss returns a string for t in a given format YYYY-MM-DD HH:MM:SS in // 24h notation // @param diff --git a/vlib/time/time_nix.v b/vlib/time/time_nix.v new file mode 100644 index 0000000000..e4b4ab3e5b --- /dev/null +++ b/vlib/time/time_nix.v @@ -0,0 +1,29 @@ +// Copyright (c) 2019 Alexander Medvednikov. All rights reserved. +// Use of this source code is governed by an MIT license +// that can be found in the LICENSE file. +module time + +struct C.tm { + tm_year int + tm_mon int + tm_mday int + tm_hour int + tm_min int + tm_sec int + tm_gmtoff int // seconds +} + +pub fn convert_ctime(t tm) Time { + return Time{ + year: t.tm_year + 1900 + month: t.tm_mon + 1 + day: t.tm_mday + hour: t.tm_hour + minute: t.tm_min + second: t.tm_sec + unix: C.mktime(&t) + }.add_seconds(t.tm_gmtoff) +} + + + diff --git a/vlib/time/time_windows.v b/vlib/time/time_windows.v new file mode 100644 index 0000000000..b36cb24bb5 --- /dev/null +++ b/vlib/time/time_windows.v @@ -0,0 +1,27 @@ +// Copyright (c) 2019 Alexander Medvednikov. All rights reserved. +// Use of this source code is governed by an MIT license +// that can be found in the LICENSE file. +module time + +struct C.tm { + tm_year int + tm_mon int + tm_mday int + tm_hour int + tm_min int + tm_sec int + //tm_gmtoff int // seconds +} + +pub fn convert_ctime(t tm) Time { + return Time{ + year: t.tm_year + 1900 + month: t.tm_mon + 1 + day: t.tm_mday + hour: t.tm_hour + minute: t.tm_min + second: t.tm_sec + unix: C.mktime(&t) + }//.add_seconds(t.tm_gmtoff) +} + diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 413fee4a23..492b811969 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -282,11 +282,9 @@ pub fn (p mut Parser) call_expr() (ast.CallExpr,types.Type) { if p.tok.kind == .comma { p.error('too many arguments in call to `$fn_name`') } + // }else{ + // p.error('unknown function `$fn_name`') } - // else{ - // p.error('unknown function `$fn_name`') - // } - // exit(0) p.check(.rpar) node := ast.CallExpr{ name: fn_name