ICU-3677 uprv_getUTCtime should return UDate instead of int32_t.
This is for cases where time_t is 64-bit. X-SVN-Rev: 16150
This commit is contained in:
parent
0cc1b6a9ed
commit
608ca77ba5
@ -214,7 +214,7 @@ u_bottomNBytesOfDouble(double* d, int n)
|
|||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* Get UTC (GMT) time measured in seconds since 0:00 on 1/1/70.*/
|
/* Get UTC (GMT) time measured in seconds since 0:00 on 1/1/70.*/
|
||||||
U_CAPI int32_t U_EXPORT2
|
U_CAPI UDate U_EXPORT2
|
||||||
uprv_getUTCtime()
|
uprv_getUTCtime()
|
||||||
{
|
{
|
||||||
#ifdef XP_MAC
|
#ifdef XP_MAC
|
||||||
@ -230,11 +230,11 @@ uprv_getUTCtime()
|
|||||||
time(&t);
|
time(&t);
|
||||||
uprv_memcpy( &tmrec, gmtime(&t), sizeof(tmrec) );
|
uprv_memcpy( &tmrec, gmtime(&t), sizeof(tmrec) );
|
||||||
t2 = mktime(&tmrec); /* seconds of current GMT*/
|
t2 = mktime(&tmrec); /* seconds of current GMT*/
|
||||||
return t2 - t1; /* GMT (or UTC) in seconds since 1970*/
|
return (UDate)(t2 - t1) * U_MILLIS_PER_SECOND; /* GMT (or UTC) in seconds since 1970*/
|
||||||
#else
|
#else
|
||||||
time_t epochtime;
|
time_t epochtime;
|
||||||
time(&epochtime);
|
time(&epochtime);
|
||||||
return epochtime;
|
return (UDate)epochtime * U_MILLIS_PER_SECOND;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,11 +238,11 @@ U_STABLE int32_t U_EXPORT2 uprv_timezone(void);
|
|||||||
U_INTERNAL const char* U_EXPORT2 uprv_tzname(int n);
|
U_INTERNAL const char* U_EXPORT2 uprv_tzname(int n);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get UTC (GMT) time measured in seconds since 0:00 on 1/1/70.
|
* Get UTC (GMT) time measured in milliseconds since 0:00 on 1/1/1970.
|
||||||
* @return the UTC time measured in seconds
|
* @return the UTC time measured in milliseconds
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
U_INTERNAL int32_t U_EXPORT2 uprv_getUTCtime(void);
|
U_INTERNAL UDate U_EXPORT2 uprv_getUTCtime(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the ICU data directory.
|
* Return the ICU data directory.
|
||||||
|
@ -783,7 +783,7 @@ Calendar::getAvailableLocales(int32_t& count)
|
|||||||
UDate
|
UDate
|
||||||
Calendar::getNow()
|
Calendar::getNow()
|
||||||
{
|
{
|
||||||
return (UDate)uprv_getUTCtime() * U_MILLIS_PER_SECOND; // return as milliseconds
|
return uprv_getUTCtime(); // return as milliseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
|
@ -446,7 +446,7 @@ UBool OlsonTimeZone::useDaylightTime() const {
|
|||||||
// DST is in use in the current year (at any point in the year)
|
// DST is in use in the current year (at any point in the year)
|
||||||
// and returns TRUE if so.
|
// and returns TRUE if so.
|
||||||
|
|
||||||
int32_t days = Math::floorDivide(uprv_getUTCtime(), SECONDS_PER_DAY); // epoch days
|
int32_t days = (int32_t)Math::floorDivide(uprv_getUTCtime(), (double)U_MILLIS_PER_DAY); // epoch days
|
||||||
|
|
||||||
int32_t year, month, dom, dow;
|
int32_t year, month, dom, dow;
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ static void TestPUtilAPI(void){
|
|||||||
if ((tzoffset % 1800 != 0)) {
|
if ((tzoffset % 1800 != 0)) {
|
||||||
log_err("FAIL: t_timezone may be incorrect. It is not a multiple of 30min.");
|
log_err("FAIL: t_timezone may be incorrect. It is not a multiple of 30min.");
|
||||||
}
|
}
|
||||||
tzoffset=uprv_getUTCtime();
|
/*tzoffset=uprv_getUTCtime();*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,10 @@
|
|||||||
if (exec) { \
|
if (exec) { \
|
||||||
logln(#test "---"); \
|
logln(#test "---"); \
|
||||||
logln((UnicodeString)""); \
|
logln((UnicodeString)""); \
|
||||||
int32_t t = uprv_getUTCtime(); \
|
UDate t = uprv_getUTCtime(); \
|
||||||
test(); \
|
test(); \
|
||||||
t = uprv_getUTCtime() - t; \
|
t = uprv_getUTCtime() - t; \
|
||||||
logln((UnicodeString)#test " took " + t + " seconds"); \
|
logln((UnicodeString)#test " took " + t/U_MILLIS_PER_DAY + " seconds"); \
|
||||||
} \
|
} \
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
TestMutexThread1 & fOtherThread;
|
TestMutexThread1 & fOtherThread;
|
||||||
UBool fDone, fErr;
|
UBool fDone, fErr;
|
||||||
int32_t fElapsed;
|
UDate fElapsed;
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* The assignment operator has no real implementation.
|
* The assignment operator has no real implementation.
|
||||||
@ -687,7 +687,7 @@ void MultithreadTest::TestMutex()
|
|||||||
{
|
{
|
||||||
if(thread2.fErr)
|
if(thread2.fErr)
|
||||||
errln("Thread 2 says: thread1 didn't run before I aquired the mutex.");
|
errln("Thread 2 says: thread1 didn't run before I aquired the mutex.");
|
||||||
logln("took %lu seconds for thread2 to aquire the mutex.", thread2.fElapsed);
|
logln("took %lu seconds for thread2 to aquire the mutex.", (int)(thread2.fElapsed/U_MILLIS_PER_DAY));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SimpleThread::sleep(1000);
|
SimpleThread::sleep(1000);
|
||||||
|
Loading…
Reference in New Issue
Block a user