pub struct DateTime {
pub inner: OffsetDateTime,
}Expand description
Log timestamp type.
Parse using FromStr impl.
Format using the Display trait.
Convert timestamp into/from SystemTime to use.
Supports compare and sorting.
Fields§
§inner: OffsetDateTimeImplementations§
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) -> i128
pub fn unix_timestamp_nano(&self) -> i128
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: i128) -> DateTime
pub fn from_timestamp_nano(nano: i128) -> 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: parse local time
fastdate::DateTime::parse("YYYY-MM-DD hh:mm:ss.000000","2022-12-13 11:12:14.123456").unwrap();or any position
fastdate::DateTime::parse("YYYY-MM-DD,hh:mm:ss.000000","2022-12-13,11:12:14.123456").unwrap();or time zone(UTC)
fastdate::DateTime::parse("YYYY-MM-DD hh:mm:ss.000000", "2022-12-13 11:12:14.123456Z").unwrap();or time zone(UTC+Hour)
fastdate::DateTime::parse("YYYY-MM-DD hh:mm:ss.000000", "2022-12-13 11:12:14.123456+06:00").unwrap();pub fn nano(&self) -> u32
pub fn ms(&self) -> u16
pub fn from_system_time(s: SystemTime, offset: i32) -> Self
sourcepub fn display_stand(&self) -> String
pub fn display_stand(&self) -> String
stand “0000-00-00 00:00:00.000000000”
sourcepub fn display(&self, zone: bool) -> String
pub fn display(&self, zone: bool) -> String
RFC3339 “0000-00-00T00:00:00.000000000Z” RFC3339 “0000-00-00T00:00:00.000000000+00:00:00”
sourcepub fn do_display(&self, buf: &mut [u8; 38], add_zone: bool) -> usize
pub fn do_display(&self, buf: &mut [u8; 38], add_zone: bool) -> usize
let mut buf: [u8; 38] = *b“0000-00-00T00:00:00.000000000+00:00:00“; than print this: RFC3339 “0000-00-00T00:00:00.000000000Z” RFC3339 “0000-00-00T00:00:00.000000000+00:00:00”
pub fn set_nano(self, nano: u32) -> Self
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 PartialEq for DateTime
impl PartialEq for DateTime
source§impl PartialOrd for DateTime
impl PartialOrd 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 moreimpl 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§
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