This change removes all references to the timezone variable, all the functions that
transitively depended on it from PAL and all the related tests.
None of these was used outside of PAL and the tests.
OUT LPFILETIME lpLastWriteTime);
PALIMPORT
-BOOL
-PALAPI
-FileTimeToLocalFileTime(
- IN CONST FILETIME *lpFileTime,
- OUT LPFILETIME lpLocalFileTime);
-
-PALIMPORT
-BOOL
-PALAPI
-LocalFileTimeToFileTime(
- IN CONST FILETIME *lpLocalFileTime,
- OUT LPFILETIME lpFileTime);
-
-
-PALIMPORT
VOID
PALAPI
GetSystemTimeAsFileTime(
OUT LPWORD lpFatTime
);
-PALIMPORT
-BOOL
-PALAPI
-DosDateTimeToFileTime(
- IN WORD wFatDate,
- IN WORD wFatTime,
- OUT LPFILETIME lpFileTime
- );
-
PALIMPORT
IN int cchLocaleName);
-
-
-#define TIME_ZONE_ID_INVALID ((DWORD)0xFFFFFFFF)
-#define TIME_ZONE_ID_UNKNOWN 0
-#define TIME_ZONE_ID_STANDARD 1
-#define TIME_ZONE_ID_DAYLIGHT 2
-
-
-typedef struct _TIME_ZONE_INFORMATION {
- LONG Bias;
- WCHAR StandardName[ 32 ];
- SYSTEMTIME StandardDate;
- LONG StandardBias;
- WCHAR DaylightName[ 32 ];
- SYSTEMTIME DaylightDate;
- LONG DaylightBias;
-} TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION;
-
-PALIMPORT
-DWORD
-PALAPI
-GetTimeZoneInformation(
- OUT LPTIME_ZONE_INFORMATION lpTimeZoneInformation);
-
-PALIMPORT
-DWORD
-PALAPI
-PAL_GetTimeZoneInformation(
- IN int year,
- OUT LPTIME_ZONE_INFORMATION lpTimeZoneInformation);
-
#define LCID_INSTALLED 0x00000001 // installed locale ids
#define LCID_SUPPORTED 0x00000002 // supported locale ids
#ifdef __APPLE__
#cmakedefine01 HAVE_PRWATCH_T
#cmakedefine SIZEOF_OFF_T @SIZEOF_OFF_T@
-#cmakedefine01 HAVE_TZNAME
-#cmakedefine01 HAVE_TIMEZONE_VAR
#cmakedefine01 HAVE_YIELD_SYSCALL
#cmakedefine01 HAVE_INFTIM
#cmakedefine01 HAVE_CHAR_BIT
set(CMAKE_EXTRA_INCLUDE_FILE)
check_type_size(off_t SIZEOF_OFF_T)
-check_cxx_symbol_exists(tzname "time.h" HAVE_TZNAME)
-check_cxx_symbol_exists(timezone "time.h" HAVE_TIMEZONE_VAR)
check_cxx_symbol_exists(SYS_yield sys/syscall.h HAVE_YIELD_SYSCALL)
check_cxx_symbol_exists(INFTIM poll.h HAVE_INFTIM)
check_cxx_symbol_exists(CHAR_BIT sys/limits.h HAVE_CHAR_BIT)
{
InternalInitializeCriticalSection(&gcsEnvironment);
MiscGetEnvArray();
-#if HAVE_TIMEZONE_VAR
- tzset();
-#endif // HAVE_TIMEZONE_VAR
return TRUE;
}
static const __int64 SECS_BETWEEN_1601_AND_2001_EPOCHS = 12622780800LL;
#endif // __APPLE__
-/* to be used as args to FILEAdjustFileTimeForTimezone */
-#define ADJUST_FROM_UTC -1
-#define ADJUST_TO_UTC 1
-
-static FILETIME FILEAdjustFileTimeForTimezone( const FILETIME *Orig,
- int Direction );
-
-
/*++
Function:
CompareFileTime
-/*++
-Function:
- FileTimeToLocalTime
-
-See MSDN doc.
---*/
-BOOL
-PALAPI
-FileTimeToLocalFileTime(
- IN CONST FILETIME *lpFileTime,
- OUT LPFILETIME lpLocalFileTime)
-{
- PERF_ENTRY(FileTimeToLocalFileTime);
- ENTRY("FileTimeToLocalFileTime(lpFileTime=%p, lpLocalFileTime=%p)\n",
- lpFileTime, lpLocalFileTime);
-
- *lpLocalFileTime = FILEAdjustFileTimeForTimezone(lpFileTime,
- ADJUST_FROM_UTC);
- LOGEXIT("FileTimeToLocalFileTime returns BOOL TRUE\n");
- PERF_EXIT(FileTimeToLocalFileTime);
- return TRUE;
-}
-
-
-/*++
-Function:
- LocalTimeToFileTime
-
---*/
-BOOL
-PALAPI
-LocalFileTimeToFileTime(
- IN CONST FILETIME *lpLocalFileTime,
- OUT LPFILETIME lpFileTime)
-{
- PERF_ENTRY(LocalFileTimeToFileTime);
- ENTRY("LocalFileTimeToFileTime(lpLocalFileTime=%p, lpFileTime=%p)\n",
- lpLocalFileTime, lpFileTime);
-
- *lpFileTime = FILEAdjustFileTimeForTimezone(lpLocalFileTime,
- ADJUST_TO_UTC);
- LOGEXIT("LocalFileTimeToFileTime returns BOOL TRUE\n");
- PERF_EXIT(LocalFileTimeToFileTime);
- return TRUE;
-}
}
-/*++
-Function:
- FILEAdjustFileTimeForTimezone
-
-Given a FILETIME, adjust it for the local time zone.
-Direction is ADJUST_FROM_UTC to go from UTC to localtime, and
-ADJUST_TO_UTC to go from localtime to UTC.
-
-The offset from UTC can be determined in one of two ways. On *BSD,
-struct tm contains a tm_gmtoff field which is a signed integer indicating
-the difference, in seconds, between local time and UTC at the supplied
-time. eg. in EST, tm_gmtoff is -18000. This value _will_ account for
-Daylight Savings Time, however that is of no concern since the time and
-date in question is 1 January.
-
-On SysV systems, there exists an external variable named timezone, which
-is similar to the tm_gmtoff field, but stores the seconds west of UTC.
-Thus for EST, timezone == 18000. This variable does not account for DST.
---*/
-static FILETIME FILEAdjustFileTimeForTimezone( const FILETIME *Orig,
- int Direction )
-{
- __int64 FullTime;
- __int64 Offset;
-
- FILETIME Ret;
-
- struct tm *tmTimePtr;
-#if HAVE_LOCALTIME_R
- struct tm tmTime;
-#endif /* HAVE_LOCALTIME_R */
- time_t timeNow;
-
- /* Use the current time and date to calculate UTC offset */
- timeNow = time(NULL);
-#if HAVE_LOCALTIME_R
- tmTimePtr = &tmTime;
- localtime_r( &timeNow, tmTimePtr );
-#else /* HAVE_LOCALTIME_R */
- tmTimePtr = localtime( &timeNow );
-#endif /* HAVE_LOCALTIME_R */
-
-#if HAVE_TM_GMTOFF
- Offset = -tmTimePtr->tm_gmtoff;
-#elif HAVE_TIMEZONE_VAR
- // Adjust timezone for DST to get the appropriate offset.
- Offset = timezone - (tmTimePtr->tm_isdst ? 3600 : 0);
-#else // !(HAVE_TM_GMTOFF || HAVE_TIMEZONE_VAR)
-
-#error Unable to determine timezone information
- Offset = 0; // Quiet the warning about Offset being used unitialized
-#endif
-
- TRACE("Calculated UTC offset to be %I64d seconds\n", Offset);
-
- FullTime = (((__int64)Orig->dwHighDateTime) << 32) +
- Orig->dwLowDateTime;
-
- FullTime += Offset * SECS_TO_100NS * Direction;
-
- Ret.dwLowDateTime = (DWORD)(FullTime);
- Ret.dwHighDateTime = (DWORD)(FullTime >> 32);
-
- return Ret;
-}
-
-
-/*++
-Function:
- DosDateTimeToFileTime
-
-See MSDN doc.
---*/
-BOOL PALAPI DosDateTimeToFileTime(
- IN WORD wFatDate,
- IN WORD wFatTime,
- OUT LPFILETIME lpFileTime
- )
-{
-
- BOOL bRet = FALSE;
- struct tm tmTime = { 0 };
- time_t tmUnix;
-
- PERF_ENTRY(DosDateTimeToFileTime);
- ENTRY("DosDateTimeToFileTime(wFatdate=%#hx,wFatTime=%#hx,lpFileTime=%p)\n",
- wFatDate,wFatTime,lpFileTime);
- /*Breakdown wFatDate & wfatTime to fill the tm structure */
- /*wFatDate contains the Date data & wFatTime time data*/
- /*wFatDate 0-4 bits-Day of month(0-31)*/
- /*5-8 Month(1=Jan,2=Feb)*/
- /*9-15 Year offset from 1980*/
- /*wFtime 0-4 Second divided by 2*/
- /*5-10 Minute(0-59)*/
- /*11-15 Hour 0-23 on a 24 hour clock*/
-
- tmTime.tm_mday = (wFatDate & 0x1F);
- if ( tmTime.tm_mday < 1 || tmTime.tm_mday > 31 )
- {
- ERROR( "Incorrect day format was passed in.\n" );
- SetLastError( ERROR_INVALID_PARAMETER );
- goto done;
- }
-
- /*tm_mon is the no. of months from january*/
- tmTime.tm_mon = ((wFatDate >> 5) & 0x0F)-1;
- if ( tmTime.tm_mon < 0 || tmTime.tm_mon > 11 )
- {
- ERROR( "Incorrect month format was passed in.\n" );
- SetLastError( ERROR_INVALID_PARAMETER );
- goto done;
- }
-
- /*tm_year is the no. of years from 1900*/
- tmTime.tm_year = ((wFatDate >> 9) & 0x7F) + 80;
- if ( tmTime.tm_year < 0 || tmTime.tm_year > 207 )
- {
- ERROR( "Incorrect year format was passed in. %d\n", tmTime.tm_year );
- SetLastError( ERROR_INVALID_PARAMETER );
- goto done;
- }
-
- tmTime.tm_sec = ( (wFatTime & 0x1F)*2 );
- if ( tmTime.tm_sec < 0 || tmTime.tm_sec > 59 )
- {
- ERROR( "Incorrect sec format was passed in.\n" );
- SetLastError( ERROR_INVALID_PARAMETER );
- goto done;
- }
-
- tmTime.tm_min = ((wFatTime >> 5) & 0x3F);
- if ( tmTime.tm_min < 0 || tmTime.tm_min > 59 )
- {
- ERROR( "Incorrect minute format was passed in.\n" );
- SetLastError( ERROR_INVALID_PARAMETER );
- goto done;
- }
-
- tmTime.tm_hour = ((wFatTime >> 11) & 0x1F);
- if ( tmTime.tm_hour < 0 || tmTime.tm_hour > 23 )
- {
- ERROR( "Incorrect hour format was passed in.\n" );
- SetLastError( ERROR_INVALID_PARAMETER );
- goto done;
- }
-
- // Get the time in seconds
-#if HAVE_TIMEGM
- tmUnix = timegm(&tmTime);
-#elif HAVE_TIMEZONE_VAR
- // Have the system try to determine if DST is being observed.
- tmTime.tm_isdst = -1;
-
- tmUnix = mktime(&tmTime);
- // mktime() doesn't take the time zone into account. Adjust it
- // by the time zone, but also consider DST to get the appropriate
- // offset.
- if (tmUnix > timezone - (tmTime.tm_isdst ? 3600 : 0))
- {
- tmUnix -= timezone - (tmTime.tm_isdst ? 3600 : 0);
- }
- else
- {
- ERROR( "Received a time before the epoch.\n" );
- SetLastError( ERROR_INVALID_PARAMETER );
- goto done;
- }
-#else
-#error Unable to calculate time offsets on this platform
- tmUnix = 0; // Avoid a compiler warning about tmUnix being uninitialized
-#endif
-
- /*check if the output buffer is valid*/
- if( lpFileTime )
- {
- *lpFileTime = FILEUnixTimeToFileTime( tmUnix, 0 );
- bRet = TRUE;
- }
-
-done:
- LOGEXIT("DosDateTimeToFileTime returns BOOl %d \n",bRet);
- PERF_EXIT(DosDateTimeToFileTime);
- return bRet;
-
-}
-
/**
Function
--*/
void MiscUnsetenv(const char *name);
-/*++
-Function:
- TIMECleanUpTransitionDates
-
-Free the memory allocated in TIMEGetStdDstDates.
---*/
-void TIMECleanUpTransitionDates();
-
#ifdef __cplusplus
}
#endif // __cplusplus
// MutexCleanup();
MiscCleanup();
- TIMECleanUpTransitionDates();
#if !HAVE_COREFOUNDATION
CODEPAGECleanup();
SET_DEFAULT_DEBUG_CHANNEL(MISC);
-typedef struct
-{
- struct tm dst_date;
- struct tm std_date;
-} TRANS_DATES;
-
-static TRANS_DATES *glob_trans_dates = NULL;
-
-static BOOL TIMEGetStdDstDates(int year, struct tm *dst_date, struct tm *std_date);
-static int TIMEGetWeekDayNumber(struct tm date);
-
/*++
Function:
GetSystemTime
PERF_EXIT(GetSystemTime);
}
-
-/*++
-Function:
- GetTimeZoneInformation
-
-The GetTimeZoneInformation function retrieves the current time-zone
-parameters. These parameters control the translations between
-Coordinated Universal Time (UTC) and local time.
-
-Parameters
-
-lpTimeZoneInformation
- [out] Pointer to a TIME_ZONE_INFORMATION structure to receive
- the current time-zone parameters.
-
-Return Values
-
-If the function succeeds, the return value is one of the following values:
-
-TIME_ZONE_ID_UNKNOWN
-TIME_ZONE_ID_STANDARD
-TIME_ZONE_ID_DAYLIGHT
-TIME_ZONE_ID_INVALID
-
---*/
-DWORD
-PALAPI
-PAL_GetTimeZoneInformation(
- IN int year,
- OUT LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
-{
-#if HAVE_TIMEZONE_VAR
- extern long int timezone;
-#endif // HAVE_TIMEZONE_VAR
- time_t tt;
- const char *tzStandardName;
- const char *tzDaylightName;
-#if HAVE_LOCALTIME_R
- struct tm ut;
-#endif /* HAVE_LOCALTIME_R */
- struct tm *utPtr;
- DWORD retval = TIME_ZONE_ID_INVALID;
- struct tm dst_date, std_date;
- struct tm local_date;
-
- PERF_ENTRY(GetTimeZoneInformation);
- ENTRY("PAL_GetTimeZoneInformation (year=%d, lpTimeZoneInformation=%p)\n",
- year, lpTimeZoneInformation);
-
-
- memset(&local_date, 0, sizeof(struct tm));
- local_date.tm_year = year-1900;
- local_date.tm_mday = 1;
-
- if (-1 == (tt = mktime(&local_date)))
- {
- ERROR("mktime() failed.\n");
- return FALSE;
- }
-
-#if HAVE_LOCALTIME_R
- utPtr = &ut;
- localtime_r(&tt,&ut);
-#else /* HAVE_LOCALTIME_R */
- utPtr = localtime(&tt);
-#endif /* HAVE_LOCALTIME_R */
-
-#if HAVE_TZNAME
- tzStandardName = tzname[0];
- tzDaylightName = tzname[1];
-#else /* HAVE_TZNAME */
- tzStandardName = utPtr->tm_zone;
- tzDaylightName = "";
-#endif /* HAVE_TZNAME */
- TRACE("standard timezone name = %s\n", tzStandardName);
- TRACE("daylight timezone name = %s\n", tzDaylightName);
-#if HAVE_TM_GMTOFF
- TRACE("timezone offset = %ld\n", utPtr->tm_gmtoff / 60);
-#else
- TRACE("timezone offset = %ld\n", (-timezone + (utPtr->tm_isdst ? 3600 : 0)) / 60);
-#endif
- TRACE("daylight savings = %d\n", utPtr->tm_isdst);
-
-#if HAVE_TM_GMTOFF
- lpTimeZoneInformation->Bias = -utPtr->tm_gmtoff / 60;
-#else
- lpTimeZoneInformation->Bias = (timezone - (utPtr->tm_isdst ? 3600 : 0)) / 60;
-#endif
-
- /* This may be wrong for some obscure time zones. */
- lpTimeZoneInformation->StandardBias = 0;
- lpTimeZoneInformation->DaylightBias = -60;
-
- if (MultiByteToWideChar(CP_ACP, 0, tzStandardName, -1,
- lpTimeZoneInformation->StandardName, 32) == 0)
- {
- ASSERT("failed to convert multibytes to wide chars\n");
- goto EXIT;
- }
-
- if (MultiByteToWideChar(CP_ACP, 0, tzDaylightName, -1,
- lpTimeZoneInformation->DaylightName, 32) == 0)
- {
- ASSERT("failed to convert multibytes to wide chars\n");
- goto EXIT;
- }
-
- memset(&lpTimeZoneInformation->StandardDate, 0, sizeof(SYSTEMTIME));
- memset(&lpTimeZoneInformation->DaylightDate, 0, sizeof(SYSTEMTIME));
-
- if (utPtr->tm_isdst >= 0)
- {
- if (!TIMEGetStdDstDates(year, &dst_date, &std_date))
- {
- goto EXIT;
- }
-
- if ((dst_date.tm_mon == 0) || (std_date.tm_mon == 0))
- {
- retval = TIME_ZONE_ID_STANDARD;
- goto EXIT;
- }
-
- TRACE("Transition to Standard date: %s\n", asctime(&dst_date));
- TRACE("Transition to Daylight date: %s\n", asctime(&std_date));
-
- lpTimeZoneInformation->StandardDate.wDay = TIMEGetWeekDayNumber(std_date);
- lpTimeZoneInformation->DaylightDate.wDay = TIMEGetWeekDayNumber(dst_date);
-
- if(!lpTimeZoneInformation->StandardDate.wDay ||
- !lpTimeZoneInformation->DaylightDate.wDay)
- {
- goto EXIT;
- }
-
- lpTimeZoneInformation->StandardDate.wMonth = std_date.tm_mon + 1;
- lpTimeZoneInformation->DaylightDate.wMonth = dst_date.tm_mon + 1;
- lpTimeZoneInformation->StandardDate.wDayOfWeek = std_date.tm_wday;
- lpTimeZoneInformation->DaylightDate.wDayOfWeek = dst_date.tm_wday;
- lpTimeZoneInformation->StandardDate.wHour = (std_date.tm_hour + 1) % 24;
- lpTimeZoneInformation->DaylightDate.wHour = (dst_date.tm_hour + 1) % 24;
-
- TRACE("StandardDate: mon:%d dofweek:%d hour:%d wday:%d\n",
- lpTimeZoneInformation->StandardDate.wMonth,
- lpTimeZoneInformation->StandardDate.wDayOfWeek,
- lpTimeZoneInformation->StandardDate.wHour,
- lpTimeZoneInformation->StandardDate.wDay);
-
- TRACE("DaylightDate: mon:%d dofweek:%d hour:%d wday:%d\n",
- lpTimeZoneInformation->DaylightDate.wMonth,
- lpTimeZoneInformation->DaylightDate.wDayOfWeek,
- lpTimeZoneInformation->DaylightDate.wHour,
- lpTimeZoneInformation->DaylightDate.wDay);
-
- if (utPtr->tm_isdst)
- {
- lpTimeZoneInformation->Bias -= lpTimeZoneInformation->DaylightBias;
- retval = TIME_ZONE_ID_DAYLIGHT;
- }
- else
- {
- lpTimeZoneInformation->Bias -= lpTimeZoneInformation->StandardBias;
- retval = TIME_ZONE_ID_STANDARD;
- }
- }
- else
- {
- retval = TIME_ZONE_ID_UNKNOWN;
- }
-
-EXIT:
- LOGEXIT("PAL_GetTimeZoneInformation returns DWORD %u\n", retval);
- PERF_EXIT(GetTimeZoneInformation);
- return retval;
-}
-
-
-DWORD
-PALAPI
-GetTimeZoneInformation(
- OUT LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
-{
- time_t tt;
-#if HAVE_LOCALTIME_R
- struct tm ut;
-#endif /* HAVE_LOCALTIME_R */
- struct tm *utPtr;
-
- tt = time(NULL);
-#if HAVE_LOCALTIME_R
- utPtr = &ut;
- localtime_r(&tt,&ut);
-#else /* HAVE_LOCALTIME_R */
- utPtr = localtime(&tt);
-#endif /* HAVE_LOCALTIME_R */
-
- return PAL_GetTimeZoneInformation (utPtr->tm_year + 1900,lpTimeZoneInformation);
-}
-
/*++
Function:
GetTickCount
return retval;
}
-/*++
-Function:
- TIMEGetWeekDayNumber
-
-calculate the week day number of the indicated date. for example, if the week day
-is Sunday, this function will returns 1 if it's the first Sunday of the month,
-2 if it's the second, etc. and 5 if it's the last Sunday on the month.
-
-Parameters
-date_param: the date for which we are going to calculate the week day order.
-
-Return Values
-
-returns the week day number (range 1-5), 0 if it fails.
---*/
-int TIMEGetWeekDayNumber(struct tm date_param)
-{
- time_t date_t;
- struct tm date = date_param;
- struct tm *datePtr;
- int month = date.tm_mon;
-
- /* first, check if it's the last week-day of the month */
- date.tm_mday += 7;
- date_t = mktime(&date);
-#if HAVE_LOCALTIME_R
- datePtr = &date;
- if (NULL == localtime_r(&date_t, &date))
-#else /* HAVE_LOCALTIME_R */
- if (NULL == (datePtr = localtime(&date_t)))
-#endif /* HAVE_LOCALTIME_R */
- {
- ERROR("localtime() failed.\n");
- return 0;
- }
-
- if (datePtr->tm_mon != month)
- {
- return 5;
- }
-
- return (date_param.tm_mday + 6) / 7;
-}
-
-/*++
-Function:
- TIMEGetStdDstDates
-
-retrieve the two dates preceding the two transition dates:
- 1- from standard date to daylight date
- 2- from daylight date to standard date
-
-if daylight/standard date doesn't apply for the current zone, then tm_mon of
-dst_date and std_date parameters will be set to 0.
-
-Parameters
- dst_date: return transition date from standard date to daylight date
- std_date: return transition date from daylight date to standard date
-
-Return Values
- FALSE, if it fails, TRUE, otherwise.
---*/
-BOOL TIMEGetStdDstDates(int year, struct tm *dst_date, struct tm *std_date)
-{
- const int sec_per_year = 31536000; /* 365x24x60x60 */
-
- int dayLightActive;
- /* the POSIX time_t type is opaque; to be portable, we should assume
- nothing about its representation. */
- time_t date_LO;
- time_t date_MID;
- time_t date_HI;
- time_t date_HI_Copy;
- struct tm local_date;
- struct tm date_MID_tm;
-#if HAVE_LOCALTIME_R
- struct tm tmp_tm;
-#endif /* HAVE_LOCALTIME_R */
- struct tm *dateMIDPtr;
- struct tm *tmpPtr;
-
- TRANS_DATES tmp_transd, *lptmp_transd;
- memset(&tmp_transd, 0, sizeof(tmp_transd));
-
- /* initialize date_LO to the first date of the current year, and date_HI to
- the last date */
-
- if( (glob_trans_dates) &&
- (glob_trans_dates->dst_date.tm_year == year - 1900))
- {
- /* tansition dates already calculated */
- TRACE("Tansition dates already calculated\n");
- *dst_date = glob_trans_dates->dst_date;
- *std_date = glob_trans_dates->std_date;
- return TRUE;
- }
-
- memset(&local_date, 0, sizeof(struct tm));
- local_date.tm_year = year - 1900;
- local_date.tm_mday = 1;
-
- if (-1 == (date_LO = mktime(&local_date)))
- {
- ERROR("mktime() failed.\n");
- return FALSE;
- }
-
- date_HI_Copy = date_HI = date_LO + sec_per_year;
-
- /* get the initial daylight status */
-#if HAVE_LOCALTIME_R
- tmpPtr = &tmp_tm;
- if (NULL == localtime_r(&date_LO, &tmp_tm))
-#else /* HAVE_LOCALTIME_R */
- if (NULL == (tmpPtr = localtime(&date_LO)))
-#endif /* HAVE_LOCALTIME_R */
- {
- ERROR("localtime_r() failed.\n");
- return FALSE;
- }
-
- dayLightActive = tmpPtr->tm_isdst;
-
- /* retrieve the date before the first transition to/from daylight/standard
- date happens */
- do
- {
- date_MID = date_LO + difftime (date_HI, date_LO) / 2.0;
-
-#if HAVE_LOCALTIME_R
- dateMIDPtr = &date_MID_tm;
- if (NULL == localtime_r(&date_MID, &date_MID_tm))
-#else /* HAVE_LOCALTIME_R */
- if (NULL == (dateMIDPtr = localtime(&date_MID)))
-#endif /* HAVE_LOCALTIME_R */
- {
- ERROR("localtime_r() failed.\n");
- return FALSE;
- }
-
- if(dateMIDPtr->tm_isdst != dayLightActive)
- {
- date_HI = date_MID - 1;
- }
- else
- {
- date_LO = date_MID + 1;
- }
- }
- while (!(difftime (date_LO, date_HI) > 0)); // date_LO <= date_HI
-
- if(dateMIDPtr->tm_isdst != dayLightActive)
- {
- /* passed the transition date, move back by one second */
- dateMIDPtr->tm_sec--;
- date_MID = mktime(dateMIDPtr);
-#if HAVE_LOCALTIME_R
- localtime_r(&date_MID, dateMIDPtr);
-#else /* HAVE_LOCALTIME_R */
- dateMIDPtr = localtime(&date_MID);
-#endif /* HAVE_LOCALTIME_R */
- }
-
- if (date_HI_Copy == date_MID)
- {
- /* no daylight/standard date for the current zone */
- memset(dst_date, 0, sizeof(*dst_date));
- memset(std_date, 0, sizeof(*std_date));
- return TRUE;
- }
-
- if (dayLightActive == 0)
- {
- tmp_transd.dst_date = *dateMIDPtr;
- dayLightActive = 1;
- }
- else
- {
- tmp_transd.std_date = *dateMIDPtr;
- dayLightActive = 0;
- }
-
- /* retrieve the date before the second transition to/from daylight/standard
- date happens */
- date_HI = date_HI_Copy;
- date_MID_tm.tm_sec++;
- date_LO = mktime(dateMIDPtr);
-
- do
- {
- date_MID = date_LO + difftime (date_HI, date_LO) / 2.0;
-
-#if HAVE_LOCALTIME_R
- dateMIDPtr = &date_MID_tm;
- if (NULL == localtime_r(&date_MID, dateMIDPtr))
-#else /* HAVE_LOCALTIME_R */
- if (NULL == (dateMIDPtr = localtime(&date_MID)))
-#endif /* HAVE_LOCALTIME_R */
- {
- ERROR("localtime() failed.\n");
- return FALSE;
- }
-
- if(dateMIDPtr->tm_isdst != dayLightActive)
- {
- date_HI = date_MID - 1;
- }
- else
- {
- date_LO = date_MID + 1;
- }
- }
- while (!(difftime (date_LO, date_HI) > 0)); // date_LO <= date_HI
-
- if(dateMIDPtr->tm_isdst != dayLightActive)
- {
- /* passed the transition date, move back by one second */
- date_MID_tm.tm_sec--;
- date_MID = mktime(dateMIDPtr);
-#if HAVE_LOCALTIME_R
- dateMIDPtr = &date_MID_tm;
- localtime_r(&date_MID, dateMIDPtr);
-#else /* HAVE_LOCALTIME_R */
- dateMIDPtr = localtime(&date_MID);
-#endif /* HAVE_LOCALTIME_R */
- }
-
- if (dayLightActive == 0)
- {
- tmp_transd.dst_date = *dateMIDPtr;
- }
- else
- {
- tmp_transd.std_date = *dateMIDPtr;
- }
-
- if(glob_trans_dates == NULL)
- {
- if((lptmp_transd = (TRANS_DATES*)PAL_malloc(sizeof(TRANS_DATES))) == NULL)
- {
- ERROR("can't allocate memory for global transition dates\n");
- return FALSE;
- }
-
- *lptmp_transd = tmp_transd;
-
- if(NULL != InterlockedCompareExchangePointer(&glob_trans_dates, lptmp_transd, NULL))
- {
- /* another thread got in before us! */
- WARN("Another thread initialized global trans dates\n");
- PAL_free(lptmp_transd);
- }
- }
- else
- {
- *glob_trans_dates = tmp_transd;
- }
-
- *dst_date = glob_trans_dates->dst_date;
- *std_date = glob_trans_dates->std_date;
-
- return TRUE;
-}
-
BOOL
PALAPI
QueryPerformanceCounter(
return FALSE;
}
-/*++
-Function:
- TIMECleanUpTransitionDates
-
-Free the memory allocated in TIMEGetStdDstDates.
---*/
-void TIMECleanUpTransitionDates()
-{
- if (glob_trans_dates)
- {
- PAL_free(glob_trans_dates);
- glob_trans_dates = 0;
- }
-}
-
/*++
Function:
add_subdirectory(CreateFileW)
add_subdirectory(DeleteFileA)
add_subdirectory(DeleteFileW)
-add_subdirectory(DosDateTimeToFileTime)
add_subdirectory(errorpathnotfound)
add_subdirectory(FileTimeToDosDateTime)
-add_subdirectory(FileTimeToLocalFileTime)
add_subdirectory(FindClose)
add_subdirectory(FindFirstFileA)
add_subdirectory(FindFirstFileW)
add_subdirectory(GetTempFileNameW)
add_subdirectory(gettemppatha)
add_subdirectory(GetTempPathW)
-add_subdirectory(LocalFileTimeToFileTime)
add_subdirectory(MoveFileA)
add_subdirectory(MoveFileExA)
add_subdirectory(MoveFileExW)
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-add_subdirectory(test1)
-add_subdirectory(test2)
-add_subdirectory(test3)
-add_subdirectory(test4)
-
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test1.c
-)
-
-add_executable(paltest_dosdatetimetofiletime_test1
- ${SOURCES}
-)
-
-add_dependencies(paltest_dosdatetimetofiletime_test1 CoreClrPal)
-
-target_link_libraries(paltest_dosdatetimetofiletime_test1
- pthread
- m
- CoreClrPal
-)
+++ /dev/null
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-/*=====================================================================
-**
-** Source: test1.c
-**
-** Purpose: Convert two valid DOS times to FileTimes. Then check that
-** the FileTimes are the same distance apart as the DOS times were.
-**
-**
-**===================================================================*/
-
-#include <palsuite.h>
-
-int __cdecl main(int argc, char **argv)
-{
-
- WORD DosDate = 0x14CF; /* Dec 15th, 2000 */
- WORD DosTime = 0x55AF; /* 10:45:30 */
- WORD SecondDosTime = 0x55B0; /* 10:45:32 */
-
- FILETIME FirstResultTime;
- FILETIME SecondResultTime;
-
- ULONG64 FullFirstTime;
- ULONG64 FullSecondTime;
-
- if (0 != PAL_Initialize(argc,argv))
- {
- return FAIL;
- }
-
- /* Convert two DosDateTimes to FileTimes, ensure that each call returns
- non-zero
- */
- if(DosDateTimeToFileTime(DosDate, DosTime, &FirstResultTime) == 0)
- {
- Fail("ERROR: DosTimeToFileTime should have returned non-0 to indicate "
- "success. GetLastError() returned %d.",GetLastError());
- }
-
- if(DosDateTimeToFileTime(DosDate, SecondDosTime, &SecondResultTime) == 0)
- {
- Fail("ERROR: DosTimeToFileTime should have returned non-0 to indicate "
- "success. GetLastError() returned %d.",GetLastError());
- }
-
- /* Move the FILETIME structures into a ULONG value which we can
- work with
- */
- FullFirstTime = ((((ULONG64)FirstResultTime.dwHighDateTime)<<32) |
- ((ULONG64)FirstResultTime.dwLowDateTime));
-
- FullSecondTime = ((((ULONG64)SecondResultTime.dwHighDateTime)<<32) |
- ((ULONG64)SecondResultTime.dwLowDateTime));
-
- /* Check to see that these two times are two seconds apart, just like
- those that were converted.
- */
- if((FullSecondTime-FullFirstTime) != 20000000)
- {
- Fail("ERROR: Two times were converted which were two seconds "
- "apart. When convert to a FileTime they should have been "
- "20000000 nano-seconds apart, but instead were %d seconds "
- "apart.",FullSecondTime-FullFirstTime);
- }
-
- PAL_Terminate();
- return PASS;
-}
-
+++ /dev/null
-#
-# Copyright (c) Microsoft Corporation. All rights reserved.
-#
-
-Version = 1.0
-Section = file_io
-Function = DosDateTimeToFileTime
-Name = Positive Test for DosDateTimeToFileTime checking normal behaviour
-TYPE = DEFAULT
-EXE1 = test1
-Description
-= Convert two valid DOS times to FileTimes. Then check that
-= the FileTimes are the same distance apart as the DOS times were.
-
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test2.c
-)
-
-add_executable(paltest_dosdatetimetofiletime_test2
- ${SOURCES}
-)
-
-add_dependencies(paltest_dosdatetimetofiletime_test2 CoreClrPal)
-
-target_link_libraries(paltest_dosdatetimetofiletime_test2
- pthread
- m
- CoreClrPal
-)
+++ /dev/null
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-/*=====================================================================
-**
-** Source: test2.c
-**
-** Purpose: Ensure that DosDateTimeToFileTime fails when passed invalid
-** dos dates and times.
-**
-**
-**===================================================================*/
-
-/* Note: Passing a NULL FILETIME causes the function to fault.
- Also -- you can't create an invalid 'year' in the date.
-*/
-
-#include <palsuite.h>
-
-int DoInvalidTest(WORD TheDate, WORD TheTime, char* DateOrTime, char* Wrong)
-{
- FILETIME ResultTime;
-
- if(DosDateTimeToFileTime(TheDate, TheTime, &ResultTime) != 0)
- {
- Trace("ERROR: DosTimeToFileTime should have failed when passed a "
- "%s with invalid %s.\n", DateOrTime, Wrong);
- return 1;
- }
-
- if(GetLastError() != ERROR_INVALID_PARAMETER)
- {
- Trace("ERROR: GetLastError should have returned "
- "ERROR_INVALID_PARAMETER but it returned %d.\n",GetLastError());
- return 1;
- }
-
- return 0;
-
-}
-
-int __cdecl main(int argc, char **argv)
-{
-
- WORD DosDate = 0x14CF; /* Dec 15th, 2000 */
- WORD InvalidMonthDosDate = 0x29EF; /* 15th Month, 15th Day, 2000 */
- WORD InvalidDayDosDate = 0x2820; /* Jan 0th, 2000 */
-
- WORD DosTime = 0x55AF; /* 10:45:30 */
- WORD InvalidSecondDosTime = 0x55BF; /* 10:45:62 */
- WORD InvalidMinuteDosTime = 0xF81; /* 1:60:02 */
- WORD InvalidHourDosTime = 0xC021; /* 24:01:02 */
-
- if (0 != PAL_Initialize(argc,argv))
- {
- return FAIL;
- }
-
- if(
- DoInvalidTest(DosDate, InvalidSecondDosTime, "time", "seconds") ||
- DoInvalidTest(DosDate, InvalidMinuteDosTime, "time", "minutes") ||
- DoInvalidTest(DosDate, InvalidHourDosTime, "time", "hours") ||
- DoInvalidTest(InvalidMonthDosDate, DosTime, "date", "month") ||
- DoInvalidTest(InvalidDayDosDate, DosTime, "date", "day"))
- {
- Fail("");
- }
-
- PAL_Terminate();
- return PASS;
-}
-
+++ /dev/null
-#
-# Copyright (c) Microsoft Corporation. All rights reserved.
-#
-
-Version = 1.0
-Section = file_io
-Function = DosDateTimeToFileTime
-Name = DosDateTimeToFileTime checking failure for incorrect values
-TYPE = DEFAULT
-EXE1 = test2
-Description
-= Ensure that DosDateTimeToFileTime fails when passed invalid
-= dos dates and times.
-
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test3.c
-)
-
-add_executable(paltest_dosdatetimetofiletime_test3
- ${SOURCES}
-)
-
-add_dependencies(paltest_dosdatetimetofiletime_test3 CoreClrPal)
-
-target_link_libraries(paltest_dosdatetimetofiletime_test3
- pthread
- m
- CoreClrPal
-)
+++ /dev/null
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-/*=====================================================================
-**
-** Source: test3.c
-**
-** Purpose: Check the upper and lower bounds of dates and times.
-**
-**
-**===================================================================*/
-
-#include <palsuite.h>
-
-int __cdecl main(int argc, char **argv)
-{
- WORD UpperDosDate = 0x739F; /* Dec 31st, 2037 */
- WORD LowerDosDate = 0x21; /* Jan, 1st, 1980 */
- WORD UpperDosTime = 0xBF7D; /* 23:59:58 */
- WORD LowerDosTime = 0x0; /* 0:00:00 */
-
- FILETIME ResultTime;
-
- if (0 != PAL_Initialize(argc,argv))
- {
- return FAIL;
- }
-
- /*
- Convert a DosDateTime using the highest possible date and time.
- */
- if(DosDateTimeToFileTime(UpperDosDate, UpperDosTime, &ResultTime) == 0)
- {
- Fail("ERROR: DosDateTimeToFileTime failed when attempting to "
- "convert the highest possible date and time. GetLastError() "
- "returned %d.\n",GetLastError());
- }
-
- /*
- Convert a DosDateTime using the lowest possible date and time.
- */
- if(DosDateTimeToFileTime(LowerDosDate, LowerDosTime, &ResultTime) == 0)
- {
- Fail("ERROR: DosDateTimeToFileTime failed when attempting to "
- "convert the lowest possible date and time. GetLastError() "
- "returned %d.\n",GetLastError());
- }
-
-
- PAL_Terminate();
- return PASS;
-}
-
+++ /dev/null
-#
-# Copyright (c) Microsoft Corporation. All rights reserved.
-#
-
-Version = 1.0
-Section = file_io
-Function = DosDateTimeToFileTime
-Name = DosDateTimeToFileTime checking upper and lower date/time bounds
-TYPE = DEFAULT
-EXE1 = test3
-Description
-= Check the upper and lower bounds of dates and times.
-
-
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test4.c
-)
-
-add_executable(paltest_dosdatetimetofiletime_test4
- ${SOURCES}
-)
-
-add_dependencies(paltest_dosdatetimetofiletime_test4 CoreClrPal)
-
-target_link_libraries(paltest_dosdatetimetofiletime_test4
- pthread
- m
- CoreClrPal
-)
+++ /dev/null
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-/*=====================================================================
-**
-** Source: test4.c
-**
-** Purpose: Create a DOS time near 1980 and one near the current date.
-** Convert these two a FILETIME and then compare the values to ensure they're
-** correct -- this should test days, years, leap years etc.
-**
-**
-**===================================================================*/
-
-#include <palsuite.h>
-
-int __cdecl main(int argc, char **argv)
-{
- WORD EarlyDosDate = 0x21; /* Jan, 1st, 1980 */
- WORD RecentDosDate = 0x14CF; /* Dec 15th, 2000 */
- WORD DosTime = 0x55AF; /* 10:45:30 */
- WORD SecondDosTime = 0xBF7D; /* 23:59:58 */
-
- FILETIME FirstResultTime;
- FILETIME SecondResultTime;
-
- ULONG64 FullFirstTime;
- ULONG64 FullSecondTime;
-
- if (0 != PAL_Initialize(argc,argv))
- {
- return FAIL;
- }
-
- /* Convert two DosDateTimes to FileTimes, ensure that each call returns
- non-zero
- */
- if(DosDateTimeToFileTime(EarlyDosDate, DosTime, &FirstResultTime) == 0)
- {
- Fail("ERROR: DosTimeToFileTime should have returned non-0 to indicate "
- "success. GetLastError() returned %d.",GetLastError());
- }
-
- if(DosDateTimeToFileTime(RecentDosDate,
- SecondDosTime, &SecondResultTime) == 0)
- {
- Fail("ERROR: DosTimeToFileTime should have returned non-0 to indicate "
- "success. GetLastError() returned %d.",GetLastError());
- }
-
- /* Move the FILETIME structures into a ULONG value which we can
- work with
- */
- FullFirstTime = ((((ULONG64)FirstResultTime.dwHighDateTime)<<32) |
- ((ULONG64)FirstResultTime.dwLowDateTime));
-
- FullSecondTime = ((((ULONG64)SecondResultTime.dwHighDateTime)<<32) |
- ((ULONG64)SecondResultTime.dwLowDateTime));
-
- /*
- The magic number below was calculated under win32 and is assumed
- to be correct. That's the value between the two dates above.
- Check to ensure this is always true.
- */
-
- if((FullSecondTime-FullFirstTime) != UI64(3299228680000000))
- {
- Fail("ERROR: The two dates should have been "
- "3299228680000000 nanseconds apart, but the result "
- "returned was %I64d.\n",FullSecondTime-FullFirstTime);
- }
-
- PAL_Terminate();
- return PASS;
-}
-
+++ /dev/null
-#
-# Copyright (c) Microsoft Corporation. All rights reserved.
-#
-
-Version = 1.0
-Section = file_io
-Function = DosDateTimeToFileTime
-Name = Positive Test for DosDateTimeToFileTime checking normal behaviour
-TYPE = DEFAULT
-EXE1 = test4
-Description
-= Create a DOS time near 1980 and one near the current date.
-= Convert these two a FILETIME and then compare the values to ensure they're
-= correct -- this should test days, years, leap years etc.
-
-
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-add_subdirectory(test1)
-
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- FileTimeToLocalFileTime.c
-)
-
-add_executable(paltest_filetimetolocalfiletime_test1
- ${SOURCES}
-)
-
-add_dependencies(paltest_filetimetolocalfiletime_test1 CoreClrPal)
-
-target_link_libraries(paltest_filetimetolocalfiletime_test1
- pthread
- m
- CoreClrPal
-)
+++ /dev/null
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-/*=====================================================================
-**
-** Source: FileTimeToLocalFileTime.c
-**
-** Purpose: Tests the PAL implementation of the FileTimeToLocalFileTime
-** This test converts a FILETIME to LOCALTIME, and after finding the correct
-** delta based on the timezone, it ensures that the difference between
-** FILETIME and LOCALTIME is correct.
-**
-** Depends
-** GetTimeZoneInformation
-**
-**
-**===================================================================*/
-
-#include <palsuite.h>
-
-
-
-int __cdecl main(int argc, char **argv)
-{
-
- FILETIME UTCTime, LocalTime;
- ULONG64 FullFileTime, FullLocalTime, CorrectTime;
- TIME_ZONE_INFORMATION ZoneInfo;
- int DeltaBetweenLocalAndUTC;
- int result;
-
- if (0 != PAL_Initialize(argc,argv))
- {
- return FAIL;
- }
-
- /* This is a valid UTC file time generated with GetFileTime */
- UTCTime.dwLowDateTime = 1867954880;
- UTCTime.dwHighDateTime = 29437095;
-
- /* Call the function */
- result = FileTimeToLocalFileTime(&UTCTime,&LocalTime);
-
- if(result == 0)
- {
- Fail("ERROR: FileTimeToLocalTime has returned zero, which "
- "indicates that it failed.");
- }
-
- /* We need to get the time zone that the user is running in. */
- result = GetTimeZoneInformation(&ZoneInfo);
-
- /* Use the Time Zone Information to construct the delta between UTC
- and local time -- in hours.
- */
-
- if(result == TIME_ZONE_ID_STANDARD)
- {
- DeltaBetweenLocalAndUTC =
- (ZoneInfo.Bias + ZoneInfo.StandardBias);
- }
- else if (result == TIME_ZONE_ID_DAYLIGHT)
- {
- DeltaBetweenLocalAndUTC =
- (ZoneInfo.Bias + ZoneInfo.DaylightBias);
- }
- else
- {
- DeltaBetweenLocalAndUTC = (ZoneInfo.Bias);
- }
-
- /* Change the UTC and Local FILETIME structures into ULONG64
- types
- */
-
- FullFileTime = ((((ULONG64)UTCTime.dwHighDateTime)<<32) |
- ((ULONG64)UTCTime.dwLowDateTime));
-
- FullLocalTime = ((((ULONG64)LocalTime.dwHighDateTime)<<32) |
- ((ULONG64)LocalTime.dwLowDateTime));
-
- /* This magic number is 10000000 * 60 * 60 -- which is the
- number of 100s of Nanseconds in a second, multiplied by the number
- of seconds in a minute, multiplied by the number of minutes in an
- hour.
-
- The correct time is the delta in hundreds of nanoseconds between
- Local and UTC times.
- */
-
- CorrectTime = 600000000 * ((ULONG64)DeltaBetweenLocalAndUTC);
-
- /* Now check to ensure that the difference between the Local and UTC
- times that was calculated with the function equals what it should be.
- */
- if((FullFileTime - FullLocalTime) != CorrectTime)
- {
- Fail("ERROR: The LocalFileTime that was returned is not equal to "
- "what the LocalFileTime should have been.");
- }
-
- PAL_Terminate();
- return PASS;
-}
-
+++ /dev/null
-#
-# Copyright (c) Microsoft Corporation. All rights reserved.
-#
-
-Version = 1.0
-Section = file_io
-Function = FileTimeToLocalFileTime
-Name = Positive Test for FileTimeToLocalFileTime
-TYPE = DEFAULT
-EXE1 = filetimetolocalfiletime
-Description
-= Test the FileTimeToLocalFileTime function.
-= This test converts a FILETIME to LOCALTIME, and after finding the correct
-= delta based on the timezone, it ensures that the difference between
-= FILETIME and LOCALTIME is correct.
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-add_subdirectory(test1)
-add_subdirectory(test2)
-
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- LocalFileTimeToFileTime.c
-)
-
-add_executable(paltest_localfiletimetofiletime_test1
- ${SOURCES}
-)
-
-add_dependencies(paltest_localfiletimetofiletime_test1 CoreClrPal)
-
-target_link_libraries(paltest_localfiletimetofiletime_test1
- pthread
- m
- CoreClrPal
-)
+++ /dev/null
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-/*=====================================================================
-**
-** Source: LocalFileTimeToFileTime.c
-**
-** Purpose: Tests the PAL implementation of the LocalFileTimeToFileTime
-** Check that the difference between the two times is correct based on the
-** current timezone.
-** Depends
-** GetTimeZoneInformation
-**
-**
-**===================================================================*/
-
-#include <palsuite.h>
-
-
-int __cdecl main(int argc, char **argv)
-{
-
- FILETIME UTCTime, LocalTime;
- ULONG64 FullFileTime, FullLocalTime, CorrectDeltaBetweenLocalAndUTC;
- TIME_ZONE_INFORMATION ZoneInfo;
- int DeltaBetweenLocalAndUTC;
- int result;
-
- if (0 != PAL_Initialize(argc,argv))
- {
- return FAIL;
- }
-
- /* This is a valid Local file time */
- LocalTime.dwLowDateTime = -398124352;
- LocalTime.dwHighDateTime = 29437061;
-
- /* Call the function */
- result = LocalFileTimeToFileTime(&LocalTime,&UTCTime);
-
- if(result == 0)
- {
- Fail("ERROR: LocalFileTimeToFileTime has returned zero, which "
- "indicates that it failed.");
- }
-
- /* We need to get the time zone that the user is running in. */
- result = GetTimeZoneInformation(&ZoneInfo);
-
-/* Use the Time Zone Information to construct the delta between UTC
- and local time -- in hours.
-*/
-
- if(result == TIME_ZONE_ID_STANDARD)
- {
- DeltaBetweenLocalAndUTC =
- (ZoneInfo.Bias + ZoneInfo.StandardBias);
- }
- else if (result == TIME_ZONE_ID_DAYLIGHT)
- {
- DeltaBetweenLocalAndUTC =
- (ZoneInfo.Bias + ZoneInfo.DaylightBias);
- }
- else
- {
- DeltaBetweenLocalAndUTC = (ZoneInfo.Bias);
- }
-
-
-
- /* Change the UTC and Local FILETIME structures into ULONG64
- types
- */
-
- FullFileTime = ((((ULONG64)UTCTime.dwHighDateTime)<<32) |
- ((ULONG64)UTCTime.dwLowDateTime));
-
- FullLocalTime = ((((ULONG64)LocalTime.dwHighDateTime)<<32) |
- ((ULONG64)LocalTime.dwLowDateTime));
-
- /* This magic number is 10000000 * 60 -- which is the
- number of 100s of Nanseconds in a second, multiplied by the number
- of seconds in a minute.
-
- The correct time is the delta in hundreds of nanoseconds between
- Local and UTC times.
-
- */
-
- CorrectDeltaBetweenLocalAndUTC =
- 600000000 * ((ULONG64)DeltaBetweenLocalAndUTC);
-
- /* Now check to ensure that the difference between the Local and UTC
- times that was calculated with the function equals what it should be.
- */
- if((FullFileTime - FullLocalTime) != CorrectDeltaBetweenLocalAndUTC)
- {
- Fail("ERROR: The FileTime that was returned is not equal to "
- "what the FileTime should have been.");
- }
-
- PAL_Terminate();
- return PASS;
-}
-
+++ /dev/null
-#
-# Copyright (c) Microsoft Corporation. All rights reserved.
-#
-
-Version = 1.0
-Section = file_io
-Function = LocalFileTimeToFileTime
-Name = Positive Test for LocalFileTimeToFileTime
-TYPE = DEFAULT
-EXE1 = localfiletimetofiletime
-Description
-= Test the LocalFileTimeToFileTime function.
-= Check that the difference between the two times is correct based on the
-= current timezone.
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- localfiletimetofiletime.c
-)
-
-add_executable(paltest_localfiletimetofiletime_test2
- ${SOURCES}
-)
-
-add_dependencies(paltest_localfiletimetofiletime_test2 CoreClrPal)
-
-target_link_libraries(paltest_localfiletimetofiletime_test2
- pthread
- m
- CoreClrPal
-)
+++ /dev/null
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-/*=====================================================================
-**
-** Source: LocalFileTimeToFileTime.c (test2)
-**
-** Purpose: Tests the PAL implementation of LocalFileTimeToFileTime
-** Call LocalFileTimeToFileTime with a known valid local time,
-** call FileTimeToLocalTime and make sure the two local times
-** are the same. Then take those values and call
-** LocalFileTimeToFileTime again and make sure the file times
-** are the same.
-**
-** Depends
-** FileTimeToLocalFileTime
-**
-**
-**===================================================================*/
-
-#include <palsuite.h>
-
-
-int __cdecl main(int argc, char **argv)
-{
- const DWORD dwLowDateTime = -398124352; /* valid low date value */
- const DWORD dwHighDateTime = 29437061; /* valid high date value */
- FILETIME FileTime01;
- FILETIME FileTime02;
- FILETIME LocalTime01;
- FILETIME LocalTime02;
-
- if (0 != PAL_Initialize(argc,argv))
- {
- return FAIL;
- }
-
-
- LocalTime01.dwLowDateTime = dwLowDateTime;
- LocalTime01.dwHighDateTime = dwHighDateTime;
-
- /* get the file time */
- if(!LocalFileTimeToFileTime(&LocalTime01,&FileTime01))
- {
- Fail("ERROR: LocalFileTimeToFileTime failed. "
- "GetLastError returned %u.\n",
- GetLastError());
- }
-
- /* now convert the file time to the local time */
- if(!FileTimeToLocalFileTime(&FileTime01,&LocalTime02))
- {
- Fail("ERROR: FileTimeToLocalFileTime failed. "
- "GetLastError returned %u.\n",
- GetLastError());
- }
-
- /* LocalTime02 should be the same as the original */
- if((LocalTime02.dwLowDateTime != dwLowDateTime) ||
- (LocalTime02.dwHighDateTime != dwHighDateTime))
- {
- Fail("ERROR: After converting times back and forth, the local"
- " times are not the same:\n"
- "orig.low = %u orig.high = %u\n"
- "new.low = %u new.high = %u.\n",
- dwLowDateTime,
- dwHighDateTime,
- LocalTime02.dwLowDateTime,
- LocalTime02.dwHighDateTime);
- }
-
- /* and back again */
- if(!LocalFileTimeToFileTime(&LocalTime02,&FileTime02))
- {
- Fail("ERROR: LocalFileTimeToFileTime failed. "
- "GetLastError returned %u.\n",
- GetLastError());
- }
-
- /* FileTime02 should be the same as FileTime01 */
- if((FileTime01.dwLowDateTime != FileTime02.dwLowDateTime) ||
- (FileTime01.dwHighDateTime != FileTime02.dwHighDateTime))
- {
- Fail("ERROR: After converting times back again, the file times"
- " are not the same:\n"
- "file01.low = %u file01.high = %u\n"
- "file02.low = %u file02.high = %u.\n",
- FileTime01.dwLowDateTime,
- FileTime01.dwHighDateTime,
- FileTime02.dwLowDateTime,
- FileTime02.dwHighDateTime);
- }
-
-
- PAL_Terminate();
- return PASS;
-}
-
+++ /dev/null
-#
-# Copyright (c) Microsoft Corporation. All rights reserved.
-#
-
-Version = 1.0
-Section = file_io
-Function = LocalFileTimeToFileTime
-Name = Positive Test for LocalFileTimeToFileTime (test2)
-TYPE = DEFAULT
-EXE1 = localfiletimetofiletime
-Description
-= Tests the PAL implementation of LocalFileTimeToFileTime
-= Call LocalFileTimeToFileTime with a known valid local time,
-= call FileTimeToLocalTime and make sure the two local times
-= are the same. Then take those values and call
-= LocalFileTimeToFileTime again and make sure the file times
-= are the same.
-
file_io/CreateDirectoryW/test1/paltest_createdirectoryw_test1
file_io/DeleteFileA/test1/paltest_deletefilea_test1
file_io/DeleteFileW/test1/paltest_deletefilew_test1
-file_io/DosDateTimeToFileTime/test1/paltest_dosdatetimetofiletime_test1
-file_io/DosDateTimeToFileTime/test2/paltest_dosdatetimetofiletime_test2
-file_io/DosDateTimeToFileTime/test3/paltest_dosdatetimetofiletime_test3
-file_io/DosDateTimeToFileTime/test4/paltest_dosdatetimetofiletime_test4
file_io/errorpathnotfound/test2/paltest_errorpathnotfound_test2
file_io/errorpathnotfound/test3/paltest_errorpathnotfound_test3
file_io/FileTimeToDosDateTime/test1/paltest_filetimetodosdatetime_test1
-file_io/FileTimeToLocalFileTime/test1/paltest_filetimetolocalfiletime_test1
file_io/FindClose/test1/paltest_findclose_test1
file_io/FindFirstFileA/test1/paltest_findfirstfilea_test1
file_io/FindFirstFileW/test1/paltest_findfirstfilew_test1
file_io/GetTempFileNameA/test2/paltest_gettempfilenamea_test2
file_io/GetTempFileNameA/test3/paltest_gettempfilenamea_test3
file_io/GetTempFileNameW/test3/paltest_gettempfilenamew_test3
-file_io/LocalFileTimeToFileTime/test1/paltest_localfiletimetofiletime_test1
-file_io/LocalFileTimeToFileTime/test2/paltest_localfiletimetofiletime_test2
file_io/ReadFile/test2/paltest_readfile_test2
file_io/ReadFile/test3/paltest_readfile_test3
file_io/ReadFile/test4/paltest_readfile_test4
file_io/createfilew/test1,1
file_io/deletefilea/test1,1
file_io/deletefilew/test1,1
-file_io/dosdatetimetofiletime/test1,1
-file_io/dosdatetimetofiletime/test2,1
-file_io/dosdatetimetofiletime/test3,1
-file_io/dosdatetimetofiletime/test4,1
file_io/errorpathnotfound/test1,1
file_io/errorpathnotfound/test2,1
file_io/errorpathnotfound/test3,1
#file_io/errorpathnotfound/test4,1
file_io/filetimetodosdatetime/test1,1
-file_io/filetimetolocalfiletime/test1,1
file_io/findclose/test1,1
file_io/findfirstfilea/test1,1
#file_io/findfirstfilew/test1,1
file_io/gettempfilenamew/test3,1
file_io/gettemppatha/test1,1
file_io/gettemppathw/test1,1
-file_io/localfiletimetofiletime/test1,1
-file_io/localfiletimetofiletime/test2,1
file_io/movefileexw/test1,1
file_io/movefilew/test1,1
#file_io/readfile/test1,1