예제 #1
0
time_t ctime::convert( const tm& aTm ) {
	time_t t = 0;
	t += aTm.tm_sec;
	t += aTm.tm_min  * 60;
	t += aTm.tm_hour * 60 * 60;
	t += aTm.tm_yday * 60 * 60 * 24;
	//[1970 , aT.tm_year + 1900) 이내의 날짜수 이므로 -1 해야한다.
	t += daycount( 1970 , ( aTm.tm_year + 1900 - 1 ) ) * (60 * 60 * 24);	
	//t -= ( 9 * 60 * 60 );
	return t;
}
예제 #2
0
int main(){
    int norm[] = {31,28,31,30,31,30,31,31,30,31,30,31};
    int leap[] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int res[] = {0,0,0,0,0,0,0};
    int i;
    int offset=readoffset();
    int lastday=6; // the week day of last year
    for(i=0;i<offset;i++){
        struct year temp;
        if(isleapyear(START_YEAR+i)==1){
            //printf("is leap %d\n",START_YEAR+i);
            temp.daynum = leap;
        }
        else
            temp.daynum = norm;
        temp.fisrtday = (lastday+1) % 7;
        //printf("%d\n",lastday);
        lastday = (lastday + daycount(temp)) % 7;
        count13(temp,res);

    }

    FILE *fout;
    char count[10];
    fout = fopen("friday.out","w");
    for(i=0;i<7;i++){
        sprintf(count,"%d",res[(i+12)%7]);
        fputs(count,fout);
        if ((i+12)%7!=4){
            fputs(" ",fout);
        }
        else
            fputs("\n",fout);
    }
    fclose(fout);
    exit(0);
//    printf("Isleap:%d",readoffset());
}