calendar:date_to_gregorian_days/1
返回从公元零年到所给出的时间之间的天数
用法:
date_to_gregorian_days(Date) -> Days
内部实现:
-spec date_to_gregorian_days(Year, Month, Day) -> Days when Year :: year(), Month :: month(), Day :: day(), Days :: non_neg_integer(). date_to_gregorian_days(Year, Month, Day) when is_integer(Day), Day > 0 -> Last = last_day_of_the_month(Year, Month), if Day =< Last -> dy(Year) + dm(Month) + df(Year, Month) + Day - 1 end. -spec date_to_gregorian_days(Date) -> Days when Date :: date(), Days :: non_neg_integer(). date_to_gregorian_days({Year, Month, Day}) -> date_to_gregorian_days(Year, Month, Day).
获取从公元零年到所给出的时间 Date 之间的天数:
calendar:date_to_gregorian_days({1970, 1, 1}).
calendar:date_to_gregorian_days({2013, 9, 18}).