kealon

博客园 首页 新随笔 联系 订阅 管理

计算2001年7月4日是星期几。

#include<stdio.h>

#include<time.h>

static const char *const wday[] = {

  "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "-unknown-"

};

struct tm time_str;

tume_str.tm_year = 2001 - 1900;            //years since 1900

time_str.tm_mon = 7 - 1;

time_str.tm_mday = 4;

time_str.tm_hour = 0;

time_str.tm_min = 0;

time_str.tm_sec = 1;

time_str.tm_isdst = -1;

if (mktime(&time_str) == -1)

  time_str.tm_wday = 7;

printf("%s\n", wday[time_str.tm_wday]);

posted on 2012-03-25 10:41  kealon  阅读(295)  评论(0编辑  收藏  举报