Expand integration suite to cover all months of 2026, minor refactorings
This commit is contained in:
@@ -23,6 +23,10 @@ impl Slot {
|
||||
self.day == Day(1) && self.position == ShiftPosition::First
|
||||
}
|
||||
|
||||
pub fn is_first_day(&self) -> bool {
|
||||
self.day == Day(1)
|
||||
}
|
||||
|
||||
pub fn is_open_first(&self) -> bool {
|
||||
self.is_open_shift() && self.position == ShiftPosition::First
|
||||
}
|
||||
@@ -160,9 +164,17 @@ impl Day {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn weekday(&self, month: u32, year: i32) -> Weekday {
|
||||
pub fn weekday_to_greek(&self, month: u32, year: i32) -> &'static str {
|
||||
let date = NaiveDate::from_ymd_opt(year, month, self.0 as u32).unwrap();
|
||||
date.weekday()
|
||||
match date.weekday() {
|
||||
Weekday::Mon => "Δευτέρα",
|
||||
Weekday::Tue => "Τρίτη",
|
||||
Weekday::Wed => "Τετάρτη",
|
||||
Weekday::Thu => "Πέμπτη",
|
||||
Weekday::Fri => "Παρασκευή",
|
||||
Weekday::Sat => "Σάββατο",
|
||||
Weekday::Sun => "Κυριακή",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,36 +184,6 @@ pub enum ShiftPosition {
|
||||
Second,
|
||||
}
|
||||
|
||||
pub fn weekday_to_greek(weekday: Weekday) -> &'static str {
|
||||
match weekday {
|
||||
Weekday::Mon => "Δευτέρα",
|
||||
Weekday::Tue => "Τρίτη",
|
||||
Weekday::Wed => "Τετάρτη",
|
||||
Weekday::Thu => "Πέμπτη",
|
||||
Weekday::Fri => "Παρασκευή",
|
||||
Weekday::Sat => "Σάββατο",
|
||||
Weekday::Sun => "Κυριακή",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn month_to_greek(month: u32) -> &'static str {
|
||||
match month {
|
||||
1 => "Ιανουάριος",
|
||||
2 => "Φεβρουάριος",
|
||||
3 => "Μάρτιος",
|
||||
4 => "Απρίλιος",
|
||||
5 => "Μάιος",
|
||||
6 => "Ιούνιος",
|
||||
7 => "Ιούλιος",
|
||||
8 => "Αύγουστος",
|
||||
9 => "Σεπτέμβριος",
|
||||
10 => "Οκτώβριος",
|
||||
11 => "Νοέμβριος",
|
||||
12 => "Δεκέμβριος",
|
||||
_ => panic!("Unable to find translation for month {}", month),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use rstest::rstest;
|
||||
@@ -225,6 +207,14 @@ mod tests {
|
||||
assert!(!slot_2.is_first());
|
||||
assert!(!slot_3.is_first());
|
||||
|
||||
assert!(slot_1.is_first_day());
|
||||
assert!(slot_2.is_first_day());
|
||||
assert!(!slot_3.is_first_day());
|
||||
|
||||
assert!(slot_1.is_open_first());
|
||||
assert!(!slot_2.is_open_first());
|
||||
assert!(!slot_3.is_open_first());
|
||||
|
||||
assert!(!slot_1.is_open_second());
|
||||
assert!(slot_2.is_open_second());
|
||||
assert!(!slot_3.is_open_second());
|
||||
|
||||
Reference in New Issue
Block a user