pub struct DateTime {
pub nano: 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§
§nano: u320…999999999
sec: u80…59
min: u80…59
hour: u80…23
day: u81…31
mon: u81…12
year: u161970…9999
Implementations§
source§impl 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 add_sub_sec(self, sec: i64) -> Self
pub fn add_sub_sec(self, sec: i64) -> Self
add/sub 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§
source§impl<'de> Deserialize<'de> for DateTime
impl<'de> Deserialize<'de> for DateTime
source§fn 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
source§impl From<DateTime> for SystemTime
impl From<DateTime> for SystemTime
source§fn from(v: DateTime) -> SystemTime
fn from(v: DateTime) -> SystemTime
Converts to this type from the input type.
source§impl From<SystemTime> for DateTime
impl From<SystemTime> for DateTime
source§fn from(v: SystemTime) -> DateTime
fn from(v: SystemTime) -> DateTime
Converts to this type from the input type.
source§impl Ord for DateTime
impl Ord for DateTime
source§impl PartialOrd<DateTime> for DateTime
impl PartialOrd<DateTime> for DateTime
1.0.0 · source§fn 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