-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add better api and examples for dates with timezones
- Loading branch information
Showing
8 changed files
with
199 additions
and
5 deletions.
There are no files selected for viewing
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,40 @@ | ||
#![cfg(feature = "chrono-tz")] | ||
use chrono::*; | ||
use chrono_tz::Europe::Berlin; | ||
use icalendar::*; | ||
|
||
fn main() { | ||
// lets make sure everybody arrives at the expected time | ||
let my_calendar = Calendar::new() | ||
.push( | ||
Event::new() | ||
.starts(CalendarDateTime::from_ymd_hm_tzid(2023, 3, 15, 18, 45, Berlin).unwrap()) | ||
.description("I'm gonna have a party\nBYOB: Bring your own beer.\nHendrik") | ||
.done(), | ||
) | ||
.push( | ||
Event::new() | ||
.starts( | ||
CalendarDateTime::from_ymd_hm_tzid(2023, 3, 15, 18, 45, Berlin) | ||
.and_then(|cdt| cdt.try_into_utc()) | ||
.unwrap(), | ||
) | ||
.description("I'm gonna have a party\nBYOB: Bring your own beer.\nHendrik") | ||
.done(), | ||
) | ||
.push( | ||
Event::new() | ||
.starts(CalendarDateTime::from_date_time( | ||
chrono_tz::Europe::Berlin | ||
.with_ymd_and_hms(2023, 3, 15, 18, 45, 0) | ||
.single() | ||
.unwrap(), | ||
)) | ||
.summary("My Birthday") | ||
.description("I'm gonna have a party\nBYOB: Bring your own beer.\nHendrik") | ||
.done(), | ||
) | ||
.done(); | ||
|
||
println!("{}", my_calendar); | ||
} |
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