Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: parse_format description formating #22113

Merged
merged 4 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cmd/tools/vdoc/theme/doc.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
--attribute-deprecated-background-color: #f59f0b48;
--attribute-deprecated-text-color: #92400e;
--attribute-text-color: #000000cf;
--table-header-line-color: #2c3e64;
--table-background-color: #edf2f7;
}
html.dark {
--background-color: #1a202c;
Expand Down Expand Up @@ -73,6 +75,8 @@ html.dark {
--attribute-background-color: #ffffff20;
--attribute-text-color: #ffffffaf;
--attribute-deprecated-text-color: #fef3c7;
--table-header-line-color: #cbd5e0;
--table-background-color: #2d3748;
}
html.dark .dark-icon {
display: none;
Expand Down Expand Up @@ -665,6 +669,21 @@ pre {
margin: 0 0 0.4rem 0;
}

table {
border: 1px solid var(--table-background-color);
border-collapse: collapse;
}
table tr td,
table tr th {
padding: 4px 8px;
}
table tr th {
background-color: var(--table-background-color);
}
tr:nth-child(even) {
background-color: var(--table-background-color);
}

/* Medium screen and up */
@media (min-width: 768px) {
*::-webkit-scrollbar {
Expand Down
42 changes: 21 additions & 21 deletions vlib/time/format.v
Original file line number Diff line number Diff line change
Expand Up @@ -287,49 +287,49 @@ const tokens_4 = ['MMMM', 'DDDD', 'DDDo', 'dddd', 'YYYY']

// custom_format returns a date with custom format
//
// | | Token | Output |
// |-----------------:|:------|:---------------------------------------|
// | **Month** | M | 1 2 ... 11 12 |
// | Category | Token | Output |
// |:-----------------|:------|:---------------------------------------|
// | Era | N | BC AD |
// | | NN | Before Christ, Anno Domini |
// | Year | YY | 70 71 ... 29 30 |
// | | YYYY | 1970 1971 ... 2029 2030 |
// | Quarter | Q | 1 2 3 4 |
// | | QQ | 01 02 03 04 |
// | | Qo | 1st 2nd 3rd 4th |
// | Month | M | 1 2 ... 11 12 |
// | | Mo | 1st 2nd ... 11th 12th |
// | | MM | 01 02 ... 11 12 |
// | | MMM | Jan Feb ... Nov Dec |
// | | MMMM | January February ... November December |
// | **Quarter** | Q | 1 2 3 4 |
// | | QQ | 01 02 03 04 |
// | | Qo | 1st 2nd 3rd 4th |
// | **Day of Month** | D | 1 2 ... 30 31 |
// | Week of Year | w | 1 2 ... 52 53 |
// | | wo | 1st 2nd ... 52nd 53rd |
// | | ww | 01 02 ... 52 53 |
// | Day of Month | D | 1 2 ... 30 31 |
// | | Do | 1st 2nd ... 30th 31st |
// | | DD | 01 02 ... 30 31 |
// | **Day of Year** | DDD | 1 2 ... 364 365 |
// | Day of Year | DDD | 1 2 ... 364 365 |
// | | DDDo | 1st 2nd ... 364th 365th |
// | | DDDD | 001 002 ... 364 365 |
// | **Day of Week** | d | 0 1 ... 5 6 (Sun-Sat) |
// | Day of Week | d | 0 1 ... 5 6 (Sun-Sat) |
// | | c | 1 2 ... 6 7 (Mon-Sun) |
// | | dd | Su Mo ... Fr Sa |
// | | ddd | Sun Mon ... Fri Sat |
// | | dddd | Sunday Monday ... Friday Saturday |
// | **Week of Year** | w | 1 2 ... 52 53 |
// | | wo | 1st 2nd ... 52nd 53rd |
// | | ww | 01 02 ... 52 53 |
// | **Year** | YY | 70 71 ... 29 30 |
// | | YYYY | 1970 1971 ... 2029 2030 |
// | **Era** | N | BC AD |
// | | NN | Before Christ, Anno Domini |
// | **AM/PM** | A | AM PM |
// | AM/PM | A | AM PM |
// | | a | am pm |
// | **Hour** | H | 0 1 ... 22 23 |
// | Hour | H | 0 1 ... 22 23 |
// | | HH | 00 01 ... 22 23 |
// | | h | 1 2 ... 11 12 |
// | | hh | 01 02 ... 11 12 |
// | | i | 0 1 ... 11 12 1 ... 11 |
// | | ii | 00 01 ... 11 12 01 ... 11 |
// | | k | 1 2 ... 23 24 |
// | | kk | 01 02 ... 23 24 |
// | **Minute** | m | 0 1 ... 58 59 |
// | Minute | m | 0 1 ... 58 59 |
// | | mm | 00 01 ... 58 59 |
// | **Second** | s | 0 1 ... 58 59 |
// | Second | s | 0 1 ... 58 59 |
// | | ss | 00 01 ... 58 59 |
// | **Offset** | Z | -7 -6 ... +5 +6 |
// | Offset | Z | -7 -6 ... +5 +6 |
// | | ZZ | -0700 -0600 ... +0500 +0600 |
// | | ZZZ | -07:00 -06:00 ... +05:00 +06:00 |
//
Expand Down
48 changes: 25 additions & 23 deletions vlib/time/parse.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -132,29 +132,31 @@ pub fn parse(s string) !Time {

// parse_format parses the string `s`, as a custom `format`, containing the following specifiers:
//
// - YYYY - 4 digit year, 0000..9999
// - YY - 2 digit year, 00..99
// - M - month, 1..12
// - MM - month, 2 digits, 01..12
// - MMM - month, three letters, Jan..Dec
// - MMMM - name of month
// - D - day of the month, 1..31
// - DD - day of the month, 01..31
// - d - day of week, 0..6
// - c - day of week, 1..7
// - dd - day of week, Su..Sa
// - ddd - day of week, Sun..Sat
// - dddd - day of week, Sunday..Saturday
// - H - hour, 0..23
// - HH - hour, 00..23
// - h - hour, 0..23
// - hh - hour, 0..23
// - k - hour, 0..23
// - kk - hour, 0..23
// - m - minute, 0..59
// - mm - minute, 0..59
// - s - second, 0..59
// - ss - second, 0..59
// |Category| Format | Description |
// |:----- | :----- | :---------- |
// |Year | YYYY | 4 digit year, 0000..9999 |
// | | YY | 2 digit year, 00..99 |
// |Month | M | month, 1..12 |
// | | MM | month, 2 digits, 01..12 |
// | | MMM | month, three letters, Jan..Dec |
// | | MMMM | name of month |
// |Day | D | day of the month, 1..31 |
// | | DD | day of the month, 01..31 |
// | | d | day of week, 0..6 |
// | | c | day of week, 1..7 |
// | | dd | day of week, Su..Sa |
// | | ddd | day of week, Sun..Sat |
// | | dddd | day of week, Sunday..Saturday |
// |Hour | H | hour, 0..23 |
// | | HH | hour, 00..23 |
// | | h | hour, 0..23 |
// | | hh | hour, 0..23 |
// | | k | hour, 0..23 |
// | | kk | hour, 0..23 |
// |Minute | m | minute, 0..59 |
// | | mm | minute, 0..59 |
// |Second | s | second, 0..59 |
// | | ss | second, 0..59 |
pub fn parse_format(s string, format string) !Time {
if s == '' {
return error_invalid_time(0, 'datetime string is empty')
Expand Down
Loading