Skip to content

Commit 62c69e8

Browse files
authored
docs: improve formatting in time.parse_format description (#22113)
1 parent d1b20be commit 62c69e8

File tree

3 files changed

+65
-44
lines changed

3 files changed

+65
-44
lines changed

cmd/tools/vdoc/theme/doc.css

+19
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
--attribute-deprecated-background-color: #f59f0b48;
3737
--attribute-deprecated-text-color: #92400e;
3838
--attribute-text-color: #000000cf;
39+
--table-header-line-color: #2c3e64;
40+
--table-background-color: #edf2f7;
3941
}
4042
html.dark {
4143
--background-color: #1a202c;
@@ -73,6 +75,8 @@ html.dark {
7375
--attribute-background-color: #ffffff20;
7476
--attribute-text-color: #ffffffaf;
7577
--attribute-deprecated-text-color: #fef3c7;
78+
--table-header-line-color: #cbd5e0;
79+
--table-background-color: #2d3748;
7680
}
7781
html.dark .dark-icon {
7882
display: none;
@@ -665,6 +669,21 @@ pre {
665669
margin: 0 0 0.4rem 0;
666670
}
667671

672+
table {
673+
border: 1px solid var(--table-background-color);
674+
border-collapse: collapse;
675+
}
676+
table tr td,
677+
table tr th {
678+
padding: 4px 8px;
679+
}
680+
table tr th {
681+
background-color: var(--table-background-color);
682+
}
683+
tr:nth-child(even) {
684+
background-color: var(--table-background-color);
685+
}
686+
668687
/* Medium screen and up */
669688
@media (min-width: 768px) {
670689
*::-webkit-scrollbar {

vlib/time/format.v

+21-21
Original file line numberDiff line numberDiff line change
@@ -287,49 +287,49 @@ const tokens_4 = ['MMMM', 'DDDD', 'DDDo', 'dddd', 'YYYY']
287287

288288
// custom_format returns a date with custom format
289289
//
290-
// | | Token | Output |
291-
// |-----------------:|:------|:---------------------------------------|
292-
// | **Month** | M | 1 2 ... 11 12 |
290+
// | Category | Token | Output |
291+
// |:-----------------|:------|:---------------------------------------|
292+
// | Era | N | BC AD |
293+
// | | NN | Before Christ, Anno Domini |
294+
// | Year | YY | 70 71 ... 29 30 |
295+
// | | YYYY | 1970 1971 ... 2029 2030 |
296+
// | Quarter | Q | 1 2 3 4 |
297+
// | | QQ | 01 02 03 04 |
298+
// | | Qo | 1st 2nd 3rd 4th |
299+
// | Month | M | 1 2 ... 11 12 |
293300
// | | Mo | 1st 2nd ... 11th 12th |
294301
// | | MM | 01 02 ... 11 12 |
295302
// | | MMM | Jan Feb ... Nov Dec |
296303
// | | MMMM | January February ... November December |
297-
// | **Quarter** | Q | 1 2 3 4 |
298-
// | | QQ | 01 02 03 04 |
299-
// | | Qo | 1st 2nd 3rd 4th |
300-
// | **Day of Month** | D | 1 2 ... 30 31 |
304+
// | Week of Year | w | 1 2 ... 52 53 |
305+
// | | wo | 1st 2nd ... 52nd 53rd |
306+
// | | ww | 01 02 ... 52 53 |
307+
// | Day of Month | D | 1 2 ... 30 31 |
301308
// | | Do | 1st 2nd ... 30th 31st |
302309
// | | DD | 01 02 ... 30 31 |
303-
// | **Day of Year** | DDD | 1 2 ... 364 365 |
310+
// | Day of Year | DDD | 1 2 ... 364 365 |
304311
// | | DDDo | 1st 2nd ... 364th 365th |
305312
// | | DDDD | 001 002 ... 364 365 |
306-
// | **Day of Week** | d | 0 1 ... 5 6 (Sun-Sat) |
313+
// | Day of Week | d | 0 1 ... 5 6 (Sun-Sat) |
307314
// | | c | 1 2 ... 6 7 (Mon-Sun) |
308315
// | | dd | Su Mo ... Fr Sa |
309316
// | | ddd | Sun Mon ... Fri Sat |
310317
// | | dddd | Sunday Monday ... Friday Saturday |
311-
// | **Week of Year** | w | 1 2 ... 52 53 |
312-
// | | wo | 1st 2nd ... 52nd 53rd |
313-
// | | ww | 01 02 ... 52 53 |
314-
// | **Year** | YY | 70 71 ... 29 30 |
315-
// | | YYYY | 1970 1971 ... 2029 2030 |
316-
// | **Era** | N | BC AD |
317-
// | | NN | Before Christ, Anno Domini |
318-
// | **AM/PM** | A | AM PM |
318+
// | AM/PM | A | AM PM |
319319
// | | a | am pm |
320-
// | **Hour** | H | 0 1 ... 22 23 |
320+
// | Hour | H | 0 1 ... 22 23 |
321321
// | | HH | 00 01 ... 22 23 |
322322
// | | h | 1 2 ... 11 12 |
323323
// | | hh | 01 02 ... 11 12 |
324324
// | | i | 0 1 ... 11 12 1 ... 11 |
325325
// | | ii | 00 01 ... 11 12 01 ... 11 |
326326
// | | k | 1 2 ... 23 24 |
327327
// | | kk | 01 02 ... 23 24 |
328-
// | **Minute** | m | 0 1 ... 58 59 |
328+
// | Minute | m | 0 1 ... 58 59 |
329329
// | | mm | 00 01 ... 58 59 |
330-
// | **Second** | s | 0 1 ... 58 59 |
330+
// | Second | s | 0 1 ... 58 59 |
331331
// | | ss | 00 01 ... 58 59 |
332-
// | **Offset** | Z | -7 -6 ... +5 +6 |
332+
// | Offset | Z | -7 -6 ... +5 +6 |
333333
// | | ZZ | -0700 -0600 ... +0500 +0600 |
334334
// | | ZZZ | -07:00 -06:00 ... +05:00 +06:00 |
335335
//

vlib/time/parse.c.v

+25-23
Original file line numberDiff line numberDiff line change
@@ -132,29 +132,31 @@ pub fn parse(s string) !Time {
132132

133133
// parse_format parses the string `s`, as a custom `format`, containing the following specifiers:
134134
//
135-
// - YYYY - 4 digit year, 0000..9999
136-
// - YY - 2 digit year, 00..99
137-
// - M - month, 1..12
138-
// - MM - month, 2 digits, 01..12
139-
// - MMM - month, three letters, Jan..Dec
140-
// - MMMM - name of month
141-
// - D - day of the month, 1..31
142-
// - DD - day of the month, 01..31
143-
// - d - day of week, 0..6
144-
// - c - day of week, 1..7
145-
// - dd - day of week, Su..Sa
146-
// - ddd - day of week, Sun..Sat
147-
// - dddd - day of week, Sunday..Saturday
148-
// - H - hour, 0..23
149-
// - HH - hour, 00..23
150-
// - h - hour, 0..23
151-
// - hh - hour, 0..23
152-
// - k - hour, 0..23
153-
// - kk - hour, 0..23
154-
// - m - minute, 0..59
155-
// - mm - minute, 0..59
156-
// - s - second, 0..59
157-
// - ss - second, 0..59
135+
// |Category| Format | Description |
136+
// |:----- | :----- | :---------- |
137+
// |Year | YYYY | 4 digit year, 0000..9999 |
138+
// | | YY | 2 digit year, 00..99 |
139+
// |Month | M | month, 1..12 |
140+
// | | MM | month, 2 digits, 01..12 |
141+
// | | MMM | month, three letters, Jan..Dec |
142+
// | | MMMM | name of month |
143+
// |Day | D | day of the month, 1..31 |
144+
// | | DD | day of the month, 01..31 |
145+
// | | d | day of week, 0..6 |
146+
// | | c | day of week, 1..7 |
147+
// | | dd | day of week, Su..Sa |
148+
// | | ddd | day of week, Sun..Sat |
149+
// | | dddd | day of week, Sunday..Saturday |
150+
// |Hour | H | hour, 0..23 |
151+
// | | HH | hour, 00..23 |
152+
// | | h | hour, 0..23 |
153+
// | | hh | hour, 0..23 |
154+
// | | k | hour, 0..23 |
155+
// | | kk | hour, 0..23 |
156+
// |Minute | m | minute, 0..59 |
157+
// | | mm | minute, 0..59 |
158+
// |Second | s | second, 0..59 |
159+
// | | ss | second, 0..59 |
158160
pub fn parse_format(s string, format string) !Time {
159161
if s == '' {
160162
return error_invalid_time(0, 'datetime string is empty')

0 commit comments

Comments
 (0)