diff options
Diffstat (limited to 'karlgui/src/helper.rs')
-rw-r--r-- | karlgui/src/helper.rs | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/karlgui/src/helper.rs b/karlgui/src/helper.rs index 1ae29c8..eb4c981 100644 --- a/karlgui/src/helper.rs +++ b/karlgui/src/helper.rs @@ -4,40 +4,11 @@ use karlcommon::Property; pub fn format_value(prop: Property, value: i64) -> String { match prop { Property::Year => format!("{value}"), - Property::Monthofyear => format!( - "{}", - match value { - 0 => "January", - 1 => "February", - 2 => "March", - 3 => "April", - 4 => "May", - 5 => "June", - 6 => "July", - 7 => "August", - 8 => "September", - 9 => "October", - 10 => "November", - 11 => "December", - _ => "(invalid)", - } - ), + Property::Monthofyear => format!("{}", month_to_str(value)), Property::Weekofmonth => format!("{value}"), Property::Dayofyear => format!("{value}"), Property::Dayofmonth => format!("{value}"), - Property::Dayofweek => format!( - "{}", - match value { - 0 => "Monday", - 1 => "Thuesday", - 2 => "Wednesday", - 3 => "Thursday", - 4 => "Friday", - 5 => "Saturday", - 6 => "Sunday", - _ => "(invalid)", - } - ), + Property::Dayofweek => format!("{}", weekday_to_str(value)), Property::Hour => format!("{value}h"), Property::Minute => format!("{value}min"), Property::Second => format!("{value}s"), @@ -91,3 +62,33 @@ pub fn edit_value(ui: &mut Ui, prop: Property, value: &mut i64) { } } } + +pub fn weekday_to_str(value: i64) -> &'static str { + match value { + 0 => "Monday", + 1 => "Thuesday", + 2 => "Wednesday", + 3 => "Thursday", + 4 => "Friday", + 5 => "Saturday", + 6 => "Sunday", + _ => "(invalid)", + } +} +pub fn month_to_str(value: i64) -> &'static str { + match value { + 0 => "January", + 1 => "February", + 2 => "March", + 3 => "April", + 4 => "May", + 5 => "June", + 6 => "July", + 7 => "August", + 8 => "September", + 9 => "October", + 10 => "November", + 11 => "December", + _ => "(invalid)", + } +} |