time: extend date str formats (#9543)
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}' }
|
||||
.mmmd { '$month|$t.day' }
|
||||
.mmmdd { '$month|${t.day:02d}' }
|
||||
.mmmddyy { '$month|${t.day:02d}|$year' }
|
||||
.mmmddyyyy { '$month|${t.day:02d}|${t.year:04d}' }
|
||||
.yyyymmdd { '${t.year:04d}|${t.month:02d}|${t.day:02d}' }
|
||||
.yymmdd { '$year|${t.month:02d}|${t.day:02d}' }
|
||||
else { 'unknown enumeration $fmt_date' }
|
||||
}
|
||||
del := match fmt_dlmtr {
|
||||
|
|
|
@ -72,9 +72,11 @@ pub enum FormatDate {
|
|||
mmddyyyy
|
||||
mmmd
|
||||
mmmdd
|
||||
mmmddyy
|
||||
mmmddyyyy
|
||||
no_date
|
||||
yyyymmdd
|
||||
yymmdd
|
||||
}
|
||||
|
||||
// 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 '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 80' == time_to_test.get_fmt_date_str(.space, .mmmddyy)
|
||||
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 '80.07.11' == time_to_test.get_fmt_date_str(.dot, .yymmdd)
|
||||
}
|
||||
|
||||
fn test_get_fmt_str() {
|
||||
|
|
Loading…
Reference in New Issue