Struct packedtime_rs::EpochDays
source · pub struct EpochDays(/* private fields */);
Expand description
A date represented as the number of days since the unix epoch 1970-01-01.
Implementations§
source§impl EpochDays
impl EpochDays
pub fn new(epoch_days: i32) -> Self
pub fn days(&self) -> i32
sourcepub fn from_ymd(year: i32, month: i32, day: i32) -> Self
pub fn from_ymd(year: i32, month: i32, day: i32) -> Self
Convert a date to the number of days since the unix epoch 1970-01-01. See https://github.com/ThreeTen/threetenbp/blob/master/src/main/java/org/threeten/bp/LocalDate.java#L1634
sourcepub fn to_ymd(&self) -> (i32, i32, i32)
pub fn to_ymd(&self) -> (i32, i32, i32)
Convert the number of days since the unix epoch into a (year, month, day) tuple. See https://github.com/ThreeTen/threetenbp/blob/master/src/main/java/org/threeten/bp/LocalDate.java#L281 The resulting month and day values are 1-based.
pub fn from_timestamp_millis(ts: i64) -> Self
pub fn from_timestamp_millis_float(ts: f64) -> Self
pub fn to_timestamp_millis(&self) -> i64
pub fn to_timestamp_millis_float(&self) -> f64
sourcepub fn add_months(&self, months: i32) -> Self
pub fn add_months(&self, months: i32) -> Self
Adds the given number of months
to epoch_days
.
If the day would be out of range for the resulting month
then the date will be clamped to the end of the month.
For example: 2022-01-31 + 1month => 2022-02-28
sourcepub fn add_years(&self, years: i32) -> Self
pub fn add_years(&self, years: i32) -> Self
Adds the given number of years
to epoch_days
.
If the day would be out of range for the resulting month
then the date will be clamped to the end of the month.
For example: 2020-02-29 + 1year => 2021-02-28