calendar:datetime_to_gregorian_seconds/1
计算从公历 0 年开始到以给定的日期和时间为结束间的秒数
用法:
datetime_to_gregorian_seconds(DateTime) -> Seconds
内部实现:
%% datetime_to_gregorian_seconds(DateTime) = Integer %% %% Computes the total number of seconds starting from year 0, %% January 1st. %% -spec datetime_to_gregorian_seconds(DateTime) -> Seconds when DateTime :: datetime(), Seconds :: non_neg_integer(). datetime_to_gregorian_seconds({Date, Time}) -> ?SECONDS_PER_DAY*date_to_gregorian_days(Date) + time_to_seconds(Time).
计算从公历 0 年开始到以给定的日期和时间为结束间的秒数。
calendar:datetime_to_gregorian_seconds({{1970, 1, 1}, {0, 0, 0}}).
calendar:datetime_to_gregorian_seconds({{2014, 7, 10}, {20, 22, 31}}).