Browse Source

fix RRULE

master
Astro 5 months ago
parent
commit
351f0e057b
  1. 2
      libticker/src/ics/parser.rs
  2. 8
      ticker-update/src/main.rs

2
libticker/src/ics/parser.rs

@ -87,6 +87,7 @@ mod test {
p.feed(b"BEGIN:VEVENT
SUMMARY:Test event
DTSTART:19700101
RRULE:FREQ=YEARLY
END:VEVENT
", |o| {
@ -96,6 +97,7 @@ END:VEVENT
assert_eq!(obj, Some(Object {
name: "VEVENT".to_owned(),
content: [("SUMMARY", "Test event"),
("RRULE", "FREQ=YEARLY"),
("DTSTART", "19700101")]
.iter()
.cloned()

8
ticker-update/src/main.rs

@ -62,7 +62,7 @@ fn obj_to_events(calendar: String, obj: &Object) -> Vec<Event> {
}
};
let rrule_str: Option<&str> = obj.get("rrule");
let rrule_str: Option<&str> = obj.get("RRULE");
let rrule = rrule_str.and_then(
|rrule_str| RRule::from_str(
&format!("DTSTART:{}\nRRULE:{}", dtstart_str, rrule_str)
@ -74,12 +74,6 @@ fn obj_to_events(calendar: String, obj: &Object) -> Vec<Event> {
let now = Utc::now();
let start = now - Duration::days(RRULE_LOOKBACK);
let end = now + Duration::days(RRULE_LOOKAHEAD);
println!("rrule {}:\n{:?}", rrule_str.unwrap_or(""), rrule.into_iter()
.skip_while(|d| *d < start)
.take_while(|d| *d <= end)
.map(|dtstart| dtstart.naive_utc())
.collect::<Vec<_>>()
);
rrule.into_iter()
.skip_while(|d| *d < start)
.take_while(|d| *d <= end)

Loading…
Cancel
Save