pub struct DateTime {
pub micro: u32,
pub sec: u8,
pub min: u8,
pub hour: u8,
pub day: u8,
pub mon: u8,
pub year: u16,
}Expand description
Log timestamp type.
Parse using FromStr impl.
Format using the Display trait.
Convert timestamp into/from SytemTime to use.
Supports comparsion and sorting.
Fields
micro: u320…999999
sec: u80…59
min: u80…59
hour: u80…23
day: u81…31
mon: u81…12
year: u161970…9999
Implementations
sourceimpl DateTime
impl DateTime
sourcepub fn set_offset(self, offset_sec: i32) -> DateTime
pub fn set_offset(self, offset_sec: i32) -> DateTime
set offset
let mut dt = fastdate::DateTime::utc();
dt = dt.set_offset(fastdate::offset_sec());sourcepub fn unix_timestamp(&self) -> i64
pub fn unix_timestamp(&self) -> i64
unix_timestamp sec
sourcepub fn unix_timestamp_micros(&self) -> i64
pub fn unix_timestamp_micros(&self) -> i64
unix_timestamp micros
sourcepub fn unix_timestamp_millis(&self) -> i64
pub fn unix_timestamp_millis(&self) -> i64
unix_timestamp millis
sourcepub fn unix_timestamp_nano(&self) -> u128
pub fn unix_timestamp_nano(&self) -> u128
unix_timestamp nano
sourcepub fn from_timestamp(sec: i64) -> DateTime
pub fn from_timestamp(sec: i64) -> DateTime
from timestamp sec
sourcepub fn from_timestamp_micros(micros: i64) -> DateTime
pub fn from_timestamp_micros(micros: i64) -> DateTime
from timestamp micros
sourcepub fn from_timestamp_millis(ms: i64) -> DateTime
pub fn from_timestamp_millis(ms: i64) -> DateTime
from timestamp millis
sourcepub fn from_timestamp_nano(nano: u128) -> DateTime
pub fn from_timestamp_nano(nano: u128) -> DateTime
from timestamp nano
sourcepub fn parse(format: &str, arg: &str) -> Result<DateTime, Error>
pub fn parse(format: &str, arg: &str) -> Result<DateTime, Error>
parse an string by format. format str must be:
fastdate::DateTime::parse("YYYY-MM-DD hh:mm:ss.000000","2022-12-13 11:12:14.123456").unwrap();or any position
fastdate::DateTime::parse("hh:mm:ss.000000,YYYY-MM-DD","11:12:14.123456,2022-12-13").unwrap();Trait Implementations
sourceimpl<'de> Deserialize<'de> for DateTime
impl<'de> Deserialize<'de> for DateTime
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<DateTime> for SystemTime
impl From<DateTime> for SystemTime
sourcefn from(v: DateTime) -> SystemTime
fn from(v: DateTime) -> SystemTime
Converts to this type from the input type.
sourceimpl From<SystemTime> for DateTime
impl From<SystemTime> for DateTime
sourcefn from(v: SystemTime) -> DateTime
fn from(v: SystemTime) -> DateTime
Converts to this type from the input type.
sourceimpl Ord for DateTime
impl Ord for DateTime
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<DateTime> for DateTime
impl PartialEq<DateTime> for DateTime
sourceimpl PartialOrd<DateTime> for DateTime
impl PartialOrd<DateTime> for DateTime
sourcefn partial_cmp(&self, other: &DateTime) -> Option<Ordering>
fn partial_cmp(&self, other: &DateTime) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl Eq for DateTime
impl StructuralEq for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnwindSafe for DateTime
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more