pub struct ThaiDate {
pub day: u8,
pub month: u8,
pub year: u32,
pub era: Era,
}Expand description
A parsed Thai date with day, month, year, and era.
Fields§
§day: u8Day of month (1–31).
month: u8Month number (1–12).
year: u32Year in the stated Era.
era: EraEra system for this date.
Implementations§
Source§impl ThaiDate
impl ThaiDate
Sourcepub fn gregorian_year(&self) -> i32
pub fn gregorian_year(&self) -> i32
Returns the year in Gregorian (CE).
Buddhist years subtract 543; Gregorian years are returned as-is.
Sourcepub fn buddhist_year(&self) -> u32
pub fn buddhist_year(&self) -> u32
Returns the year in Buddhist Era (BE).
Gregorian years add 543; Buddhist years are returned as-is.
Sourcepub fn to_iso8601(&self) -> String
pub fn to_iso8601(&self) -> String
Formats the date as an ISO 8601 string (YYYY-MM-DD) using Gregorian year.
use kham_core::date::parse_thai_date;
let d = parse_thai_date("5 กรกฎาคม 2567").unwrap();
assert_eq!(d.to_iso8601(), "2024-07-05");Sourcepub fn to_thai_text(&self) -> String
pub fn to_thai_text(&self) -> String
Formats the date as Thai text: "5 กรกฎาคม พ.ศ. 2567".
The year is always expressed in Buddhist Era.
use kham_core::date::parse_thai_date;
let d = parse_thai_date("5/7/2567").unwrap();
assert_eq!(d.to_thai_text(), "5 กรกฎาคม พ.ศ. 2567");Trait Implementations§
impl Eq for ThaiDate
impl StructuralPartialEq for ThaiDate
Auto Trait Implementations§
impl Freeze for ThaiDate
impl RefUnwindSafe for ThaiDate
impl Send for ThaiDate
impl Sync for ThaiDate
impl Unpin for ThaiDate
impl UnsafeUnpin for ThaiDate
impl UnwindSafe for ThaiDate
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