pub struct YmdHms { /* private fields */ }Expand description
Combined Gregorian date + wall time with subsecond precision.
Has some basic calendar aware math, but not time zone aware.
§Examples
Creating a YmdHms.
use deep_time::{Dt, Scale};
// clamped to 29
let x = Dt::from_ymd(2000, 2, 30, 0, 0, 0, 0, Scale::UTC).to_ymd();
assert_eq!(x.day(), 29);Adding a year. 2000 is a leap year and Feb. 29th is possible, but 2001 isn’t a leap year so the day is clamped to the 28th.
use deep_time::{Dt, Scale};
let x = Dt::from_ymd(2000, 2, 29, 0, 0, 0, 0, Scale::UTC).to_ymd();
let x = x.add_yr(1);
assert_eq!(x.day(), 28);Implementations§
Source§impl YmdHms
impl YmdHms
Sourcepub fn add_yr(&self, years: i64) -> Self
pub fn add_yr(&self, years: i64) -> Self
Adds (or subtracts) whole years, preserving month and day-of-month. Negative values subtract years. Uses standard last-day-of-month clamping.
Sourcepub fn add_mo(&self, months: i64) -> Self
pub fn add_mo(&self, months: i64) -> Self
Adds (or subtracts) whole months. Negative values subtract months.
Uses i128 total-month arithmetic to avoid overflow at extreme years.
Sourcepub fn add_days(&self, days: i64) -> Self
pub fn add_days(&self, days: i64) -> Self
Adds (or subtracts) calendar days using Julian Day arithmetic. Negative values subtract days.
pub fn add_wk(&self, weeks: i64) -> Self
pub fn add_attos(&self, attos: i128) -> Self
pub fn add_sec(&self, sec: i64) -> Self
pub fn add_min(&self, min: i64) -> Self
pub fn add_hr(&self, hr: i64) -> Self
pub fn yr(&self) -> i64
pub fn mo(&self) -> u8
pub fn day(&self) -> u8
pub fn hr(&self) -> u8
pub fn min(&self) -> u8
pub fn sec(&self) -> u8
pub fn attos(&self) -> u64
Sourcepub fn unix_attosec(&self) -> i128
pub fn unix_attosec(&self) -> i128
Attoseconds since 1970-01-01 midnight, on whatever time scale the object was created on.
pub fn iso_yr(&self) -> i64
pub fn iso_wk(&self) -> u8
pub fn day_of_yr(&self) -> u16
pub fn wkday(&self) -> Weekday
pub fn wk_of_yr_sun(&self) -> u8
pub fn wk_of_yr_mon(&self) -> u8
Sourcepub const fn unix_timestamp(&self) -> (i64, u64)
pub const fn unix_timestamp(&self) -> (i64, u64)
Returns the Unix timestamp since 1970-01-01 00:00:00 as a tuple of
(whole_seconds, attoseconds).
- The timestamp will be on whatever
Scalethe [DateTime] was created on. whole_secondscan be negative (for dates before 1970).- The fractional part (
attoseconds) is always in the range0..=999_999_999_999_999_999.
Trait Implementations§
impl Copy for YmdHms
Source§impl<'de> Deserialize<'de> for YmdHms
impl<'de> Deserialize<'de> for YmdHms
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>,
impl Eq for YmdHms
impl StructuralPartialEq for YmdHms
Source§impl Tsify for YmdHms
impl Tsify for YmdHms
const DECL: &'static str = "/**\n * Combined Gregorian date + wall time with subsecond precision.\n *\n * Has some basic calendar aware math, but not time zone aware.\n *\n * ## Examples\n *\n * **Creating a** [`YmdHms`].\n *\n * ```rust\n * use deep_time::{Dt, Scale};\n *\n * // clamped to 29\n * let x = Dt::from_ymd(2000, 2, 30, 0, 0, 0, 0, Scale::UTC).to_ymd();\n *\n * assert_eq!(x.day(), 29);\n * ```\n *\n * **Adding a year.** 2000 is a leap year and Feb. 29th is possible, but\n * 2001 isn\\\'t a leap year so the day is clamped to the 28th.\n *\n * ```rust\n * use deep_time::{Dt, Scale};\n *\n * let x = Dt::from_ymd(2000, 2, 29, 0, 0, 0, 0, Scale::UTC).to_ymd();\n * let x = x.add_yr(1);\n *\n * assert_eq!(x.day(), 28);\n * ```\n */\nexport interface YmdHms {\n yr: number;\n mo: number;\n day: number;\n hr: number;\n min: number;\n sec: number;\n attos: number;\n unix_attosec: number;\n scale: Scale;\n}"
const SERIALIZATION_CONFIG: SerializationConfig
type JsType = JsType
fn into_js(&self) -> Result<Self::JsType, Error>where
Self: Serialize,
fn from_js<T>(js: T) -> Result<Self, Error>
Auto Trait Implementations§
impl Freeze for YmdHms
impl RefUnwindSafe for YmdHms
impl Send for YmdHms
impl Sync for YmdHms
impl Unpin for YmdHms
impl UnsafeUnpin for YmdHms
impl UnwindSafe for YmdHms
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.