可能重复:
C程序查找给定日期的星期几
我有一个日历文件,日期为“20121027T190000”,我需要将其转换为“1900 年 10 月 27 日,星期三”。是否有计算星期几的 C 函数?
可能重复:
C程序查找给定日期的星期几
我有一个日历文件,日期为“20121027T190000”,我需要将其转换为“1900 年 10 月 27 日,星期三”。是否有计算星期几的 C 函数?
Yes, the standard localtime()
function converts from a time_t
to a struct tm
that includes the day of the week. To create a time_t
value, you can use the mktime()
function to convert from a struct tm
to a time_t
(you do not have to fill in the day of the week when using mktime()
).
This might seem like a roundabout way to do this, but it's reasonably straightforward and uses standard library functions.