Enum icalendar::CalendarDateTime
source · pub enum CalendarDateTime {
Floating(NaiveDateTime),
Utc(DateTime<Utc>),
WithTimezone {
date_time: NaiveDateTime,
tzid: String,
},
}Expand description
Representation of various forms of DATE-TIME per
RFC 5545, Section 3.3.5
Conversions from chrono types are provided in form of From implementations, see documentation of individual variants.
In addition to readily implemented FORM #1 and FORM #2, the RFC also specifies
FORM #3: DATE WITH LOCAL TIME AND TIME ZONE REFERENCE. This variant is not yet implemented.
Adding it will require adding support for VTIMEZONE and referencing it using TZID.
Variants§
Floating(NaiveDateTime)
FORM #1: DATE WITH LOCAL TIME: floating, follows current time-zone of the attendee.
Conversion from chrono::NaiveDateTime results in this variant.
§Note
finding this in a calendar is a red flag, datetimes should end in 'Z' for UTC or have a TZID property
Utc(DateTime<Utc>)
FORM #2: DATE WITH UTC TIME: rendered with Z suffix character.
Conversion from chrono::DateTime<Utc> results in this variant. Use
date_time.with_timezone(&Utc) to convert date_time from arbitrary time zone to UTC.
WithTimezone
FORM #3: DATE WITH LOCAL TIME AND TIME ZONE REFERENCE: refers to a time zone definition.
Fields
date_time: NaiveDateTimeThe date and time in the given time zone.
Implementations§
source§impl CalendarDateTime
impl CalendarDateTime
sourcepub fn try_into_utc(&self) -> Option<DateTime<Utc>>
pub fn try_into_utc(&self) -> Option<DateTime<Utc>>
attempts to convert the into UTC
sourcepub fn from_ymd_hm_tzid(
year: i32,
month: u32,
day: u32,
hour: u32,
min: u32,
tz_id: Tz,
) -> Option<Self>
pub fn from_ymd_hm_tzid( year: i32, month: u32, day: u32, hour: u32, min: u32, tz_id: Tz, ) -> Option<Self>
will return None if date is not valid
sourcepub fn from_date_time<TZ: TimeZone<Offset = O>, O: OffsetName>(
dt: DateTime<TZ>,
) -> Self
pub fn from_date_time<TZ: TimeZone<Offset = O>, O: OffsetName>( dt: DateTime<TZ>, ) -> Self
Create a new instance with the given timezone
Trait Implementations§
source§impl Clone for CalendarDateTime
impl Clone for CalendarDateTime
source§fn clone(&self) -> CalendarDateTime
fn clone(&self) -> CalendarDateTime
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for CalendarDateTime
impl Debug for CalendarDateTime
source§impl From<(NaiveDateTime, Tz)> for CalendarDateTime
impl From<(NaiveDateTime, Tz)> for CalendarDateTime
source§fn from((date_time, tzid): (NaiveDateTime, Tz)) -> Self
fn from((date_time, tzid): (NaiveDateTime, Tz)) -> Self
source§impl From<CalendarDateTime> for DatePerhapsTime
impl From<CalendarDateTime> for DatePerhapsTime
source§fn from(dt: CalendarDateTime) -> Self
fn from(dt: CalendarDateTime) -> Self
source§impl From<DateTime<Utc>> for CalendarDateTime
impl From<DateTime<Utc>> for CalendarDateTime
Converts from time zone-aware UTC date-time to CalendarDateTime::Utc.
source§impl From<NaiveDateTime> for CalendarDateTime
impl From<NaiveDateTime> for CalendarDateTime
Converts from time zone-less date-time to CalendarDateTime::Floating.
source§fn from(dt: NaiveDateTime) -> Self
fn from(dt: NaiveDateTime) -> Self
source§impl FromStr for CalendarDateTime
impl FromStr for CalendarDateTime
source§impl PartialEq for CalendarDateTime
impl PartialEq for CalendarDateTime
source§impl TryFrom<(NaiveDateTime, &str)> for CalendarDateTime
impl TryFrom<(NaiveDateTime, &str)> for CalendarDateTime
impl Eq for CalendarDateTime
impl StructuralPartialEq for CalendarDateTime
Auto Trait Implementations§
impl Freeze for CalendarDateTime
impl RefUnwindSafe for CalendarDateTime
impl Send for CalendarDateTime
impl Sync for CalendarDateTime
impl Unpin for CalendarDateTime
impl UnwindSafe for CalendarDateTime
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)