Skip to content

Commit

Permalink
feat(ics): add utility method for Eventc
Browse files Browse the repository at this point in the history
  • Loading branch information
H1ghBre4k3r committed Jul 14, 2024
1 parent 82a852f commit e941fc3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions crates/ics/src/component_properties/uid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ impl std::fmt::Display for Uid {
f.write_str(self.inner.as_str())
}
}

impl From<&str> for Uid {
fn from(value: &str) -> Self {
Self {
inner: value.to_string(),
}
}
}
11 changes: 11 additions & 0 deletions crates/ics/src/components/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,14 @@ pub struct Eventc {
#[skip]
pub iana_prop: Vec<()>,
}

impl Eventc {
pub fn new() -> Eventc {
Eventc {
dtstamp: DTStamp {
date: Some(chrono::Utc::now()),
},
..Default::default()
}
}
}
2 changes: 1 addition & 1 deletion crates/ics/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use ics::{Calendar, Components, Eventc};
use url::Url;

fn main() {
let evt = Eventc::default()
let evt = Eventc::new()
.with_description("Some Desc")
.with_summary("Some Summary")
.with_dtstart(chrono::Utc::now())
Expand Down

0 comments on commit e941fc3

Please sign in to comment.