diff --git a/.github/workflows/docs_ci.yml b/.github/workflows/docs_ci.yml index cc071499b7..a5221fe060 100644 --- a/.github/workflows/docs_ci.yml +++ b/.github/workflows/docs_ci.yml @@ -69,4 +69,5 @@ jobs: vlib/builtin/ vlib/arrays/ vlib/flag/ \ vlib/bitfield/ vlib/term/ vlib/strings/ \ vlib/rand/ vlib/compress/ vlib/clipboard/ \ + vlib/time/ \ vlib/os diff --git a/vlib/time/chrono.c.v b/vlib/time/chrono.c.v index f95dc8d230..0f69ef8a09 100644 --- a/vlib/time/chrono.c.v +++ b/vlib/time/chrono.c.v @@ -1,7 +1,6 @@ module time -// portable_timegm does the same as C._mkgmtime, but unlike it, -// can work with dates before the Unix epoch of 1970-01-01 . +// portable_timegm does the same as C._mkgmtime, but unlike it, can work with dates before the Unix epoch of 1970-01-01 . pub fn portable_timegm(t &C.tm) i64 { mut year := t.tm_year + 1900 mut month := t.tm_mon // 0-11 diff --git a/vlib/time/duration.v b/vlib/time/duration.v index 2f6c35cb36..2d61394a0b 100644 --- a/vlib/time/duration.v +++ b/vlib/time/duration.v @@ -91,7 +91,7 @@ pub fn (d Duration) str() string { } } -// debug returns a detailed breakdown of the Duration, as: 'Duration: - 50days, 4h, 3m, 7s, 541ms, 78us, 9ns' +// debug returns a detailed breakdown of the Duration, as: 'Duration: - 50days, 4h, 3m, 7s, 541ms, 78us, 9ns'. pub fn (d Duration) debug() string { mut res := []string{} mut x := i64(d) diff --git a/vlib/time/format.v b/vlib/time/format.v index e7cfc4f560..691640d997 100644 --- a/vlib/time/format.v +++ b/vlib/time/format.v @@ -562,7 +562,8 @@ pub fn (t Time) custom_format(s string) string { return sb.str() } -// clean returns a date string in a following format: +// clean returns a date string in a clean form. +// It has the following format: // - a date string in "HH:mm" format (24h) for current day // - a date string in "MMM D HH:mm" format (24h) for date of current year // - a date string formatted with format function for other dates @@ -579,7 +580,8 @@ pub fn (t Time) clean() string { return t.format() } -// clean12 returns a date string in a following format: +// clean12 returns a date string in a clean form. +// It has the following format: // - a date string in "hh:mm" format (12h) for current day // - a date string in "MMM D hh:mm" format (12h) for date of current year // - a date string formatted with format function for other dates @@ -653,8 +655,7 @@ pub fn (t Time) get_fmt_date_str(fmt_dlmtr FormatDelimiter, fmt_date FormatDate) return res } -// get_fmt_str returns a date string with specified FormatDelimiter, -// FormatTime type, and FormatDate type. +// get_fmt_str returns a date string with specified FormatDelimiter, FormatTime type, and FormatDate type. pub fn (t Time) get_fmt_str(fmt_dlmtr FormatDelimiter, fmt_time FormatTime, fmt_date FormatDate) string { if fmt_date == .no_date { if fmt_time == .no_time { diff --git a/vlib/time/stopwatch.v b/vlib/time/stopwatch.v index 29cb114a39..4b8de8ccbd 100644 --- a/vlib/time/stopwatch.v +++ b/vlib/time/stopwatch.v @@ -61,7 +61,7 @@ pub fn (mut t StopWatch) pause() { t.start = 0 } -// elapsed returns the Duration since the last start call +// elapsed returns the Duration since the last start call. pub fn (t StopWatch) elapsed() Duration { if t.start > 0 { if t.end == 0 { diff --git a/vlib/time/time.c.v b/vlib/time/time.c.v index 83d06862a2..aefcc67f50 100644 --- a/vlib/time/time.c.v +++ b/vlib/time/time.c.v @@ -115,7 +115,7 @@ fn convert_ctime(t C.tm, nanosecond int) Time { } } -// strftime returns the formatted time using `strftime(3)` +// strftime returns the formatted time using `strftime(3)`. pub fn (t Time) strftime(fmt string) string { mut tm := &C.tm{} $if windows { diff --git a/vlib/time/time.v b/vlib/time/time.v index 4b522e83b2..8b82041264 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -279,8 +279,7 @@ pub fn (t Time) relative_short() string { return '${prefix}${y}y${suffix}' } -// day_of_week returns the current day of a given year, month, and day, -// as an integer. +// day_of_week returns the current day of a given year, month, and day, as an integer. pub fn day_of_week(y int, m int, d int) int { // Sakomotho's algorithm is explained here: // https://stackoverflow.com/a/6385934 @@ -365,7 +364,7 @@ pub fn days_in_month(month int, year int) !int { return res } -// debug returns detailed breakdown of time (`Time{ year: YYYY month: MM day: dd hour: HH: minute: mm second: ss nanosecond: nanos unix: unix }`) +// debug returns detailed breakdown of time (`Time{ year: YYYY month: MM day: dd hour: HH: minute: mm second: ss nanosecond: nanos unix: unix }`). pub fn (t Time) debug() string { return 'Time{ year: ${t.year:04} month: ${t.month:02} day: ${t.day:02} hour: ${t.hour:02} minute: ${t.minute:02} second: ${t.second:02} nanosecond: ${t.nanosecond:09} unix: ${t.unix:07} }' } diff --git a/vlib/time/time_windows.c.v b/vlib/time/time_windows.c.v index 3d64b91b05..52dc41cef1 100644 --- a/vlib/time/time_windows.c.v +++ b/vlib/time/time_windows.c.v @@ -99,7 +99,7 @@ fn local_as_unix_time() i64 { return make_unix_time(*tm) } -// local - return the time `t`, converted to the currently active local timezone +// local - return the time `t`, converted to the currently active local timezone. pub fn (t Time) local() Time { if t.is_local { return t diff --git a/vlib/time/unix.v b/vlib/time/unix.v index f91fcf9824..87b93faf9b 100644 --- a/vlib/time/unix.v +++ b/vlib/time/unix.v @@ -3,22 +3,22 @@ // that can be found in the LICENSE file. module time -// unix returns a Time calculated from the given Unix timestamp in seconds since 1970-01-01 +// unix returns a Time calculated from the given Unix timestamp in seconds since 1970-01-01 . pub fn unix(epoch i64) Time { return unix_nanosecond(epoch, 0) } -// unix_milli returns a Time calculated from the given Unix timestamp in milliseconds since 1970-01-01 +// unix_milli returns a Time calculated from the given Unix timestamp in milliseconds since 1970-01-01 . pub fn unix_milli(ms i64) Time { return ts_to_time_impl(ms, 1_000, 1_000_000) } -// unix_micro returns a Time calculated from the given Unix timestamp in microseconds since 1970-01-01 +// unix_micro returns a Time calculated from the given Unix timestamp in microseconds since 1970-01-01 . pub fn unix_micro(us i64) Time { return ts_to_time_impl(us, 1_000_000, 1_000) } -// unix_nano returns a Time calculated from the given Unix timestamp in nanoseconds since 1970-01-01 +// unix_nano returns a Time calculated from the given Unix timestamp in nanoseconds since 1970-01-01 . pub fn unix_nano(ns i64) Time { return ts_to_time_impl(ns, 1_000_000_000, 1) } @@ -29,12 +29,12 @@ fn ts_to_time_impl(value i64, down i64, up i64) Time { return unix_nanosecond(epoch, int(remainder)) } -// unix_microsecond returns a Time struct, given an Unix timestamp in seconds, and a microsecond value +// unix_microsecond returns a Time struct, given an Unix timestamp in seconds, and a microsecond value. pub fn unix_microsecond(epoch i64, microsecond int) Time { return unix_nanosecond(epoch, microsecond * 1000) } -// unix_nanosecond returns a Time struct given a Unix timestamp in seconds and a nanosecond value +// unix_nanosecond returns a Time struct given a Unix timestamp in seconds and a nanosecond value. pub fn unix_nanosecond(abs_unix_timestamp i64, nanosecond int) Time { // Split into day and time mut day_offset := abs_unix_timestamp / seconds_per_day