<分区>
我有这样的日期字符串:
"2015-11-27"
我想从中确定星期几。
这 ( live sample ) 是我使用 <ctime>
的方式:
int dayOfWeek(std::string date){
int y, m, d; char c;
std::stringstream(date) >> y >> c >> m >> c >> d;
std::tm t = {0,0,0,d,m-1,y-1900};
std::mktime(&t);
return t.tm_wday;
}
但我想知道在 C++11 中是否有更规范的方法来解决这个问题?