pub struct ZipDateTime<TZ = Utc> { /* private fields */ }
Expand description
Represents a timestamp found in a ZIP file
Implementations§
Source§impl<TZ: TimeZoneMarker> ZipDateTime<TZ>
impl<TZ: TimeZoneMarker> ZipDateTime<TZ>
Sourcepub fn from_components(
year: u16,
month: u8,
day: u8,
hour: u8,
minute: u8,
second: u8,
nanosecond: u32,
) -> Option<Self>
pub fn from_components( year: u16, month: u8, day: u8, hour: u8, minute: u8, second: u8, nanosecond: u32, ) -> Option<Self>
Creates a ZipDateTime from date/time components with validation.
§Arguments
year
- Year (1-65535)month
- Month (1-12)day
- Day of month (1-31, validated against month)hour
- Hour (0-23)minute
- Minute (0-59)second
- Second (0-59)nanosecond
- Nanosecond (0-999,999,999), defaults to 0
§Errors
Returns None
if any component is invalid or the date doesn’t exist
(e.g. February 30th, April 31st).
§Examples
let utc_datetime = UtcDateTime::from_components(
2023, 6, 15, 14, 30, 45, 500_000_000
).unwrap();
assert_eq!(utc_datetime.year(), 2023);
assert_eq!(utc_datetime.nanosecond(), 500_000_000);
// Invalid date returns None
assert!(UtcDateTime::from_components(2023, 2, 30, 0, 0, 0, 0).is_none());
Sourcepub const fn nanosecond(&self) -> u32
pub const fn nanosecond(&self) -> u32
Returns the nanosecond component (0-999,999,999) of the timestamp. For timestamps that don’t support nanosecond precision, this returns 0.
Source§impl ZipDateTime<Utc>
impl ZipDateTime<Utc>
Sourcepub fn from_unix(seconds: i64) -> UtcDateTime
pub fn from_unix(seconds: i64) -> UtcDateTime
Creates a ZipDateTime from a Unix timestamp (seconds since epoch)
Trait Implementations§
Source§impl<TZ: Clone> Clone for ZipDateTime<TZ>
impl<TZ: Clone> Clone for ZipDateTime<TZ>
Source§fn clone(&self) -> ZipDateTime<TZ>
fn clone(&self) -> ZipDateTime<TZ>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<TZ: Debug> Debug for ZipDateTime<TZ>
impl<TZ: Debug> Debug for ZipDateTime<TZ>
Source§impl<TZ: TimeZoneMarker> Display for ZipDateTime<TZ>
impl<TZ: TimeZoneMarker> Display for ZipDateTime<TZ>
Source§impl From<&ZipDateTime> for DosDateTime
impl From<&ZipDateTime> for DosDateTime
Source§fn from(zip_dt: &ZipDateTime) -> Self
fn from(zip_dt: &ZipDateTime) -> Self
Converts to this type from the input type.
Source§impl<TZ: Hash> Hash for ZipDateTime<TZ>
impl<TZ: Hash> Hash for ZipDateTime<TZ>
Source§impl<TZ: Ord> Ord for ZipDateTime<TZ>
impl<TZ: Ord> Ord for ZipDateTime<TZ>
Source§fn cmp(&self, other: &ZipDateTime<TZ>) -> Ordering
fn cmp(&self, other: &ZipDateTime<TZ>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<TZ: PartialEq> PartialEq for ZipDateTime<TZ>
impl<TZ: PartialEq> PartialEq for ZipDateTime<TZ>
Source§impl<TZ: PartialOrd> PartialOrd for ZipDateTime<TZ>
impl<TZ: PartialOrd> PartialOrd for ZipDateTime<TZ>
impl<TZ: Copy> Copy for ZipDateTime<TZ>
impl<TZ: Eq> Eq for ZipDateTime<TZ>
impl<TZ> StructuralPartialEq for ZipDateTime<TZ>
Auto Trait Implementations§
impl<TZ> Freeze for ZipDateTime<TZ>
impl<TZ> RefUnwindSafe for ZipDateTime<TZ>where
TZ: RefUnwindSafe,
impl<TZ> Send for ZipDateTime<TZ>where
TZ: Send,
impl<TZ> Sync for ZipDateTime<TZ>where
TZ: Sync,
impl<TZ> Unpin for ZipDateTime<TZ>where
TZ: Unpin,
impl<TZ> UnwindSafe for ZipDateTime<TZ>where
TZ: UnwindSafe,
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