Skip to content

Commit 17847a8

Browse files
authored
Merge pull request #212 from yuankunzhang/replace-chrono-with-jiff-5
(jiff series #5) refactor: add conversion from `Day` to `jiff::civil::Weekday`
2 parents cc5029c + 6fce029 commit 17847a8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/items/weekday.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub(crate) enum Day {
4141
}
4242

4343
#[derive(PartialEq, Eq, Debug)]
44-
pub struct Weekday {
44+
pub(crate) struct Weekday {
4545
pub(crate) offset: i32,
4646
pub(crate) day: Day,
4747
}
@@ -60,6 +60,20 @@ impl From<Day> for chrono::Weekday {
6060
}
6161
}
6262

63+
impl From<Day> for jiff::civil::Weekday {
64+
fn from(value: Day) -> Self {
65+
match value {
66+
Day::Monday => jiff::civil::Weekday::Monday,
67+
Day::Tuesday => jiff::civil::Weekday::Tuesday,
68+
Day::Wednesday => jiff::civil::Weekday::Wednesday,
69+
Day::Thursday => jiff::civil::Weekday::Thursday,
70+
Day::Friday => jiff::civil::Weekday::Friday,
71+
Day::Saturday => jiff::civil::Weekday::Saturday,
72+
Day::Sunday => jiff::civil::Weekday::Sunday,
73+
}
74+
}
75+
}
76+
6377
/// Parse a weekday item.
6478
pub(super) fn parse(input: &mut &str) -> ModalResult<Weekday> {
6579
seq!(Weekday {

0 commit comments

Comments
 (0)