Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
use super::funejson::Value; ← the fune runtime: the JSON value the test vectors use; fune build keeps it only where a signature takes one
use super::dates_add_days::is_leap_year as kernel_is_leap_year;
/// Whether a year is a Gregorian leap year. The rule lives in dates.add-days;
/// this adds the range check so a year of 0 or 10000 fails loudly rather than
/// answering for a year no ISO date can name.
///
/// # Panics
/// Panics if the year is outside 1-9999.
pub fn is_leap_year(year: i64) -> bool {
if !(1..=9999).contains(&year) {
panic!("year {} is outside the supported range 1 to 9999", year);
}
kernel_is_leap_year(year)
}
pub fn fune_vector(args: &[Value]) -> Value {
// Refuse what the typed signature cannot hold, with the wording TypeScript
// and Python use, rather than let the conversion below quietly change it.
if let Value::Float(f) = args[0] {
if f.fract() != 0.0 {
panic!("year must be an integer, received {}", f);
}
}
Value::Bool(is_leap_year(args[0].as_i64()))
}