> Erlang中文手册 > gregorian_days_to_date/1 把天数转换为日期

calendar:gregorian_days_to_date/1

把天数转换为日期

用法:

gregorian_days_to_date(Days) -> date()

内部实现:

%% gregorian_days_to_date(Days) = {Year, Month, Day}
%%
-spec gregorian_days_to_date(Days) -> date() when
      Days :: non_neg_integer().
gregorian_days_to_date(Days) ->
    {Year, DayOfYear} = day_to_year(Days),
    {Month, DayOfMonth} = year_day_to_date(Year, DayOfYear),
    {Year, Month, DayOfMonth}.

把给出的天数 Days 转换为日期(从公元 0 年开始计算)。

calendar:gregorian_days_to_date(1000).