diff options
author | Indrajith K L | 2022-12-03 17:00:20 +0530 |
---|---|---|
committer | Indrajith K L | 2022-12-03 17:00:20 +0530 |
commit | f5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch) | |
tree | 2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/time/parse.js.v | |
download | cli-tools-windows-master.tar.gz cli-tools-windows-master.tar.bz2 cli-tools-windows-master.zip |
Diffstat (limited to 'v_windows/v/vlib/time/parse.js.v')
-rw-r--r-- | v_windows/v/vlib/time/parse.js.v | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/v_windows/v/vlib/time/parse.js.v b/v_windows/v/vlib/time/parse.js.v new file mode 100644 index 0000000..1303561 --- /dev/null +++ b/v_windows/v/vlib/time/parse.js.v @@ -0,0 +1,24 @@ +module time + +// parse returns time from a date string. +// +// TODO(playX): JS Date expects iso8061 format of strings and other formats +// are implementation dependant, we probably want to implement parsing in JS. +pub fn parse(s string) Time { + mut res := Time{} + #let date = new Date(s.str) + #res.year.val = date.getFullYear() + #res.month.val = date.getMonth() + #res.day.val = date.getDay() + #res.hour.val = date.getHours() + #res.minute.val = date.getMinutes() + #res.second.val = date.getSeconds() + #res.microsecond.val = date.getMilliseconds() * 1000 + #res.unix.val = (date.getTime() / 1000).toFixed(0) + + return res +} + +pub fn parse_iso8601(s string) ?Time { + return parse(s) +} |