feat: added day/month/year format (#2189)

This commit is contained in:
Samiksha Garg
2023-04-10 16:16:07 +05:30
committed by GitHub
parent aac5c2a4da
commit 28ae193002
4 changed files with 16 additions and 0 deletions

View File

@ -58,6 +58,16 @@ mod tests {
&field_rev,
);
},
DateFormat::DayMonthYear => {
assert_date(
&type_option,
1647251762,
None,
"14/03/2022",
false,
&field_rev,
);
},
}
}
}

View File

@ -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",
}
}
}