pub enum TimeZone {
TimeZoneTime(String),
TimeZoneCity(String),
TimeZoneNumber(i8),
}Expand description
TimeZone enum for representing different time zone formats.
It can represent:
- Time zone offset as a string (e.g., “+08:00”)
- Time zone city as a string (e.g., “Asia/Shanghai”)
- Time zone number as an integer (-12 to +12)
§Examples
use dayjs::TimeZone;
let tz_offset = TimeZone::TimeZoneTime("+08:00".to_string());
let tz_city = TimeZone::TimeZoneCity("Asia/Shanghai".to_string());
let tz_number = TimeZone::TimeZoneNumber(8);Variants§
Implementations§
Source§impl TimeZone
impl TimeZone
Sourcepub fn from_string(s: String) -> Self
pub fn from_string(s: String) -> Self
Parse timezone from string
Attempts to parse a string into a TimeZone enum:
- If it starts with ‘+’ or ‘-’, treats it as TimeZoneTime (offset)
- If it’s a valid number between -12 and 12, treats it as TimeZoneNumber
- Otherwise, treats it as TimeZoneCity
Trait Implementations§
impl StructuralPartialEq for TimeZone
Auto Trait Implementations§
impl Freeze for TimeZone
impl RefUnwindSafe for TimeZone
impl Send for TimeZone
impl Sync for TimeZone
impl Unpin for TimeZone
impl UnwindSafe for TimeZone
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
Mutably borrows from an owned value. Read more