Skip to main content

ical/value/
utc_offset.rs

1//! # UTC-offset value
2//!
3//! The decoded UTC-offset value kind.
4//!
5//! Backs `TZOFFSETFROM` and `TZOFFSETTO`: a signed `+/-HHMM[SS]` offset from
6//! UTC (RFC 5545 3.3.14; e.g. `-0500`). The offset is kept as its raw text; the
7//! crate does not decode it into hours/minutes/seconds. Pure data, no escaping;
8//! the owning property's wire name lives on [`crate::prop::IcalProp::name`].
9
10use alloc::{borrow::Cow, string::String};
11
12/// A decoded UTC-offset value (signed `hhmm`), kept as its raw text.
13#[derive(Clone, Debug, Default, PartialEq, Eq)]
14pub struct IcalUtcOffset<'a>(pub Cow<'a, str>);
15
16impl<'a> From<&'a str> for IcalUtcOffset<'a> {
17    fn from(value: &'a str) -> Self {
18        Self(Cow::Borrowed(value))
19    }
20}
21
22impl From<String> for IcalUtcOffset<'_> {
23    fn from(value: String) -> Self {
24        Self(Cow::Owned(value))
25    }
26}
27
28impl<'a> From<Cow<'a, str>> for IcalUtcOffset<'a> {
29    fn from(value: Cow<'a, str>) -> Self {
30        Self(value)
31    }
32}