/// Returns if the provided year is a leap year in the proleptic Gregorian calendar. Uses /// [astronomical year numbering](https://en.wikipedia.org/wiki/Astronomical_year_numbering). /// /// ```rust /// # use time::util::is_leap_year; /// assert!(!is_leap_year(1900)); /// assert!(is_leap_year(2000)); /// assert!(is_leap_year(2004)); /// assert!(!is_leap_year(2005)); /// assert!(!is_leap_year(2100)); /// ``` pubconstfn is_leap_year(year: i32) -> bool {
year % 4 == 0 && (year % 25 != 0 || year % 16 == 0)
}
/// Get the number of calendar days in a given year. /// /// The returned value will always be either 365 or 366. /// /// ```rust /// # use time::util::days_in_year; /// assert_eq!(days_in_year(1900), 365); /// assert_eq!(days_in_year(2000), 366); /// assert_eq!(days_in_year(2004), 366); /// assert_eq!(days_in_year(2005), 365); /// assert_eq!(days_in_year(2100), 365); /// ``` pubconstfn days_in_year(year: i32) -> u16 { if is_leap_year(year) { 366 } else { 365 }
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.