/********************************************************************* * GetLocalTime (KERNEL32.@) * * Get the current local time. * * PARAMS * systime [O] Destination for current time. * * RETURNS * Nothing. */ VOID WINAPI GetLocalTime(LPSYSTEMTIME systime) { FILETIME lft; LARGE_INTEGER ft, ft2; NtQuerySystemTime(&ft); RtlSystemTimeToLocalTime(&ft, &ft2); lft.dwLowDateTime = ft2.u.LowPart; lft.dwHighDateTime = ft2.u.HighPart; FileTimeToSystemTime(&lft, systime); }
BOOL WINAPI FileTimeToLocalFileTime( const FILETIME *utcft, LPFILETIME localft ) { LARGE_INTEGER local, utc; TRACEN((printf("FileTimeToLocalFileTime\n"))) utc.QuadPart = utcft->dwHighDateTime; utc.QuadPart = (utc.QuadPart << 32) | utcft->dwLowDateTime; RtlSystemTimeToLocalTime( &utc, &local ); localft->dwLowDateTime = (DWORD)local.QuadPart; localft->dwHighDateTime = (DWORD)(local.QuadPart >> 32); return TRUE; }
/********************************************************************* * FileTimeToLocalFileTime (KERNEL32.@) */ BOOL WINAPI FileTimeToLocalFileTime( const FILETIME *utcft, LPFILETIME localft ) { NTSTATUS status; LARGE_INTEGER local, utc; utc.u.LowPart = utcft->dwLowDateTime; utc.u.HighPart = utcft->dwHighDateTime; if (!(status = RtlSystemTimeToLocalTime( &utc, &local ))) { localft->dwLowDateTime = local.u.LowPart; localft->dwHighDateTime = local.u.HighPart; } else SetLastError( RtlNtStatusToDosError(status) ); return !status; }
/*++ * @name RtlCliDumpFileInfo * * The RtlCliDumpFileInfo routine FILLMEIN * * @param DirInfo * FILLMEIN * * @return None. * * @remarks Documentation for this routine needs to be completed. * *--*/ VOID RtlCliDumpFileInfo(PFILE_BOTH_DIR_INFORMATION DirInfo) { PWCHAR Null; WCHAR Save; TIME_FIELDS Time; CHAR SizeString[16]; WCHAR ShortString[12+1]; WCHAR FileString[MAX_PATH+1]; WCHAR FileStringSize[100]; WCHAR ShortStringSize[100]; UINT file_size = 0; UINT short_size = 0; // // The filename isn't null-terminated, and the next structure follows // right after it. So, we save the next char (which ends up being the // NextEntryOffset of the next structure), then temporarly clear it so // that the RtlCliDisplayString can treat it as a null-terminated string // Null = (PWCHAR)((PBYTE)DirInfo->FileName + DirInfo->FileNameLength); Save = *Null; *Null = 0; // // Get the last access time // RtlSystemTimeToLocalTime(&DirInfo->CreationTime, &DirInfo->CreationTime); RtlTimeToTimeFields(&DirInfo->CreationTime, &Time); // // Don't display sizes for directories // if (!(DirInfo->FileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { sprintf(SizeString, "%d", DirInfo->AllocationSize.LowPart); } else { sprintf(SizeString, " ", DirInfo->AllocationSize.LowPart); } // // Display this entry // // 75 symbols. file_size = DirInfo->FileNameLength / sizeof(WCHAR); short_size = DirInfo->ShortNameLength / sizeof(WCHAR); swprintf(ShortStringSize, L"%d", short_size); swprintf(FileStringSize, L"%d", file_size); if (DirInfo->ShortNameLength) { memset(ShortString, 0x00, (12+1)*sizeof(WCHAR)); wcsncpy(ShortString, DirInfo->ShortName, short_size); } else { swprintf(ShortString, L" "); } if (DirInfo->FileNameLength) { memset(FileString, 0x00, (MAX_PATH+1)*sizeof(WCHAR)); wcsncpy(FileString, DirInfo->FileName, file_size); } else { swprintf(FileString, L" "); } RtlCliDisplayString("%02d.%02d.%04d %02d:%02d %s %9s %-28S %12S\n", Time.Day, Time.Month, Time.Year, Time.Hour, Time.Minute, DirInfo->FileAttributes & FILE_ATTRIBUTE_DIRECTORY ? "<DIR>" : " ", SizeString, FileString, ShortString); // // Restore the character that was here before // *Null = Save; }
PSTR SystemTimeToString( LONGLONG Value ) /*++ Routine Description: Maps a LONGLONG representing system time to a displayable string. Arguments: Value - The LONGLONG time to map. Return Value: PSTR - Points to the displayable form of the system time. Notes: This routine is NOT multithread safe! --*/ { static char buffer[64]; NTSTATUS status; LARGE_INTEGER systemTime; LARGE_INTEGER localTime; TIME_FIELDS timeFields; systemTime.QuadPart = Value; status = RtlSystemTimeToLocalTime( &systemTime, &localTime ); if( !NT_SUCCESS(status) ) { return LongLongToString( Value ); } RtlTimeToTimeFields( &localTime, &timeFields ); sprintf( buffer, "%s %s %2d %4d %02d:%02d:%02d.%03d", WeekdayNames[timeFields.Weekday], MonthNames[timeFields.Month], timeFields.Day, timeFields.Year, timeFields.Hour, timeFields.Minute, timeFields.Second, timeFields.Milliseconds ); return buffer; } // SystemTimeToString