mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: added day/month/year format (#2189)
This commit is contained in:
parent
aac5c2a4da
commit
28ae193002
@ -282,6 +282,7 @@
|
||||
"dateFormatISO": "Year-Month-Day",
|
||||
"dateFormatLocal": "Month/Day/Year",
|
||||
"dateFormatUS": "Year/Month/Day",
|
||||
"dateFormatDayMonthYear": "Day/Month/Year",
|
||||
"timeFormat": "Time format",
|
||||
"invalidTimeFormat": "Invalid format",
|
||||
"timeFormatTwelveHour": "12 hour",
|
||||
|
@ -299,6 +299,8 @@ extension DateFormatExtension on DateFormat {
|
||||
return LocaleKeys.grid_field_dateFormatLocal.tr();
|
||||
case DateFormat.US:
|
||||
return LocaleKeys.grid_field_dateFormatUS.tr();
|
||||
case DateFormat.DayMonthYear:
|
||||
return LocaleKeys.grid_field_dateFormatDayMonthYear.tr();
|
||||
default:
|
||||
throw UnimplementedError;
|
||||
}
|
||||
|
@ -58,6 +58,16 @@ mod tests {
|
||||
&field_rev,
|
||||
);
|
||||
},
|
||||
DateFormat::DayMonthYear => {
|
||||
assert_date(
|
||||
&type_option,
|
||||
1647251762,
|
||||
None,
|
||||
"14/03/2022",
|
||||
false,
|
||||
&field_rev,
|
||||
);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +174,7 @@ pub enum DateFormat {
|
||||
US = 1,
|
||||
ISO = 2,
|
||||
Friendly = 3,
|
||||
DayMonthYear = 4,
|
||||
}
|
||||
impl std::default::Default for DateFormat {
|
||||
fn default() -> Self {
|
||||
@ -188,6 +189,7 @@ impl std::convert::From<i32> for DateFormat {
|
||||
1 => DateFormat::US,
|
||||
2 => DateFormat::ISO,
|
||||
3 => DateFormat::Friendly,
|
||||
4 => DateFormat::DayMonthYear,
|
||||
_ => {
|
||||
tracing::error!("Unsupported date format, fallback to friendly");
|
||||
DateFormat::Friendly
|
||||
@ -207,6 +209,7 @@ impl DateFormat {
|
||||
DateFormat::US => "%Y/%m/%d",
|
||||
DateFormat::ISO => "%Y-%m-%d",
|
||||
DateFormat::Friendly => "%b %d,%Y",
|
||||
DateFormat::DayMonthYear => "%d/%m/%Y",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user