/*********************************************************************** * TzSpecificLocalTimeToSystemTime (KERNEL32.@) * * Converts a local time to a time in utc. * * PARAMS * lpTimeZoneInformation [in] The desired time zone. * lpLocalTime [in] The local time. * lpUniversalTime [out] The calculated utc time. * * RETURNS * Success: TRUE. lpUniversalTime contains the converted time. * Failure: FALSE. */ BOOL WINAPI TzSpecificLocalTimeToSystemTime( const TIME_ZONE_INFORMATION *lpTimeZoneInformation, const SYSTEMTIME *lpLocalTime, LPSYSTEMTIME lpUniversalTime) { FILETIME ft; LONG lBias; LONGLONG t; TIME_ZONE_INFORMATION tzinfo; if (lpTimeZoneInformation != NULL) { tzinfo = *lpTimeZoneInformation; } else { if (GetTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_INVALID) return FALSE; } if (!SystemTimeToFileTime(lpLocalTime, &ft)) return FALSE; FILETIME2LL( &ft, t) if (!TIME_GetTimezoneBias(&tzinfo, &ft, TRUE, &lBias)) return FALSE; /* convert minutes to 100-nanoseconds-ticks */ t += (LONGLONG)lBias * 600000000; LL2FILETIME( t, &ft) return FileTimeToSystemTime(&ft, lpUniversalTime); }
BOOL WINAPI SystemTimeToTzSpecificLocalTime( LPTIME_ZONE_INFORMATION lpTimeZoneInformation, LPSYSTEMTIME lpUniversalTime, LPSYSTEMTIME lpLocalTime ) { FILETIME ft; LONG lBias; LONGLONG llTime; TIME_ZONE_INFORMATION tzinfo; if (lpTimeZoneInformation != NULL) { memcpy(&tzinfo, lpTimeZoneInformation, sizeof(TIME_ZONE_INFORMATION)); } else { if (GetTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_INVALID) return FALSE; } if (!SystemTimeToFileTime(lpUniversalTime, &ft)) return FALSE; FILETIME2LL( &ft, llTime) if (!TIME_GetTimezoneBias(&tzinfo, &ft, FALSE, &lBias)) return FALSE; /* convert minutes to 100-nanoseconds-ticks */ llTime -= (LONGLONG)lBias * 600000000; LL2FILETIME( llTime, &ft) return FileTimeToSystemTime(&ft, lpLocalTime); }
/* * @implemented */ BOOL WINAPI SystemTimeToTzSpecificLocalTime(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, CONST SYSTEMTIME *lpUniversalTime, LPSYSTEMTIME lpLocalTime) { TIME_ZONE_INFORMATION TzInfo; FILETIME FileTime; LONGLONG llTime; LONG lBias; if (lpTimeZoneInformation != NULL) { TzInfo = *lpTimeZoneInformation; } else { if (GetTimeZoneInformation(&TzInfo) == TIME_ZONE_ID_INVALID) return FALSE; } if (!lpUniversalTime || !lpLocalTime) return FALSE; if (!SystemTimeToFileTime(lpUniversalTime, &FileTime)) return FALSE; FILETIME2LL(&FileTime, llTime) if (!TIME_GetTimezoneBias(&TzInfo, &FileTime, FALSE, &lBias)) return FALSE; /* convert minutes to 100-nanoseconds-ticks */ llTime -= (LONGLONG)lBias * TICKSPERMIN; LL2FILETIME( llTime, &FileTime) return FileTimeToSystemTime(&FileTime, lpLocalTime); }