ZipDateTime

Struct ZipDateTime 

Source
pub struct ZipDateTime<TZ = Utc> { /* private fields */ }
Expand description

Represents a timestamp found in a ZIP file

Implementations§

Source§

impl<TZ: TimeZoneMarker> ZipDateTime<TZ>

Source

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());
Source

pub const fn year(&self) -> u16

Returns the year component of the timestamp.

Source

pub const fn month(&self) -> u8

Returns the month component (1-12) of the timestamp.

Source

pub const fn day(&self) -> u8

Returns the day component (1-31) of the timestamp.

Source

pub const fn hour(&self) -> u8

Returns the hour component (0-23) of the timestamp.

Source

pub const fn minute(&self) -> u8

Returns the minute component (0-59) of the timestamp.

Source

pub const fn second(&self) -> u8

Returns the second component (0-59) of the timestamp.

Source

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

pub fn timezone(&self) -> TimeZone

Returns the timezone of this timestamp.

Source§

impl ZipDateTime<Utc>

Source

pub fn from_unix(seconds: i64) -> UtcDateTime

Creates a ZipDateTime from a Unix timestamp (seconds since epoch)

Source

pub fn to_unix(&self) -> i64

Convert to Unix timestamp (seconds since epoch).

Returns the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC). Negative values represent dates before 1970.

Trait Implementations§

Source§

impl<TZ: Clone> Clone for ZipDateTime<TZ>

Source§

fn clone(&self) -> ZipDateTime<TZ>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<TZ: Debug> Debug for ZipDateTime<TZ>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<TZ: TimeZoneMarker> Display for ZipDateTime<TZ>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&ZipDateTime> for DosDateTime

Source§

fn from(zip_dt: &ZipDateTime) -> Self

Converts to this type from the input type.
Source§

impl<TZ: Hash> Hash for ZipDateTime<TZ>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<TZ: Ord> Ord for ZipDateTime<TZ>

Source§

fn cmp(&self, other: &ZipDateTime<TZ>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<TZ: PartialEq> PartialEq for ZipDateTime<TZ>

Source§

fn eq(&self, other: &ZipDateTime<TZ>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<TZ: PartialOrd> PartialOrd for ZipDateTime<TZ>

Source§

fn partial_cmp(&self, other: &ZipDateTime<TZ>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<TZ: Copy> Copy for ZipDateTime<TZ>

Source§

impl<TZ: Eq> Eq for ZipDateTime<TZ>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.