Skip to content

Commit bbff9dd

Browse files
committed
refactor: Switch to !TimeOfDay tag
1 parent ae04b63 commit bbff9dd

File tree

8 files changed

+18
-10
lines changed

8 files changed

+18
-10
lines changed

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"yaml.customTags": [
3+
"!DayOfWeek sequence",
4+
"!TimeOfDay mapping",
5+
"!Unavailable mapping",
6+
"!None",
7+
]
8+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ will cover on-call (if you have part time employees, or people whose situations
8484
shiftLength: 1 # A new shift starts every day
8585
constraints:
8686
- !DayOfWeek [Mon, Tue, Wed, Thu, Fri] # Shifts cover weekdays only
87-
- !TimeRange # And run from 08:00 to 16:00 on those days
87+
- !TimeOfDay # And run from 08:00 to 16:00 on those days
8888
start: 08:00:00
8989
end: 16:00:00
9090
humans:

examples/3-day.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
shiftLength: 3
22
constraints:
33
- !DayOfWeek [Mon, Tue, Wed, Thu, Fri]
4-
- !TimeRange
4+
- !TimeOfDay
55
start: 08:00:00
66
end: 16:00:00
77
humans:

examples/rotation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
shiftLength: 1
22
constraints:
33
- !DayOfWeek [Mon, Tue, Wed, Thu, Fri]
4-
- !TimeRange
4+
- !TimeOfDay
55
start: 08:00:00
66
end: 16:00:00
77
humans:

examples/weekly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
shiftLength: 5
22
constraints:
33
- !DayOfWeek [Mon, Tue, Wed, Thu, Fri]
4-
- !TimeRange
4+
- !TimeOfDay
55
start: 08:00:00
66
end: 16:00:00
77
humans:

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ mod tests {
252252
shiftLength: 1
253253
constraints:
254254
- !DayOfWeek [Mon, Tue, Wed, Thu, Fri]
255-
- !TimeRange
255+
- !TimeOfDay
256256
start: 08:00:00
257257
end: 16:00:00
258258
humans:

src/constraints/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod unavailable;
1414
pub enum Constraint {
1515
None,
1616
DayOfWeek(Vec<Weekday>),
17-
TimeRange { start: NaiveTime, end: NaiveTime },
17+
TimeOfDay { start: NaiveTime, end: NaiveTime },
1818
Unavailable { start: NaiveDate, end: NaiveDate },
1919
}
2020

@@ -28,7 +28,7 @@ impl Constraint {
2828
Constraint::DayOfWeek(days) => {
2929
Box::new(dayofweek::DayOfWeekIterator::new(ranges, days.clone()))
3030
}
31-
Constraint::TimeRange { start, end } => {
31+
Constraint::TimeOfDay { start, end } => {
3232
Box::new(timeofday::TimeOfDayIterator::new(ranges, *start, *end))
3333
}
3434
Constraint::Unavailable { start, end } => {
@@ -45,7 +45,7 @@ impl Display for Constraint {
4545
Constraint::DayOfWeek(days) => {
4646
write!(f, "available on {:?}", days)
4747
}
48-
Constraint::TimeRange { start, end } => {
48+
Constraint::TimeOfDay { start, end } => {
4949
write!(f, "available between {} and {}", start, end)
5050
}
5151
Constraint::Unavailable { start, end } => {
@@ -61,7 +61,7 @@ mod tests {
6161

6262
#[test]
6363
fn test_time_of_day_constraint() {
64-
let constraint = Constraint::TimeRange {
64+
let constraint = Constraint::TimeOfDay {
6565
start: NaiveTime::from_hms_opt(9, 0, 0).unwrap(),
6666
end: NaiveTime::from_hms_opt(17, 0, 0).unwrap(),
6767
};

src/solver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ mod tests {
159159
chrono::Weekday::Thu,
160160
chrono::Weekday::Fri,
161161
]),
162-
Constraint::TimeRange {
162+
Constraint::TimeOfDay {
163163
start: NaiveTime::from_hms_opt(9, 0, 0).unwrap(),
164164
end: NaiveTime::from_hms_opt(17, 0, 0).unwrap(),
165165
},

0 commit comments

Comments
 (0)