diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2013-03-17 08:36:26 +0100 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2013-04-18 21:34:46 +0200 |
commit | 9830fd36dbdb72c79703b0c61efc027fba793c5a (patch) | |
tree | 2e9d698e6ca109dc6627adb5c84aa2b635bcfe92 /tools | |
parent | 5aaaf0694b6e3213685563fc3bc90d19b10f5c75 (diff) |
date/time IDL datatypes incompatible change
- nanosecond precision
- signed (allowed negative) year
Also: assorted improvements / bugfixes in date/time handling code.
Some factorisation of copy/pasted code.
Change-Id: I761a1b0b8731c82f19a0c37acbcf43d3c06d6cd6
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Library_tl.mk | 6 | ||||
-rw-r--r-- | tools/inc/tools/datetime.hxx | 4 | ||||
-rw-r--r-- | tools/inc/tools/time.hxx | 50 | ||||
-rw-r--r-- | tools/source/datetime/datetime.cxx | 18 | ||||
-rw-r--r-- | tools/source/datetime/ttime.cxx | 246 | ||||
-rw-r--r-- | tools/source/inet/inetmsg.cxx | 6 | ||||
-rw-r--r-- | tools/source/rc/rc.cxx | 5 |
7 files changed, 222 insertions, 113 deletions
diff --git a/tools/Library_tl.mk b/tools/Library_tl.mk index 9ea13e7e290e..5491b8c90e91 100644 --- a/tools/Library_tl.mk +++ b/tools/Library_tl.mk @@ -97,6 +97,12 @@ $(eval $(call gb_Library_use_externals,tl,\ zlib \ )) +ifeq ($(OS),LINUX) +$(eval $(call gb_Library_add_libs,tl,\ + -lrt \ +)) +endif + ifeq ($(OS),WNT) $(eval $(call gb_Library_use_system_win32_libs,tl,\ diff --git a/tools/inc/tools/datetime.hxx b/tools/inc/tools/datetime.hxx index 0a799343145e..1de0f3d6432c 100644 --- a/tools/inc/tools/datetime.hxx +++ b/tools/inc/tools/datetime.hxx @@ -50,11 +50,11 @@ public: sal_Bool IsBetween( const DateTime& rFrom, const DateTime& rTo ) const; - sal_Bool IsEqualIgnore100Sec( const DateTime& rDateTime ) const + sal_Bool IsEqualIgnoreNanoSec( const DateTime& rDateTime ) const { if ( Date::operator!=( rDateTime ) ) return sal_False; - return Time::IsEqualIgnore100Sec( rDateTime ); + return Time::IsEqualIgnoreNanoSec( rDateTime ); } sal_Bool operator ==( const DateTime& rDateTime ) const diff --git a/tools/inc/tools/time.hxx b/tools/inc/tools/time.hxx index fe585103bb2e..ce6eb42ebe88 100644 --- a/tools/inc/tools/time.hxx +++ b/tools/inc/tools/time.hxx @@ -33,7 +33,7 @@ class ResId; class TOOLS_DLLPUBLIC SAL_WARN_UNUSED Time { private: - sal_Int32 nTime; + sal_Int64 nTime; public: enum TimeInitSystem @@ -46,38 +46,54 @@ public: { EMPTY }; + static const sal_Int64 hourPerDay = 24; + static const sal_Int64 minutePerHour = 60; + static const sal_Int64 secondPerMinute = 60; + static const sal_Int64 nanoSecPerSec = 1000000000; + static const sal_Int64 nanoSecPerMinute = nanoSecPerSec * secondPerMinute; + static const sal_Int64 nanoSecPerHour = nanoSecPerSec * secondPerMinute * minutePerHour; + static const sal_Int64 nanoSecPerDay = nanoSecPerSec * secondPerMinute * minutePerHour * hourPerDay; + static const sal_Int64 secondPerHour = secondPerMinute * minutePerHour; + static const sal_Int64 secondPerDay = secondPerMinute * minutePerHour * hourPerDay; + static const sal_Int64 minutePerDay = minutePerHour * hourPerDay; + static const sal_Int64 nanoPerMicro = 1000; + static const sal_Int64 nanoPerMilli = 1000000; + static const sal_Int64 nanoPerCenti = 10000000; Time( TimeInitEmpty ) { nTime = 0; } Time( TimeInitSystem ); Time( const ResId & rResId ); - Time( sal_Int32 _nTime ) { Time::nTime = _nTime; } + Time( sal_Int64 _nTime ) { Time::nTime = _nTime; } Time( const Time& rTime ); Time( sal_uIntPtr nHour, sal_uIntPtr nMin, - sal_uIntPtr nSec = 0, sal_uIntPtr n100Sec = 0 ); + sal_uIntPtr nSec = 0, sal_uIntPtr nNanoSec = 0 ); - void SetTime( sal_Int32 nNewTime ) { nTime = nNewTime; } - sal_Int32 GetTime() const { return nTime; } + void SetTime( sal_Int64 nNewTime ) { nTime = nNewTime; } + sal_Int64 GetTime() const { return nTime; } void SetHour( sal_uInt16 nNewHour ); void SetMin( sal_uInt16 nNewMin ); void SetSec( sal_uInt16 nNewSec ); - void Set100Sec( sal_uInt16 nNew100Sec ); + void SetNanoSec( sal_uInt32 nNewNanoSec ); sal_uInt16 GetHour() const - { sal_uIntPtr nTempTime = (nTime >= 0) ? nTime : nTime*-1; - return (sal_uInt16)(nTempTime / 1000000); } + { sal_uInt64 nTempTime = (nTime >= 0) ? nTime : -nTime; + return static_cast<sal_uInt16>(nTempTime / 10000000000000); } sal_uInt16 GetMin() const - { sal_uIntPtr nTempTime = (nTime >= 0) ? nTime : nTime*-1; - return (sal_uInt16)((nTempTime / 10000) % 100); } + { sal_uInt64 nTempTime = (nTime >= 0) ? nTime : -nTime; + return static_cast<sal_uInt16>((nTempTime / 100000000000) % 100); } sal_uInt16 GetSec() const - { sal_uIntPtr nTempTime = (nTime >= 0) ? nTime : nTime*-1; - return (sal_uInt16)((nTempTime / 100) % 100); } - sal_uInt16 Get100Sec() const - { sal_uIntPtr nTempTime = (nTime >= 0) ? nTime : nTime*-1; - return (sal_uInt16)(nTempTime % 100); } + { sal_uInt64 nTempTime = (nTime >= 0) ? nTime : -nTime; + return static_cast<sal_uInt16>((nTempTime / 1000000000) % 100); } + sal_uInt32 GetNanoSec() const + { sal_uInt64 nTempTime = (nTime >= 0) ? nTime : -nTime; + return static_cast<sal_uInt32>( nTempTime % 1000000000); } + // TODO: consider removing GetMSFromTime and MakeTimeFromMS? sal_Int32 GetMSFromTime() const; void MakeTimeFromMS( sal_Int32 nMS ); + sal_Int64 GetNSFromTime() const; + void MakeTimeFromNS( sal_Int64 nNS ); /// 12 hours == 0.5 days double GetTimeInDays() const; @@ -85,7 +101,7 @@ public: sal_Bool IsBetween( const Time& rFrom, const Time& rTo ) const { return ((nTime >= rFrom.nTime) && (nTime <= rTo.nTime)); } - sal_Bool IsEqualIgnore100Sec( const Time& rTime ) const; + sal_Bool IsEqualIgnoreNanoSec( const Time& rTime ) const; sal_Bool operator ==( const Time& rTime ) const { return (nTime == rTime.nTime); } @@ -108,7 +124,7 @@ public: Time& operator =( const Time& rTime ); Time operator -() const - { return Time( nTime * -1 ); } + { return Time( -nTime ); } Time& operator +=( const Time& rTime ); Time& operator -=( const Time& rTime ); TOOLS_DLLPUBLIC friend Time operator +( const Time& rTime1, const Time& rTime2 ); diff --git a/tools/source/datetime/datetime.cxx b/tools/source/datetime/datetime.cxx index 4027d16fce97..1bf612730bb0 100644 --- a/tools/source/datetime/datetime.cxx +++ b/tools/source/datetime/datetime.cxx @@ -181,8 +181,8 @@ DateTime& DateTime::operator +=( double fTimeInDays ) if ( fFrac ) { Time aTime(0); // default ctor calls system time, we don't need that - fFrac *= 24UL * 60 * 60 * 1000; // time expressed in milliseconds - aTime.MakeTimeFromMS( long(fFrac) ); // method handles negative ms + fFrac *= ::Time::nanoSecPerDay; // time expressed in nanoseconds + aTime.MakeTimeFromNS( static_cast<sal_Int64>(fFrac) ); // method handles negative ns operator+=( aTime ); } return *this; @@ -198,11 +198,11 @@ DateTime operator +( const DateTime& rDateTime, double fTimeInDays ) double operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 ) { long nDays = (const Date&) rDateTime1 - (const Date&) rDateTime2; - long nTime = rDateTime1.GetMSFromTime() - rDateTime2.GetMSFromTime(); + sal_Int64 nTime = rDateTime1.GetNSFromTime() - rDateTime2.GetNSFromTime(); if ( nTime ) { double fTime = double(nTime); - fTime /= 24UL * 60 * 60 * 1000; // convert from milliseconds to fraction + fTime /= ::Time::nanoSecPerDay; // convert from nanoseconds to fraction if ( nDays < 0 && fTime > 0.0 ) fTime = 1.0 - fTime; return double(nDays) + fTime; @@ -223,10 +223,7 @@ void DateTime::GetWin32FileDateTime( sal_uInt32 & rLower, sal_uInt32 & rUpper ) sal_Int64 aTime = a100nPerDay * nDays + - a100nPerSecond * ( - sal_Int64( GetSec() ) + - 60 * sal_Int64( GetMin() ) + - 60 * 60 * sal_Int64( GetHour() ) ); + GetNSFromTime()/100; rLower = sal_uInt32( aTime % SAL_CONST_UINT64( 0x100000000 ) ); rUpper = sal_uInt32( aTime / SAL_CONST_UINT64( 0x100000000 ) ); @@ -263,8 +260,9 @@ DateTime DateTime::CreateFromWin32FileDateTime( const sal_uInt32 & rLower, const (sal_uInt16)( nDays + 1 ), nMonths, sal::static_int_cast< sal_uInt16 >(nYears + 1601) ); Time _aTime( sal_uIntPtr( ( aTime / ( a100nPerSecond * 60 * 60 ) ) % sal_Int64( 24 ) ), - sal_uIntPtr( ( aTime / ( a100nPerSecond * 60 ) ) % sal_Int64( 60 ) ), - sal_uIntPtr( ( aTime / ( a100nPerSecond ) ) % sal_Int64( 60 ) ) ); + sal_uIntPtr( ( aTime / ( a100nPerSecond * 60 ) ) % sal_Int64( 60 ) ), + sal_uIntPtr( ( aTime / ( a100nPerSecond ) ) % sal_Int64( 60 ) ), + (aTime % a100nPerSecond) * 100 ); return DateTime( _aDate, _aTime ); } diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx index b32c09078e40..2841bb119173 100644 --- a/tools/source/datetime/ttime.cxx +++ b/tools/source/datetime/ttime.cxx @@ -27,46 +27,61 @@ #endif #include <time.h> +#ifdef __MACH__ +#include <mach/clock.h> +#include <mach/mach.h> +#endif #include <tools/time.hxx> +#include <osl/diagnose.h> + #if defined(SOLARIS) && defined(__GNUC__) extern long altzone; #endif -static sal_Int32 TimeToSec100( const Time& rTime ) -{ - short nSign = (rTime.GetTime() >= 0) ? +1 : -1; - sal_Int32 nHour = rTime.GetHour(); - sal_Int32 nMin = rTime.GetMin(); - sal_Int32 nSec = rTime.GetSec(); - sal_Int32 n100Sec = rTime.Get100Sec(); +namespace { -// Due to interal compiler error in MSC a little bit more complicated: -// return (n100Sec + (nSec*100) + (nMin*60*100) + (nHour*60*60*100) * nSign); + const sal_Int64 secMask = 1000000000; + const sal_Int64 minMask = 100000000000; + const sal_Int64 hourMask = 10000000000000; - sal_Int32 nRet = n100Sec; - nRet += nSec*100; - nRet += nMin*60*100; - nRet += nHour*60*60*100; + const sal_Int64 nanoSecInSec = 1000000000; + const sal_Int16 secInMin = 60; + const sal_Int16 minInHour = 60; - return (nRet * nSign); -} + sal_Int64 TimeToNanoSec( const Time& rTime ) + { + short nSign = (rTime.GetTime() >= 0) ? +1 : -1; + sal_Int32 nHour = rTime.GetHour(); + sal_Int32 nMin = rTime.GetMin(); + sal_Int32 nSec = rTime.GetSec(); + sal_Int32 nNanoSec = rTime.GetNanoSec(); + + sal_Int64 nRet = nNanoSec; + nRet += nSec * nanoSecInSec; + nRet += nMin * secInMin * nanoSecInSec; + nRet += nHour * minInHour * secInMin * nanoSecInSec; + + return (nRet * nSign); + } -static Time Sec100ToTime( sal_Int32 nSec100 ) -{ - short nSign; - if ( nSec100 < 0 ) + Time NanoSecToTime( sal_Int64 nNanoSec ) { - nSec100 *= -1; - nSign = -1; + short nSign; + if ( nNanoSec < 0 ) + { + nNanoSec *= -1; + nSign = -1; + } + else + nSign = 1; + + Time aTime( 0, 0, 0, nNanoSec ); + aTime.SetTime( aTime.GetTime() * nSign ); + return aTime; } - else - nSign = 1; - Time aTime( 0, 0, 0, nSec100 ); - aTime.SetTime( aTime.GetTime() * nSign ); - return aTime; -} +} // anonymous namespace Time::Time( TimeInitSystem ) { @@ -75,27 +90,47 @@ Time::Time( TimeInitSystem ) GetLocalTime( &aDateTime ); // construct time - nTime = (((sal_Int32)aDateTime.wHour)*1000000) + - (((sal_Int32)aDateTime.wMinute)*10000) + - (((sal_Int32)aDateTime.wSecond)*100) + - ((sal_Int32)aDateTime.wMilliseconds/10); + nTime = aDateTime.wHour * hourMask + + aDateTime.wMinute * minMask + + aDateTime.wSecond * secMask + + aDateTime.wMilliseconds * 1000000; #else - time_t nTmpTime; - struct tm aTime; - // determine time - nTmpTime = time( 0 ); + struct timespec tsTime; +#if defined( __MACH__ ) + // OS X does not have clock_gettime, use clock_get_time + clock_serv_t cclock; + mach_timespec_t mts; + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); + clock_get_time(cclock, &mts); + mach_port_deallocate(mach_task_self(), cclock); + tsTime.tv_sec = mts.tv_sec; + tsTime.tv_nsec = mts.tv_nsec; +#else + // CLOCK_REALTIME should be supported + // on any modern Unix, but be extra cautious + if (clock_gettime(CLOCK_REALTIME, &tsTime) != 0) + { + struct timeval tvTime; + OSL_VERIFY( gettimeofday(&tvTime, NULL) != 0 ); + tsTime.tv_sec = tvTime.tv_sec; + tsTime.tv_nsec = tvTime.tv_usec * 1000; + } +#endif // __MACH__ // construct time + struct tm aTime; + time_t nTmpTime = tsTime.tv_sec; if ( localtime_r( &nTmpTime, &aTime ) ) { - nTime = (((sal_Int32)aTime.tm_hour)*1000000) + - (((sal_Int32)aTime.tm_min)*10000) + - (((sal_Int32)aTime.tm_sec)*100); + nTime = aTime.tm_hour * hourMask + + aTime.tm_min * minMask + + aTime.tm_sec * secMask + + tsTime.tv_nsec; } else nTime = 0; -#endif +#endif // WNT } Time::Time( const Time& rTime ) @@ -103,43 +138,52 @@ Time::Time( const Time& rTime ) nTime = rTime.nTime; } -Time::Time( sal_uIntPtr nHour, sal_uIntPtr nMin, sal_uIntPtr nSec, sal_uIntPtr n100Sec ) +Time::Time( sal_uIntPtr nHour, sal_uIntPtr nMin, sal_uIntPtr nSec, sal_uIntPtr nNanoSec ) { // normalize time - nSec += n100Sec / 100; - n100Sec = n100Sec % 100; - nMin += nSec / 60; - nSec = nSec % 60; - nHour += nMin / 60; - nMin = nMin % 60; + nSec += nNanoSec / nanoSecInSec; + nNanoSec %= nanoSecInSec; + nMin += nSec / secInMin; + nSec %= secInMin; + nHour += nMin / minInHour; + nMin %= minInHour; // construct time - nTime = (sal_Int32)(n100Sec + (nSec*100) + (nMin*10000) + (nHour*1000000)); + nTime = nNanoSec + + nSec * secMask + + nMin * minMask + + nHour * hourMask; } void Time::SetHour( sal_uInt16 nNewHour ) { - short nSign = (nTime >= 0) ? +1 : -1; + short nSign = (nTime >= 0) ? +1 : -1; sal_Int32 nMin = GetMin(); sal_Int32 nSec = GetSec(); - sal_Int32 n100Sec = Get100Sec(); + sal_Int32 nNanoSec = GetNanoSec(); - nTime = (n100Sec + (nSec*100) + (nMin*10000) + - (((sal_Int32)nNewHour)*1000000)) * nSign; + nTime = nSign * + ( nNanoSec + + nSec * secMask + + nMin * minMask + + nNewHour * hourMask ); } void Time::SetMin( sal_uInt16 nNewMin ) { - short nSign = (nTime >= 0) ? +1 : -1; + short nSign = (nTime >= 0) ? +1 : -1; sal_Int32 nHour = GetHour(); sal_Int32 nSec = GetSec(); - sal_Int32 n100Sec = Get100Sec(); + sal_Int32 nNanoSec = GetNanoSec(); // no overflow - nNewMin = nNewMin % 60; + nNewMin = nNewMin % minInHour; - nTime = (n100Sec + (nSec*100) + (((sal_Int32)nNewMin)*10000) + - (nHour*1000000)) * nSign; + nTime = nSign * + ( nNanoSec + + nSec * secMask + + nNewMin * minMask + + nHour * hourMask ); } void Time::SetSec( sal_uInt16 nNewSec ) @@ -147,16 +191,19 @@ void Time::SetSec( sal_uInt16 nNewSec ) short nSign = (nTime >= 0) ? +1 : -1; sal_Int32 nHour = GetHour(); sal_Int32 nMin = GetMin(); - sal_Int32 n100Sec = Get100Sec(); + sal_Int32 nNanoSec = GetNanoSec(); // no overflow - nNewSec = nNewSec % 60; + nNewSec = nNewSec % secInMin; - nTime = (n100Sec + (((sal_Int32)nNewSec)*100) + (nMin*10000) + - (nHour*1000000)) * nSign; + nTime = nSign * + ( nNanoSec + + nNewSec * secMask + + nMin * minMask + + nHour * hourMask ); } -void Time::Set100Sec( sal_uInt16 nNew100Sec ) +void Time::SetNanoSec( sal_uInt32 nNewNanoSec ) { short nSign = (nTime >= 0) ? +1 : -1; sal_Int32 nHour = GetHour(); @@ -164,10 +211,44 @@ void Time::Set100Sec( sal_uInt16 nNew100Sec ) sal_Int32 nSec = GetSec(); // no overflow - nNew100Sec = nNew100Sec % 100; + nNewNanoSec = nNewNanoSec % nanoSecInSec; + + nTime = nSign * + ( nNewNanoSec + + nSec * secMask + + nMin * minMask + + nHour * hourMask ); +} + +sal_Int64 Time::GetNSFromTime() const +{ + short nSign = (nTime >= 0) ? +1 : -1; + sal_Int32 nHour = GetHour(); + sal_Int32 nMin = GetMin(); + sal_Int32 nSec = GetSec(); + sal_Int32 nNanoSec = GetNanoSec(); + + return nSign * + ( nNanoSec + + nSec * nanoSecInSec + + nMin * (secInMin * nanoSecInSec) + + nHour * (minInHour * secInMin * nanoSecInSec) ); +} + +void Time::MakeTimeFromNS( sal_Int64 nNS ) +{ + short nSign; + if ( nNS < 0 ) + { + nNS *= -1; + nSign = -1; + } + else + nSign = 1; - nTime = (((sal_Int32)nNew100Sec) + (nSec*100) + (nMin*10000) + - (nHour*1000000)) * nSign; + // avoid overflow when sal_uIntPtr is 32 bits + Time aTime( 0, 0, nNS/nanoSecInSec, nNS % nanoSecInSec ); + SetTime( aTime.GetTime() * nSign ); } sal_Int32 Time::GetMSFromTime() const @@ -176,9 +257,13 @@ sal_Int32 Time::GetMSFromTime() const sal_Int32 nHour = GetHour(); sal_Int32 nMin = GetMin(); sal_Int32 nSec = GetSec(); - sal_Int32 n100Sec = Get100Sec(); + sal_Int32 nNanoSec = GetNanoSec(); - return (((nHour*3600000)+(nMin*60000)+(nSec*1000)+(n100Sec*10))*nSign); + return nSign * + ( nNanoSec/1000000 + + nSec * 1000 + + nMin * 60000 + + nHour * 360000 ); } void Time::MakeTimeFromMS( sal_Int32 nMS ) @@ -192,7 +277,8 @@ void Time::MakeTimeFromMS( sal_Int32 nMS ) else nSign = 1; - Time aTime( 0, 0, 0, nMS/10 ); + // avoid overflow when sal_uIntPtr is 32 bits + Time aTime( 0, 0, nMS/1000, (nMS % 1000) * 1000000 ); SetTime( aTime.GetTime() * nSign ); } @@ -202,9 +288,9 @@ double Time::GetTimeInDays() const double nHour = GetHour(); double nMin = GetMin(); double nSec = GetSec(); - double n100Sec = Get100Sec(); + double nNanoSec = GetNanoSec(); - return (nHour+(nMin/60)+(nSec/(60*60))+(n100Sec/(60*60*100))) / 24 * nSign; + return (nHour + (nMin / 60) + (nSec / (minInHour * secInMin)) + (nNanoSec / (minInHour * secInMin * nanoSecInSec))) / 24 * nSign; } Time& Time::operator =( const Time& rTime ) @@ -215,34 +301,34 @@ Time& Time::operator =( const Time& rTime ) Time& Time::operator +=( const Time& rTime ) { - nTime = Sec100ToTime( TimeToSec100( *this ) + - TimeToSec100( rTime ) ).GetTime(); + nTime = NanoSecToTime( TimeToNanoSec( *this ) + + TimeToNanoSec( rTime ) ).GetTime(); return *this; } Time& Time::operator -=( const Time& rTime ) { - nTime = Sec100ToTime( TimeToSec100( *this ) - - TimeToSec100( rTime ) ).GetTime(); + nTime = NanoSecToTime( TimeToNanoSec( *this ) - + TimeToNanoSec( rTime ) ).GetTime(); return *this; } Time operator +( const Time& rTime1, const Time& rTime2 ) { - return Sec100ToTime( TimeToSec100( rTime1 ) + - TimeToSec100( rTime2 ) ); + return NanoSecToTime( TimeToNanoSec( rTime1 ) + + TimeToNanoSec( rTime2 ) ); } Time operator -( const Time& rTime1, const Time& rTime2 ) { - return Sec100ToTime( TimeToSec100( rTime1 ) - - TimeToSec100( rTime2 ) ); + return NanoSecToTime( TimeToNanoSec( rTime1 ) - + TimeToNanoSec( rTime2 ) ); } -sal_Bool Time::IsEqualIgnore100Sec( const Time& rTime ) const +sal_Bool Time::IsEqualIgnoreNanoSec( const Time& rTime ) const { - sal_Int32 n1 = (nTime < 0 ? -Get100Sec() : Get100Sec() ); - sal_Int32 n2 = (rTime.nTime < 0 ? -rTime.Get100Sec() : rTime.Get100Sec() ); + sal_Int32 n1 = (nTime < 0 ? -static_cast<sal_Int32>(GetNanoSec()) : GetNanoSec() ); + sal_Int32 n2 = (rTime.nTime < 0 ? -static_cast<sal_Int32>(rTime.GetNanoSec()) : rTime.GetNanoSec() ); return (nTime - n1) == (rTime.nTime - n2); } diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index 914d59caca82..120a1db0a32c 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -303,7 +303,7 @@ bool INetRFC822Message::ParseDateField ( rDateTime.SetHour (ParseNumber (aDateField, nIndex)); nIndex++; rDateTime.SetMin (ParseNumber (aDateField, nIndex)); nIndex++; rDateTime.SetSec (ParseNumber (aDateField, nIndex)); nIndex++; - rDateTime.Set100Sec (0); + rDateTime.SetNanoSec (0); sal_uInt16 nYear = ParseNumber (aDateField, nIndex); if (nYear < 100) nYear += 1900; @@ -324,7 +324,7 @@ bool INetRFC822Message::ParseDateField ( rDateTime.SetHour (ParseNumber (aDateField, nIndex)); nIndex++; rDateTime.SetMin (ParseNumber (aDateField, nIndex)); nIndex++; rDateTime.SetSec (ParseNumber (aDateField, nIndex)); nIndex++; - rDateTime.Set100Sec (0); + rDateTime.SetNanoSec (0); if ((aDateField[nIndex] == '+') || (aDateField[nIndex] == '-') ) @@ -338,7 +338,7 @@ bool INetRFC822Message::ParseDateField ( aDiff.SetHour (nOffset / 100); aDiff.SetMin (nOffset % 100); aDiff.SetSec (0); - aDiff.Set100Sec (0); + aDiff.SetNanoSec (0); if (bEast) rDateTime -= aDiff; diff --git a/tools/source/rc/rc.cxx b/tools/source/rc/rc.cxx index 87ec7667d4eb..7ebdae058461 100644 --- a/tools/source/rc/rc.cxx +++ b/tools/source/rc/rc.cxx @@ -54,7 +54,10 @@ Time::Time( const ResId& rResId ) if ( 0x04 & nObjMask ) SetSec( (sal_uInt16)pResMgr->ReadShort() ); if ( 0x08 & nObjMask ) - Set100Sec( (sal_uInt16)pResMgr->ReadShort() ); + // TODO: when we change the place that writes this binary resource format to match: + // SetNanoSec( pResMgr->ReadLong() ); + // In the meantime: + SetNanoSec( pResMgr->ReadShort() * ::Time::nanoPerCenti ); } Date::Date( const ResId& rResId ) : nDate(0) |