Skip to content

Commit a74f317

Browse files
authored
time: add documentation for remaining time-related functions and ISO 8601 parsing (#23867)
1 parent 2dc5f68 commit a74f317

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

vlib/time/parse.js.v

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ pub fn parse(s string) Time {
1919
return res
2020
}
2121

22+
// parse_iso8601 parses the ISO 8601 time format yyyy-MM-ddTHH:mm:ss.dddddd+dd:dd as local time.
23+
// The fraction part is difference in milli seconds, and the last part is offset from UTC time.
24+
// Both can be +/- HH:mm .
25+
// See https://en.wikipedia.org/wiki/ISO_8601 .
26+
// Remarks: not all of ISO 8601 is supported; checks and support for leapseconds should be added.
2227
pub fn parse_iso8601(s string) !Time {
2328
return parse(s)
2429
}

vlib/time/time.js.v

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module time
22

3+
// now returns the current local time.
34
pub fn now() Time {
45
mut res := Time{}
56
#let date = new Date()
@@ -15,6 +16,7 @@ pub fn now() Time {
1516
return res
1617
}
1718

19+
// utc returns the current UTC time.
1820
pub fn utc() Time {
1921
mut res := Time{}
2022
#let date = new Date()
@@ -61,6 +63,8 @@ fn time_with_unix(t Time) Time {
6163
return res
6264
}
6365

66+
// ticks returns the number of milliseconds since the UNIX epoch.
67+
// // On Windows ticks returns the number of milliseconds elapsed since system start.
6468
pub fn ticks() i64 {
6569
t := i64(0)
6670
#t.val = BigInt(new Date().getTime())

vlib/time/time.v

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pub enum FormatDelimiter {
8484
no_delimiter
8585
}
8686

87+
// Time.new static method returns a time struct with the calculated Unix time.
8788
pub fn Time.new(t Time) Time {
8889
return time_with_unix(t)
8990
}

0 commit comments

Comments
 (0)