calendar:is_leap_year/1
判断一个年份是否是闰年
用法:
is_leap_year(Year) -> boolean()
内部实现:
%% is_leap_year(Year) = true | false %% -spec is_leap_year(Year) -> boolean() when Year :: year(). is_leap_year(Y) when is_integer(Y), Y >= 0 -> is_leap_year1(Y). -spec is_leap_year1(year()) -> boolean(). is_leap_year1(Year) when Year rem 4 =:= 0, Year rem 100 > 0 -> true; is_leap_year1(Year) when Year rem 400 =:= 0 -> true; is_leap_year1(_) -> false.
这个函数检查一个年份是否为闰年。
calendar:is_leap_year(1996).
calendar:is_leap_year(2009).
{{Year, _Month, _Day}, {_Hour, _Minute, _Second}} = calendar:now_to_local_time(os:timestamp()), calendar:is_leap_year(Year).