관련글: http://joinc.co.kr/modules.php?op=modload&name=Forum&file=viewtopic&topic=31448&forum=1
문제점: 한주의 시작을 일요일로 정의할것인지 월요일로 정의할것인지 필요.
문제점: 한주의 시작을 일요일로 정의할것인지 월요일로 정의할것인지 필요.
| 코드: |
| #include <stdio.h> #include <string.h> #include <time.h> int (week_of_year)(time_t s_time_t) { struct tm *s_tm; s_tm = localtime((time_t *)(&s_time_t)); return(((s_tm->tm_yday + (6 - s_tm->tm_wday)) / 7) + 1); } int (main)(void) { time_t s_time_t; s_time_t = time(NULL); (void)fprintf(stdout, "current time = %snweek of year = %dn", ctime((time_t *)(&s_time_t)), week_of_year(s_time_t)); return(0); } /* End of source */ |




댓글을 달아 주세요