给定日期,获取星期几 - SYSTEMTIME
如果提供了日期(月-日-年),是否可以使用 SYSTEMTIME 确定星期几,或者该结构只是单向的?
如果 SYSTEMTIME 无法做到这一点(使用 Win32),完成我所要求的任务的最轻量级方法是什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如果提供了日期(月-日-年),是否可以使用 SYSTEMTIME 确定星期几,或者该结构只是单向的?
如果 SYSTEMTIME 无法做到这一点(使用 Win32),完成我所要求的任务的最轻量级方法是什么?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
根据 msdn,
SYSTEMTIME 转换为
FILETIME
时,>wDayOfWeek 成员将被忽略。转换回来的时候就填了。According to the msdn, the
wDayOfWeek
member is ignored when convertingSYSTEMTIME
toFILETIME
. When converting back, it's filled in.另一种可能更加独立于平台的方法是使用 localtime< /a> 或 gmtime。
例如,打印当前星期几:
Another way of doing it that might be a bit more platform independent would be to use localtime or gmtime.
For example, print current day of week:
使用 SystemTimeToFileTime 将 SYSTEMTIME 转换为 FILETIME。然后使用 FileTimeToSystemTime 将其转换为带有星期几的 SYSTEMTIME。
Use SystemTimeToFileTime to covert the SYSTEMTIME to a FILETIME. Then use FileTimeToSystemTimeto convert it to a SYSTEMTIME with day of week.