|
TDataTime을 알아보시는 것도 좋을 듯하네요.
0 12/30/1899 12:00 am
2.75 1/1/1900 6:00 pm
-1.25 12/29/1899 6:00 am
35065 1/1/1996 12:00 am
정수부 값은 경과일 을 나타내고 기준일이 있지만
현재 시간에서 만약 7일 전이나 후를 구하신다면
CurrentDataTime 함수로 현재시간을 읽어 들여 그냥 7을 빼시구
편하신 포맷의 형태로 변환만 하시면 변환 가능합니다.
보탬이 되었는지 모르겠네요 .. 저도 초보라서 ^^
양종열 님이 쓰신 글 :
: 임의의 날짜까지의 경과일구하는건 알겠는데요..
: 여기서 경과일을 변경시키고 다시 그 경과일로 날짜를 출력하는 함수를 알려주세요..
: 밑에는 날짜에서 경과일을 출력하는 프로그램입니다.
:
:
: #include "stdio.h"
:
: int leap_year(int year);
: int total_days(int year, int month, int day);
:
: void main()
: {
: int year, month, day, total;
: char date[][10]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
:
: printf("enter year, month, day : ");
: scanf("%d%d%d", &year, &month, &day);
: total = total_days(year, month, day);
:
:
:
: // 1980년 1월 1일이 화요일이므로 +1
: printf("total days : %d / %s\n", total, date[(total+1) % 7]);
: }
:
: int leap_year(int year)
: {
: if (!(year % 400)) return 1;
: else if (!(year % 100)) return 0;
: else if (!(year % 4)) return 1;
: else return 0;
: }
:
:
:
: // 1980년 1월 1일 입력하면 1을 리턴함.
:
: // 0을 리턴해야 된다면 약간 수정해야 함
:
: int total_days(int year, int month, int day)
: {
: int total=0, i;
: int dayofmonth[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
: if (year < 1980) return 0;
: for (i = 1980 ; i < year ; i++)
: {
: total += 365;
: if (leap_year(i)) total++;
: }
:
: for (i = 1 ; i < month ; i++) total+=dayofmonth[i-1];
:
: // 윤년이고 3월 이후면 2월 29일 고려 +1
: if (leap_year(year) && (month>2)) total++;
: total+=day;
:
: return total;
: }
:
|