给定日期,获取星期几 - SYSTEMTIME [英] Given Date, Get Day of Week - SYSTEMTIME
本文介绍了给定日期,获取星期几 - SYSTEMTIME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果提供日期(月 - 日 - 年),或者此结构是单向的,那么可以使用SYSTEMTIME确定星期几?
解决方案
如果SYSTEMTIME无法做到这一点,根据 msdn ,当将
成员。 SYSTEMTIME
转换为 FILETIME
时,将忽略wDayOfWeek
SYSTEMTIME t = {2010,6,-1 / * ignored * /,11} ;
FILETIME ft;
HRESULT hrto = SystemTimeToFileTime(& t,& ft);
HRESULT hrback = FileTimeToSystemTime(& ft,& t);
WORD dayofweek = t.wDayOfWeek;
Is it possible to determine the day of the week, using SYSTEMTIME, if a date (month-day-year) is provided or is this structure one-way only?
What is the most lightweight way to accomplish what I am asking if SYSTEMTIME cannot do it (using Win32)?
解决方案
According to the msdn, the wDayOfWeek
member is ignored when converting SYSTEMTIME
to FILETIME
. When converting back, it's filled in.
SYSTEMTIME t = { 2010, 6, -1 /*ignored*/, 11 };
FILETIME ft;
HRESULT hrto = SystemTimeToFileTime( &t, &ft );
HRESULT hrback = FileTimeToSystemTime( &ft, &t );
WORD dayofweek = t.wDayOfWeek;
这篇关于给定日期,获取星期几 - SYSTEMTIME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文