From 608ca77ba562e98a05f926db2eba3b874ad35802 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Fri, 13 Aug 2004 01:20:26 +0000 Subject: [PATCH] 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 --- icu4c/source/common/putil.c | 6 +++--- icu4c/source/common/unicode/putil.h | 6 +++--- icu4c/source/i18n/calendar.cpp | 2 +- icu4c/source/i18n/olsontz.cpp | 2 +- icu4c/source/test/cintltst/putiltst.c | 2 +- icu4c/source/test/intltest/transrt.cpp | 4 ++-- icu4c/source/test/intltest/tsmthred.cpp | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/icu4c/source/common/putil.c b/icu4c/source/common/putil.c index 9789e4d943..1ff673db30 100644 --- a/icu4c/source/common/putil.c +++ b/icu4c/source/common/putil.c @@ -214,7 +214,7 @@ u_bottomNBytesOfDouble(double* d, int n) ---------------------------------------------------------------------------*/ /* 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() { #ifdef XP_MAC @@ -230,11 +230,11 @@ uprv_getUTCtime() time(&t); uprv_memcpy( &tmrec, gmtime(&t), sizeof(tmrec) ); 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 time_t epochtime; time(&epochtime); - return epochtime; + return (UDate)epochtime * U_MILLIS_PER_SECOND; #endif } diff --git a/icu4c/source/common/unicode/putil.h b/icu4c/source/common/unicode/putil.h index 66955345d9..687dbd4b8e 100644 --- a/icu4c/source/common/unicode/putil.h +++ b/icu4c/source/common/unicode/putil.h @@ -238,11 +238,11 @@ U_STABLE int32_t U_EXPORT2 uprv_timezone(void); U_INTERNAL const char* U_EXPORT2 uprv_tzname(int n); /** - * Get UTC (GMT) time measured in seconds since 0:00 on 1/1/70. - * @return the UTC time measured in seconds + * Get UTC (GMT) time measured in milliseconds since 0:00 on 1/1/1970. + * @return the UTC time measured in milliseconds * @internal */ -U_INTERNAL int32_t U_EXPORT2 uprv_getUTCtime(void); +U_INTERNAL UDate U_EXPORT2 uprv_getUTCtime(void); /** * Return the ICU data directory. diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index e9c3a5abae..d39ddd8ddf 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -783,7 +783,7 @@ Calendar::getAvailableLocales(int32_t& count) UDate Calendar::getNow() { - return (UDate)uprv_getUTCtime() * U_MILLIS_PER_SECOND; // return as milliseconds + return uprv_getUTCtime(); // return as milliseconds } // ------------------------------------- diff --git a/icu4c/source/i18n/olsontz.cpp b/icu4c/source/i18n/olsontz.cpp index 5964f12df9..3f5170f4b5 100644 --- a/icu4c/source/i18n/olsontz.cpp +++ b/icu4c/source/i18n/olsontz.cpp @@ -446,7 +446,7 @@ UBool OlsonTimeZone::useDaylightTime() const { // DST is in use in the current year (at any point in the year) // 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; diff --git a/icu4c/source/test/cintltst/putiltst.c b/icu4c/source/test/cintltst/putiltst.c index 04a3c8c3ea..48c8b00d65 100644 --- a/icu4c/source/test/cintltst/putiltst.c +++ b/icu4c/source/test/cintltst/putiltst.c @@ -245,7 +245,7 @@ static void TestPUtilAPI(void){ if ((tzoffset % 1800 != 0)) { log_err("FAIL: t_timezone may be incorrect. It is not a multiple of 30min."); } - tzoffset=uprv_getUTCtime(); + /*tzoffset=uprv_getUTCtime();*/ } } diff --git a/icu4c/source/test/intltest/transrt.cpp b/icu4c/source/test/intltest/transrt.cpp index 41b6c49cd6..2e0b1aeca5 100644 --- a/icu4c/source/test/intltest/transrt.cpp +++ b/icu4c/source/test/intltest/transrt.cpp @@ -36,10 +36,10 @@ if (exec) { \ logln(#test "---"); \ logln((UnicodeString)""); \ - int32_t t = uprv_getUTCtime(); \ + UDate t = uprv_getUTCtime(); \ test(); \ t = uprv_getUTCtime() - t; \ - logln((UnicodeString)#test " took " + t + " seconds"); \ + logln((UnicodeString)#test " took " + t/U_MILLIS_PER_DAY + " seconds"); \ } \ break diff --git a/icu4c/source/test/intltest/tsmthred.cpp b/icu4c/source/test/intltest/tsmthred.cpp index e1fbb0ab04..6ef8d7f902 100644 --- a/icu4c/source/test/intltest/tsmthred.cpp +++ b/icu4c/source/test/intltest/tsmthred.cpp @@ -643,7 +643,7 @@ public: public: TestMutexThread1 & fOtherThread; UBool fDone, fErr; - int32_t fElapsed; + UDate fElapsed; private: /** * The assignment operator has no real implementation. @@ -687,7 +687,7 @@ void MultithreadTest::TestMutex() { if(thread2.fErr) 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; } SimpleThread::sleep(1000);