WinHex的两个时间函数

JAVA date+ time(64bit)

void foo( int& year, int& month, int& day )

    {

        //year = 1900;

        month = 1;

        day += 0;

        for( int n; n=(((year%4==0 && year%100!=0)||(year%400==0))?366:365), day>=n; day-=n, ++year );

            static int m[12] = { 31,0,31,30,31,30,31,31,30,31,30,31 };

            m[1] = ( ((year%4==0 && year%100!=0)||(year%400==0)) ? 29 : 28 );

        for( int i=0; day>=m[i]; day-=m[i], ++i, ++month );

    ++day;

}



CString Mylocaltime(UINT64 date)

{

    int dd = date/(24*60*60*1000);

    int ms = date%(24*60*60*1000);

    int year=1970;

    int month;

    foo( year, month, dd);

    int hh = ms/(1000*60*60);

    int min = (ms%(1000*60*60))/(1000*60);

    int sec = (ms%(1000*60*60))%(1000*60)/1000;

    CString str;

    str.Format(_T("%d-%.2d-%.2d %.2d:%.2d:%.2d"),year,month,dd,hh,min,sec);

    return str;


评论