pub struct Timestamp(/* private fields */);Expand description
Timestamp represents absolute time.
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn try_from_ymd_hms(
year: i32,
month: i32,
day: i32,
hour: i32,
minute: i32,
second: f64,
) -> Result<Self, DateTimeError>
pub fn try_from_ymd_hms( year: i32, month: i32, day: i32, hour: i32, minute: i32, second: f64, ) -> Result<Self, DateTimeError>
Construct Timestamp from year, month, day, hour, minute, second. Second can indicate millisecond and microsecond.
Sourcepub fn try_from_str(
s: &str,
type_mod: i32,
date_order: DateOrder,
) -> Result<Timestamp, DateTimeError>
pub fn try_from_str( s: &str, type_mod: i32, date_order: DateOrder, ) -> Result<Timestamp, DateTimeError>
Parses Timestamp string. type_mode should be -1, or 1~6, else will be error.
Sourcepub fn format(
self,
date_style: DateStyle,
date_order: DateOrder,
) -> Result<String, DateTimeError>
pub fn format( self, date_style: DateStyle, date_order: DateOrder, ) -> Result<String, DateTimeError>
Converts Timestamp to string.
Sourcepub fn add_interval(self, span: Interval) -> Result<Self, DateTimeError>
pub fn add_interval(self, span: Interval) -> Result<Self, DateTimeError>
Timestamp add Interval.
Note that interval has provisions for qualitative year/month and day
units, so try to do the right thing with them.
To add a month, increment the month, and use the same day of month.
Then, if the next month has fewer days, set the day of month
to the last day of month.
To add a day, increment the mday, and use the same time of day.
Lastly, add in the “quantitative time”.
Sourcepub fn sub_interval(self, span: Interval) -> Result<Timestamp, DateTimeError>
pub fn sub_interval(self, span: Interval) -> Result<Timestamp, DateTimeError>
Timestamp subtracts Interval.
Sourcepub fn sub_time(self, time: Time) -> Result<Timestamp, DateTimeError>
pub fn sub_time(self, time: Time) -> Result<Timestamp, DateTimeError>
Timestamp subtracts Time.
Sourcepub fn sub_timestamp(
self,
timestamp: Timestamp,
) -> Result<Interval, DateTimeError>
pub fn sub_timestamp( self, timestamp: Timestamp, ) -> Result<Interval, DateTimeError>
Timestamp subtracts Timestamp.
Trait Implementations§
Source§impl DateTime for Timestamp
impl DateTime for Timestamp
Source§fn date_part(
&self,
ty: FieldType,
unit: DateUnit,
) -> Result<Option<f64>, DateTimeError>
fn date_part( &self, ty: FieldType, unit: DateUnit, ) -> Result<Option<f64>, DateTimeError>
Extracts specified field from Timestamp.
Source§fn truncate(&self, ty: FieldType, unit: DateUnit) -> Result<Self, DateTimeError>
fn truncate(&self, ty: FieldType, unit: DateUnit) -> Result<Self, DateTimeError>
Truncates Timestamp to specified units.