pub struct JulianDate { /* private fields */ }Expand description
Representation of a proleptic Julian date. Only represents logic down to single-day accuracy: i.e., leap days are included, but leap seconds are not. This is useful in keeping this calendar applicable to all different time scales. Can represent years from -2^31 up to 2^31 - 1.
Implementations§
Source§impl JulianDate
impl JulianDate
Sourcepub const fn new(
year: i32,
month: Month,
day: u8,
) -> Result<Self, InvalidJulianDate>
pub const fn new( year: i32, month: Month, day: u8, ) -> Result<Self, InvalidJulianDate>
Creates a new Julian date, given its year, month, and day. If the date is not a
valid proleptic Julian date, returns a JulianDateDoesNotExist to indicate that the
requested date does not exist in the proleptic Julian calendar.
This function will never panic.
Sourcepub const fn from_date(date: Date) -> Self
pub const fn from_date(date: Date) -> Self
Constructs a Julian date from a given Date instance. Useful primarily when an
existing Date must be printed in human-readable format.
Uses Howard Hinnant’s julian_from_days algorithm.
Sourcepub const fn into_date(&self) -> Date
pub const fn into_date(&self) -> Date
Constructs a Date from a given Julian date. Uses Howard Hinnant’s days_from_julian
algorithm.
Sourcepub const fn from_ordinal_date(
year: i32,
day_of_year: u16,
) -> Result<Self, InvalidDayOfYear>
pub const fn from_ordinal_date( year: i32, day_of_year: u16, ) -> Result<Self, InvalidDayOfYear>
Creates a new date given only the year and the day-of-year. Implementation is based on an algorithm found by A. Pouplier and reported by Jean Meeus in Astronomical Algorithms.
This function will never panic.
Sourcepub const fn year(&self) -> i32
pub const fn year(&self) -> i32
Returns the year stored inside this proleptic Julian date. Astronomical year numbering is used (as also done in NAIF SPICE): the year 1 BCE is represented as 0, 2 BCE as -1, etc. Hence, around the year 0, the numbering is …, -2 (3 BCE), -1 (2 BCE), 0 (1 BCE), 1 (1 CE), 2 (2 CE), et cetera. In this manner, the year numbering proceeds smoothly through 0.
Source§impl JulianDate
impl JulianDate
Sourcepub fn parse_partial(
string: &str,
) -> Result<(Self, &str), JulianDateParsingError>
pub fn parse_partial( string: &str, ) -> Result<(Self, &str), JulianDateParsingError>
Parses a JulianDate based on some string. Accepts only the extended complete calendar
date format specified in ISO 8601 (see section 5.2.2.1), though in addition any number of
digits is accepted for the years term - to extend applicability of the format to a larger
time range.
On success, returns the resulting JulianDate and any remaining input that was not yet
parsed. On failure, returns a reason indicating why.
Trait Implementations§
Source§impl Clone for JulianDate
impl Clone for JulianDate
Source§fn clone(&self) -> JulianDate
fn clone(&self) -> JulianDate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JulianDate
impl Debug for JulianDate
Source§impl From<Date> for JulianDate
impl From<Date> for JulianDate
Source§impl From<JulianDate> for Date
impl From<JulianDate> for Date
Source§fn from(value: JulianDate) -> Self
fn from(value: JulianDate) -> Self
Source§impl FromStr for JulianDate
impl FromStr for JulianDate
Source§fn from_str(string: &str) -> Result<Self, Self::Err>
fn from_str(string: &str) -> Result<Self, Self::Err>
Parses a JulianDate based on some string. Accepts only the extended complete calendar
date format specified in ISO 8601 (see section 5.2.2.1), though in addition any number of
digits is accepted for each term.