From d03f0ec294badb15ae8b53e811e9974de9761bcc Mon Sep 17 00:00:00 2001 From: yatsen1 Date: Mon, 23 Dec 2019 18:25:44 +0800 Subject: [PATCH] fix time.parse() --- vlib/time/time.v | 2 +- vlib/time/time_test.v | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/vlib/time/time.v b/vlib/time/time.v index a19fa35ca9..4fc4d97383 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -306,7 +306,7 @@ pub fn parse(s string) Time { } shms := s[pos..] hms := shms.split(':') - hour := hms[0] + hour := hms[0][1..] minute := hms[1] second := hms[2] // ////////// diff --git a/vlib/time/time_test.v b/vlib/time/time_test.v index d369112bc7..9a4f147097 100644 --- a/vlib/time/time_test.v +++ b/vlib/time/time_test.v @@ -177,3 +177,11 @@ fn test_get_fmt_str() { .dot, .hhmmss24, .ddmmyyyy ) } + +fn test_parse() { + s := '2018-01-27 12:48:34' + t := time.parse(s) + assert t.year == 2018 && t.month == 1 && t.day == 27 + && t.hour == 12 && t.minute == 48 && t.second == 34 +} +