mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
time: extend date str formats (#9543)
This commit is contained in:
parent
0d1714cb0d
commit
043f6420f7
@ -126,8 +126,10 @@ pub fn (t Time) get_fmt_date_str(fmt_dlmtr FormatDelimiter, fmt_date FormatDate)
|
|||||||
.mmddyyyy { '${t.month:02d}|${t.day:02d}|${t.year:04d}' }
|
.mmddyyyy { '${t.month:02d}|${t.day:02d}|${t.year:04d}' }
|
||||||
.mmmd { '$month|$t.day' }
|
.mmmd { '$month|$t.day' }
|
||||||
.mmmdd { '$month|${t.day:02d}' }
|
.mmmdd { '$month|${t.day:02d}' }
|
||||||
|
.mmmddyy { '$month|${t.day:02d}|$year' }
|
||||||
.mmmddyyyy { '$month|${t.day:02d}|${t.year:04d}' }
|
.mmmddyyyy { '$month|${t.day:02d}|${t.year:04d}' }
|
||||||
.yyyymmdd { '${t.year:04d}|${t.month:02d}|${t.day:02d}' }
|
.yyyymmdd { '${t.year:04d}|${t.month:02d}|${t.day:02d}' }
|
||||||
|
.yymmdd { '$year|${t.month:02d}|${t.day:02d}' }
|
||||||
else { 'unknown enumeration $fmt_date' }
|
else { 'unknown enumeration $fmt_date' }
|
||||||
}
|
}
|
||||||
del := match fmt_dlmtr {
|
del := match fmt_dlmtr {
|
||||||
|
@ -72,9 +72,11 @@ pub enum FormatDate {
|
|||||||
mmddyyyy
|
mmddyyyy
|
||||||
mmmd
|
mmmd
|
||||||
mmmdd
|
mmmdd
|
||||||
|
mmmddyy
|
||||||
mmmddyyyy
|
mmmddyyyy
|
||||||
no_date
|
no_date
|
||||||
yyyymmdd
|
yyyymmdd
|
||||||
|
yymmdd
|
||||||
}
|
}
|
||||||
|
|
||||||
// FormatDelimiter contains different time/date delimiters.
|
// FormatDelimiter contains different time/date delimiters.
|
||||||
|
@ -72,8 +72,10 @@ fn test_get_fmt_date_str() {
|
|||||||
assert '07 11 80' == time_to_test.get_fmt_date_str(.space, .mmddyy)
|
assert '07 11 80' == time_to_test.get_fmt_date_str(.space, .mmddyy)
|
||||||
assert 'Jul 11' == time_to_test.get_fmt_date_str(.space, .mmmd)
|
assert 'Jul 11' == time_to_test.get_fmt_date_str(.space, .mmmd)
|
||||||
assert 'Jul 11' == time_to_test.get_fmt_date_str(.space, .mmmdd)
|
assert 'Jul 11' == time_to_test.get_fmt_date_str(.space, .mmmdd)
|
||||||
|
assert 'Jul 11 80' == time_to_test.get_fmt_date_str(.space, .mmmddyy)
|
||||||
assert 'Jul 11 1980' == time_to_test.get_fmt_date_str(.space, .mmmddyyyy)
|
assert 'Jul 11 1980' == time_to_test.get_fmt_date_str(.space, .mmmddyyyy)
|
||||||
assert '1980-07-11' == time_to_test.get_fmt_date_str(.hyphen, .yyyymmdd)
|
assert '1980-07-11' == time_to_test.get_fmt_date_str(.hyphen, .yyyymmdd)
|
||||||
|
assert '80.07.11' == time_to_test.get_fmt_date_str(.dot, .yymmdd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_get_fmt_str() {
|
fn test_get_fmt_str() {
|
||||||
|
Loading…
Reference in New Issue
Block a user