BOOL WINAPI DosDateTimeToFileTime( WORD fatdate, WORD fattime, FILETIME * ft) { struct tm newtm; #ifndef ENV_HAVE_TIMEGM struct tm *gtm; time_t time1, time2; #endif TRACEN((printf("DosDateTimeToFileTime\n"))) newtm.tm_sec = (fattime & 0x1f) * 2; newtm.tm_min = (fattime >> 5) & 0x3f; newtm.tm_hour = (fattime >> 11); newtm.tm_mday = (fatdate & 0x1f); newtm.tm_mon = ((fatdate >> 5) & 0x0f) - 1; newtm.tm_year = (fatdate >> 9) + 80; newtm.tm_isdst = -1; #ifdef ENV_HAVE_TIMEGM RtlSecondsSince1970ToFileTime( timegm(&newtm), ft ); #else newtm.tm_isdst = 0; time1 = mktime(&newtm); gtm = gmtime(&time1); time2 = mktime(gtm); RtlSecondsSince1970ToFileTime( 2*time1-time2, ft ); #endif TRACEN((printf("DosDateTimeToFileTime(%ld,%ld) => %lx %lx\n", (long)fatdate,(long)fattime, (long)ft->dwHighDateTime,(long)ft->dwLowDateTime))) return TRUE; }
BOOL WINAPI DosDateTimeToFileTime( WORD fatdate, WORD fattime, LPFILETIME ft) { struct tm newtm; #ifndef HAVE_TIMEGM struct tm *gtm; time_t time1, time2; #endif TRACEN((printf("DosDateTimeToFileTime\n"))) newtm.tm_sec = (fattime & 0x1f) * 2; newtm.tm_min = (fattime >> 5) & 0x3f; newtm.tm_hour = (fattime >> 11); newtm.tm_mday = (fatdate & 0x1f); newtm.tm_mon = ((fatdate >> 5) & 0x0f) - 1; newtm.tm_year = (fatdate >> 9) + 80; #ifdef HAVE_TIMEGM TRACEN((printf("DosDateTimeToFileTime-1\n"))) RtlSecondsSince1970ToFileTime( timegm(&newtm), ft ); #else TRACEN((printf("DosDateTimeToFileTime-2\n"))) time1 = mktime(&newtm); gtm = gmtime(&time1); time2 = mktime(gtm); RtlSecondsSince1970ToFileTime( 2*time1-time2, ft ); #endif return TRUE; }
BOOL WINAPI DosDateTimeToFileTime( WORD fatdate, WORD fattime, FILETIME * ft) { struct tm newtm; TRACEN((printf("DosDateTimeToFileTime\n"))) // memset(&newtm,0,sizeof(newtm)); newtm.tm_sec = (fattime & 0x1f) * 2; newtm.tm_min = (fattime >> 5) & 0x3f; newtm.tm_hour = (fattime >> 11); newtm.tm_mday = (fatdate & 0x1f); newtm.tm_mon = ((fatdate >> 5) & 0x0f) - 1; newtm.tm_year = (fatdate >> 9) + 80; newtm.tm_isdst = -1; time_t time1 = mktime(&newtm); LONG bias = TIME_GetBias(); RtlSecondsSince1970ToFileTime( time1 - bias, ft ); TRACEN((printf("DosDateTimeToFileTime(%ld,%ld) t1=%ld bias=%ld => %lx %lx\n", (long)fatdate,(long)fattime,(long)time1,(long)bias, (long)ft->dwHighDateTime,(long)ft->dwLowDateTime))) return TRUE; }