-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
949 additions
and
885 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
mod frequency; | ||
mod month; | ||
mod n_weekday; | ||
mod rrule; | ||
mod rrule_datetime; | ||
mod rrule_set; | ||
mod rrule_timezone; | ||
mod weekday; | ||
|
||
pub use frequency::Frequency; | ||
pub use month::Month; | ||
pub use n_weekday::NWeekday; | ||
pub use rrule::RRule; | ||
pub use rrule_datetime::RRuleDateTime; | ||
pub use rrule_set::RRuleSet; | ||
pub use rrule_timezone::RRuleTimezone; | ||
pub use weekday::Weekday; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use napi_derive::napi; | ||
|
||
#[napi(js_name = "Frequency")] | ||
pub enum Frequency { | ||
Yearly, | ||
Monthly, | ||
Weekly, | ||
Daily, | ||
Hourly, | ||
Minutely, | ||
Secondly, | ||
} | ||
|
||
impl From<rrule::Frequency> for Frequency { | ||
fn from(freq: rrule::Frequency) -> Self { | ||
match freq { | ||
rrule::Frequency::Daily => Frequency::Daily, | ||
rrule::Frequency::Hourly => Frequency::Hourly, | ||
rrule::Frequency::Minutely => Frequency::Minutely, | ||
rrule::Frequency::Monthly => Frequency::Monthly, | ||
rrule::Frequency::Secondly => Frequency::Secondly, | ||
rrule::Frequency::Weekly => Frequency::Weekly, | ||
rrule::Frequency::Yearly => Frequency::Yearly, | ||
} | ||
} | ||
} | ||
|
||
impl Into<rrule::Frequency> for Frequency { | ||
fn into(self) -> rrule::Frequency { | ||
match self { | ||
Frequency::Daily => rrule::Frequency::Daily, | ||
Frequency::Hourly => rrule::Frequency::Hourly, | ||
Frequency::Minutely => rrule::Frequency::Minutely, | ||
Frequency::Monthly => rrule::Frequency::Monthly, | ||
Frequency::Secondly => rrule::Frequency::Secondly, | ||
Frequency::Weekly => rrule::Frequency::Weekly, | ||
Frequency::Yearly => rrule::Frequency::Yearly, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use napi_derive::napi; | ||
|
||
#[napi(js_name = "Month")] | ||
pub enum Month { | ||
January, | ||
February, | ||
March, | ||
April, | ||
May, | ||
June, | ||
July, | ||
August, | ||
September, | ||
October, | ||
November, | ||
December, | ||
} | ||
|
||
impl From<&u8> for Month { | ||
fn from(month: &u8) -> Self { | ||
match month { | ||
0 => Month::January, | ||
1 => Month::February, | ||
2 => Month::March, | ||
3 => Month::April, | ||
4 => Month::May, | ||
5 => Month::June, | ||
6 => Month::July, | ||
7 => Month::August, | ||
8 => Month::September, | ||
9 => Month::October, | ||
10 => Month::November, | ||
11 => Month::December, | ||
_ => panic!("Unknown month index: {}", month), | ||
} | ||
} | ||
} | ||
|
||
impl Into<chrono::Month> for Month { | ||
fn into(self) -> chrono::Month { | ||
match self { | ||
Month::January => chrono::Month::January, | ||
Month::February => chrono::Month::February, | ||
Month::March => chrono::Month::March, | ||
Month::April => chrono::Month::April, | ||
Month::May => chrono::Month::May, | ||
Month::June => chrono::Month::June, | ||
Month::July => chrono::Month::July, | ||
Month::August => chrono::Month::August, | ||
Month::September => chrono::Month::September, | ||
Month::October => chrono::Month::October, | ||
Month::November => chrono::Month::November, | ||
Month::December => chrono::Month::December, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use super::weekday::Weekday; | ||
use napi_derive::napi; | ||
|
||
#[napi(object, js_name = "NWeekday")] | ||
pub struct NWeekday { | ||
/// If set, this represents the nth occurrence of the weekday. | ||
/// Otherwise it represents every occurrence of the weekday. | ||
/// | ||
/// A negative value represents nth occurrence from the end. | ||
pub n: Option<i16>, | ||
pub weekday: Weekday, | ||
} | ||
|
||
impl From<rrule::NWeekday> for NWeekday { | ||
fn from(nday: rrule::NWeekday) -> Self { | ||
match nday { | ||
rrule::NWeekday::Every(weekday) => NWeekday { | ||
n: None, | ||
weekday: Weekday::from(weekday), | ||
}, | ||
rrule::NWeekday::Nth(n, weekday) => NWeekday { | ||
n: Some(n), | ||
weekday: weekday.into(), | ||
}, | ||
} | ||
} | ||
} | ||
|
||
impl Into<rrule::NWeekday> for NWeekday { | ||
fn into(self) -> rrule::NWeekday { | ||
match self.n { | ||
Some(n) => rrule::NWeekday::Nth(n, self.weekday.into()), | ||
None => rrule::NWeekday::Every(self.weekday.into()), | ||
} | ||
} | ||
} |
Oops, something went wrong.