File tree 3 files changed +10
-0
lines changed
3 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ pub fn parse(s string) Time {
19
19
return res
20
20
}
21
21
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.
22
27
pub fn parse_iso8601 (s string ) ! Time {
23
28
return parse (s)
24
29
}
Original file line number Diff line number Diff line change 1
1
module time
2
2
3
+ // now returns the current local time.
3
4
pub fn now () Time {
4
5
mut res := Time{}
5
6
#let date = new Date()
@@ -15,6 +16,7 @@ pub fn now() Time {
15
16
return res
16
17
}
17
18
19
+ // utc returns the current UTC time.
18
20
pub fn utc () Time {
19
21
mut res := Time{}
20
22
#let date = new Date()
@@ -61,6 +63,8 @@ fn time_with_unix(t Time) Time {
61
63
return res
62
64
}
63
65
66
+ // ticks returns the number of milliseconds since the UNIX epoch.
67
+ // // On Windows ticks returns the number of milliseconds elapsed since system start.
64
68
pub fn ticks () i64 {
65
69
t := i64 (0 )
66
70
#t.val = BigInt(new Date().getTime())
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ pub enum FormatDelimiter {
84
84
no_delimiter
85
85
}
86
86
87
+ // Time.new static method returns a time struct with the calculated Unix time.
87
88
pub fn Time .new (t Time) Time {
88
89
return time_with_unix (t)
89
90
}
You can’t perform that action at this time.
0 commit comments