Add fairness for each shift type count
This commit is contained in:
@@ -21,10 +21,22 @@ impl Slot {
|
||||
self.day == Day(1) && self.position == ShiftPosition::First
|
||||
}
|
||||
|
||||
pub fn is_open_first(&self) -> bool {
|
||||
self.is_open_shift() && self.position == ShiftPosition::First
|
||||
}
|
||||
|
||||
pub fn is_open_second(&self) -> bool {
|
||||
self.is_open_shift() && self.position == ShiftPosition::Second
|
||||
}
|
||||
|
||||
pub fn shift_type_str(&self) -> String {
|
||||
match (self.day.is_open_shift(), self.position) {
|
||||
(true, ShiftPosition::First) => "Ανοιχτή(1)".to_string(),
|
||||
(true, ShiftPosition::Second) => "Ανοιχτή(2)".to_string(),
|
||||
_ => "Κλειστή".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn next(&self) -> Self {
|
||||
match self.position {
|
||||
ShiftPosition::First if self.is_open_shift() => Self {
|
||||
@@ -103,6 +115,11 @@ impl Day {
|
||||
let weekday = date.weekday();
|
||||
weekday == Weekday::Sat || weekday == Weekday::Sun
|
||||
}
|
||||
|
||||
pub fn weekday(&self, month: u32, year: i32) -> Weekday {
|
||||
let date = NaiveDate::from_ymd_opt(year, month, self.0 as u32).unwrap();
|
||||
date.weekday()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, PartialOrd, Ord, Eq, Debug, Hash, Clone, Copy)]
|
||||
|
||||
Reference in New Issue
Block a user