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/time.js.v | |
download | cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.gz cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.bz2 cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.zip |
Diffstat (limited to 'v_windows/v/vlib/time/time.js.v')
-rw-r--r-- | v_windows/v/vlib/time/time.js.v | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/v_windows/v/vlib/time/time.js.v b/v_windows/v/vlib/time/time.js.v new file mode 100644 index 0000000..9d08e08 --- /dev/null +++ b/v_windows/v/vlib/time/time.js.v @@ -0,0 +1,38 @@ +module time + +pub fn now() Time { + mut res := Time{} + #let date = new Date() + #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 utc() Time { + mut res := Time{} + #let date = new Date() + #res.year.val = date.getUTCFullYear() + #res.month.val = date.getUTCMonth() + #res.day.val = date.getUTCDay() + #res.hour.val = date.getUTCHours() + #res.minute.val = date.getUTCMinutes() + #res.second.val = date.getUTCSeconds() + #res.microsecond.val = date.getUTCMilliseconds() * 1000 + #res.unix.val = (date.getTime() / 1000).toFixed(0) + + return res +} + +/// Returns local time +pub fn (t Time) local() Time { + // TODO: Does this actually correct? JS clock is always set to timezone or no? + // if it is not we should try to use Intl for getting local time. + return t +} |