模块说明
导出函数
- date_to_gregorian_days(Date) -> Days
date_to_gregorian_days(Year, Month, Day) -> Days
返回日期的公历天数
- datetime_to_gregorian_seconds(DateTime) -> Seconds
返回日期时间的公历秒数
- day_of_the_week(Date) -> daynum()
day_of_the_week(Year, Month, Day) -> daynum()
返回日期是星期几。1-Monday 2-Tuesday 等等
- gregorian_days_to_date(Days) -> date()
公历天数转日期
- gregorian_seconds_to_datetime(Seconds) -> datetime()
公历秒数转日期时间
- is_leap_year(Year) -> boolean()
是否闰年
- iso_week_number() -> yearweeknum() 返回 local_time/0 对应日期的第几周
iso_week_number(Date) -> yearweeknum() 返回Date 对应的第几周
- last_day_of_the_month(Year, Month) -> LastDay
某年某月多少天
- local_time() -> datetime()
操作系统告知的本地时间
- local_time_to_universal_time(DateTime1) -> DateTime2
本地时间转世界时,申明废弃;建议使用如下版本
- local_time_to_universal_time_dst(DateTime1) -> [DateTime]
同上,考虑了夏令时。返回[] 对应那些不存在的日期时间,比如夏令时从5时直接进入6时,那么中间的本地时间就没有对应了。
返回 [DstDateTimeUTC,DateTimeUTC] 从夏令时改回来时,从6时改为5时,本地时间又走了一遍5时到6时,其中DstDateTimeUTC是夏令时起作用中;
DateTimeUTC是改回来后。这样理解对吧?
返回[DateTimeUTC] 对应那些一般日期时间
- now_to_local_time(Now) -> datetime1970()
erlang:now/0 的秒数元组转本地时间
- now_to_universal_time(Now) ->datetime1970()
now_to_datetime(Now) ->datetime1970()
erlang:now/0的秒数元组转世界时
- seconds_to_daystime(Seconds) -> {Days, Time}
秒数转{天数,时间}
- seconds_to_time(Seconds) -> time()
限制一天内的秒数[0,86400)转时间
- time_difference(T1, T2) -> {Days, Time}
废弃
- time_to_seconds(Time) -> secs_per_day()
时间转秒数
- universal_time() -> datetime()
世界时
- universal_time_to_local_time(DateTime) -> datetime()
时间时转本地时间
calendar
原文:http://www.cnblogs.com/rubyist/p/erlang_stdlib_calendar.html