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
This commit is contained in:
@@ -3051,7 +3051,7 @@ RTLFUNC(FileDateTime)
|
||||
try
|
||||
{
|
||||
util::DateTime aUnoDT = xSFI->getDateTimeModified( aPath );
|
||||
aTime = Time( aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds, aUnoDT.HundredthSeconds );
|
||||
aTime = Time( aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds, aUnoDT.NanoSeconds );
|
||||
aDate = Date( aUnoDT.Day, aUnoDT.Month, aUnoDT.Year );
|
||||
}
|
||||
catch(const Exception & )
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace comphelper
|
||||
if ( lhs.Seconds > rhs.Seconds )
|
||||
return false;
|
||||
|
||||
if ( lhs.HundredthSeconds < rhs.HundredthSeconds )
|
||||
if ( lhs.NanoSeconds < rhs.NanoSeconds )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ namespace comphelper
|
||||
if ( lhs.Seconds > rhs.Seconds )
|
||||
return false;
|
||||
|
||||
if ( lhs.HundredthSeconds < rhs.HundredthSeconds )
|
||||
if ( lhs.NanoSeconds < rhs.NanoSeconds )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ using namespace ::com::sun::star::lang;
|
||||
//-------------------------------------------------------------------------
|
||||
sal_Bool operator ==(const DateTime& _rLeft, const DateTime& _rRight)
|
||||
{
|
||||
return ( _rLeft.HundredthSeconds == _rRight.HundredthSeconds) &&
|
||||
return ( _rLeft.NanoSeconds == _rRight.NanoSeconds) &&
|
||||
( _rLeft.Seconds == _rRight.Seconds) &&
|
||||
( _rLeft.Minutes == _rRight.Minutes) &&
|
||||
( _rLeft.Hours == _rRight.Hours) &&
|
||||
@@ -64,7 +64,7 @@ sal_Bool operator ==(const Date& _rLeft, const Date& _rRight)
|
||||
//-------------------------------------------------------------------------
|
||||
sal_Bool operator ==(const Time& _rLeft, const Time& _rRight)
|
||||
{
|
||||
return ( _rLeft.HundredthSeconds == _rRight.HundredthSeconds) &&
|
||||
return ( _rLeft.NanoSeconds == _rRight.NanoSeconds) &&
|
||||
( _rLeft.Seconds == _rRight.Seconds) &&
|
||||
( _rLeft.Minutes == _rRight.Minutes) &&
|
||||
( _rLeft.Hours == _rRight.Hours) ;
|
||||
|
||||
@@ -111,7 +111,9 @@ namespace dbtools
|
||||
static ::com::sun::star::util::DateTime toDateTime(const OUString& _sSQLDate);
|
||||
|
||||
|
||||
// TODO: consider removing getMsFromTime
|
||||
static sal_Int32 getMsFromTime(const ::com::sun::star::util::Time& rVal);
|
||||
static sal_Int64 getNsFromTime(const ::com::sun::star::util::Time& rVal);
|
||||
|
||||
static sal_Int32 toDays(const ::com::sun::star::util::Date& _rVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
|
||||
|
||||
@@ -120,10 +122,10 @@ namespace dbtools
|
||||
static double toDouble(const ::com::sun::star::util::DateTime& rVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
|
||||
|
||||
static sal_Int32 toINT32(const ::com::sun::star::util::Date& rVal);
|
||||
static sal_Int32 toINT32(const ::com::sun::star::util::Time& rVal);
|
||||
static sal_Int64 toINT64(const ::com::sun::star::util::Time& rVal);
|
||||
|
||||
static ::com::sun::star::util::Date toDate(sal_Int32 _nVal);
|
||||
static ::com::sun::star::util::Time toTime(sal_Int32 _nVal);
|
||||
static ::com::sun::star::util::Time toTime(sal_Int64 _nVal);
|
||||
|
||||
/** convert a double which is a date value relative to a given fixed date into a date value relative
|
||||
to the standard db null date.
|
||||
@@ -139,9 +141,9 @@ namespace dbtools
|
||||
|
||||
// return the date in the format %04d-%02d-%02d
|
||||
static OUString toDateString(const ::com::sun::star::util::Date& rDate);
|
||||
// return the time in the format %02d:%02d:%02d
|
||||
// return the time in the format %02d:%02d:%02d.%09d
|
||||
static OUString toTimeString(const ::com::sun::star::util::Time& rTime);
|
||||
// return the DateTime in the format %04d-%02d-%02d %02d:%02d:%02d
|
||||
// return the DateTime in the format %04d-%02d-%02d %02d:%02d:%02d.%09d
|
||||
static OUString toDateTimeString(const ::com::sun::star::util::DateTime& _rDateTime);
|
||||
// return the any in an sql standard format
|
||||
static OUString toSQLString(sal_Int32 eType, const ::com::sun::star::uno::Any& _rVal, sal_Bool bQuote,
|
||||
|
||||
@@ -746,14 +746,14 @@ bool operator==(const Date& _rLH,const Date& _rRH)
|
||||
|
||||
bool operator==(const Time& _rLH,const Time& _rRH)
|
||||
{
|
||||
return _rLH.Minutes == _rRH.Minutes && _rLH.Hours == _rRH.Hours && _rLH.Seconds == _rRH.Seconds && _rLH.HundredthSeconds == _rRH.HundredthSeconds;
|
||||
return _rLH.Minutes == _rRH.Minutes && _rLH.Hours == _rRH.Hours && _rLH.Seconds == _rRH.Seconds && _rLH.NanoSeconds == _rRH.NanoSeconds;
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
bool operator==(const DateTime& _rLH,const DateTime& _rRH)
|
||||
{
|
||||
return _rLH.Day == _rRH.Day && _rLH.Month == _rRH.Month && _rLH.Year == _rRH.Year &&
|
||||
_rLH.Minutes == _rRH.Minutes && _rLH.Hours == _rRH.Hours && _rLH.Seconds == _rRH.Seconds && _rLH.HundredthSeconds == _rRH.HundredthSeconds;
|
||||
_rLH.Minutes == _rRH.Minutes && _rLH.Hours == _rRH.Hours && _rLH.Seconds == _rRH.Seconds && _rLH.NanoSeconds == _rRH.NanoSeconds;
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@@ -2020,7 +2020,7 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
|
||||
case DataType::TIMESTAMP:
|
||||
{
|
||||
::com::sun::star::util::DateTime* pDateTime = static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue);
|
||||
aValue.HundredthSeconds = pDateTime->HundredthSeconds;
|
||||
aValue.NanoSeconds = pDateTime->NanoSeconds;
|
||||
aValue.Seconds = pDateTime->Seconds;
|
||||
aValue.Minutes = pDateTime->Minutes;
|
||||
aValue.Hours = pDateTime->Hours;
|
||||
@@ -2073,7 +2073,7 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
|
||||
case DataType::TIME:
|
||||
{
|
||||
::com::sun::star::util::Time* pTime = static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue);
|
||||
aValue.HundredthSeconds = pTime->HundredthSeconds;
|
||||
aValue.NanoSeconds = pTime->NanoSeconds;
|
||||
aValue.Seconds = pTime->Seconds;
|
||||
aValue.Minutes = pTime->Minutes;
|
||||
aValue.Hours = pTime->Hours;
|
||||
|
||||
@@ -31,6 +31,20 @@
|
||||
|
||||
#define MAX_DAYS 3636532
|
||||
|
||||
namespace
|
||||
{
|
||||
const double fMilliSecondsPerDay = 86400000.0;
|
||||
const sal_Int64 nanoSecInSec = 1000000000;
|
||||
const sal_Int16 secInMin = 60;
|
||||
const sal_Int16 minInHour = 60;
|
||||
|
||||
const sal_Int64 secMask = 1000000000;
|
||||
const sal_Int64 minMask = 100000000000;
|
||||
const sal_Int64 hourMask = 10000000000000;
|
||||
|
||||
const double fNanoSecondsPerDay = nanoSecInSec * secInMin * minInHour * 24.0;
|
||||
}
|
||||
|
||||
//.........................................................................
|
||||
namespace dbtools
|
||||
{
|
||||
@@ -68,14 +82,15 @@ namespace dbtools
|
||||
//------------------------------------------------------------------
|
||||
OUString DBTypeConversion::toTimeString(const Time& rTime)
|
||||
{
|
||||
sal_Char s[9];
|
||||
const size_t buflen = 19;
|
||||
sal_Char s[buflen];
|
||||
snprintf(s,
|
||||
sizeof(s),
|
||||
"%02d:%02d:%02d",
|
||||
(int)rTime.Hours,
|
||||
(int)rTime.Minutes,
|
||||
(int)rTime.Seconds);
|
||||
s[8] = 0;
|
||||
buflen,
|
||||
"%02d:%02d:%02d.%09d",
|
||||
rTime.Hours,
|
||||
rTime.Minutes,
|
||||
rTime.Seconds,
|
||||
rTime.NanoSeconds);
|
||||
return OUString::createFromAscii(s);
|
||||
}
|
||||
|
||||
@@ -85,10 +100,8 @@ namespace dbtools
|
||||
Date aDate(_rDateTime.Day,_rDateTime.Month,_rDateTime.Year);
|
||||
OUStringBuffer aTemp(toDateString(aDate));
|
||||
aTemp.appendAscii(" ");
|
||||
Time aTime(0,_rDateTime.Seconds,_rDateTime.Minutes,_rDateTime.Hours);
|
||||
Time aTime(_rDateTime.NanoSeconds,_rDateTime.Seconds,_rDateTime.Minutes,_rDateTime.Hours);
|
||||
aTemp.append( toTimeString(aTime) );
|
||||
aTemp.appendAscii(".");
|
||||
aTemp.append( static_cast<sal_Int32>(_rDateTime.HundredthSeconds));
|
||||
return aTemp.makeStringAndClear();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -102,17 +115,17 @@ namespace dbtools
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Time DBTypeConversion::toTime(sal_Int32 _nVal)
|
||||
Time DBTypeConversion::toTime(sal_Int64 _nVal)
|
||||
{
|
||||
Time aReturn;
|
||||
aReturn.Hours = (sal_uInt16)(((sal_uInt32)(_nVal >= 0 ? _nVal : _nVal*-1)) / 1000000);
|
||||
aReturn.Minutes = (sal_uInt16)((((sal_uInt32)(_nVal >= 0 ? _nVal : _nVal*-1)) / 10000) % 100);
|
||||
aReturn.Seconds = (sal_uInt16)((((sal_uInt32)(_nVal >= 0 ? _nVal : _nVal*-1)) / 100) % 100);
|
||||
aReturn.HundredthSeconds = (sal_uInt16)(((sal_uInt32)(_nVal >= 0 ? _nVal : _nVal*-1)) % 100);
|
||||
sal_uInt64 unVal = static_cast<sal_uInt64>(_nVal >= 0 ? _nVal : -_nVal);
|
||||
aReturn.Hours = unVal / hourMask;
|
||||
aReturn.Minutes = (unVal / minMask) % 100;
|
||||
aReturn.Seconds = (unVal / secMask) % 100;
|
||||
aReturn.NanoSeconds = unVal % secMask;
|
||||
return aReturn;
|
||||
}
|
||||
|
||||
const double fMilliSecondsPerDay = 86400000.0;
|
||||
//------------------------------------------------------------------------------
|
||||
sal_Int32 DBTypeConversion::toINT32(const Date& rVal)
|
||||
{
|
||||
@@ -122,18 +135,21 @@ namespace dbtools
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
sal_Int32 DBTypeConversion::toINT32(const Time& rVal)
|
||||
sal_Int64 DBTypeConversion::toINT64(const Time& rVal)
|
||||
{
|
||||
// normalize time
|
||||
sal_Int32 nSeconds = rVal.Seconds + rVal.HundredthSeconds / 100;
|
||||
sal_Int32 nHundredthSeconds = rVal.HundredthSeconds % 100;
|
||||
sal_Int32 nMinutes = rVal.Minutes + nSeconds / 60;
|
||||
nSeconds = nSeconds % 60;
|
||||
sal_Int32 nHours = rVal.Hours + nMinutes / 60;
|
||||
nMinutes = nMinutes % 60;
|
||||
sal_Int32 nSeconds = rVal.Seconds + rVal.NanoSeconds / nanoSecInSec;
|
||||
sal_Int32 nNanoSeconds = rVal.NanoSeconds % nanoSecInSec;
|
||||
sal_Int32 nMinutes = rVal.Minutes + nSeconds / secInMin;
|
||||
nSeconds = nSeconds % secInMin;
|
||||
sal_Int32 nHours = rVal.Hours + nMinutes / minInHour;
|
||||
nMinutes = nMinutes % minInHour;
|
||||
|
||||
// assemble time
|
||||
return (sal_Int32)(nHundredthSeconds + (nSeconds*100) + (nMinutes*10000) + (nHours*1000000));
|
||||
return nNanoSeconds +
|
||||
nSeconds * secMask +
|
||||
nMinutes * minMask +
|
||||
nHours * hourMask;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -142,9 +158,23 @@ namespace dbtools
|
||||
sal_Int32 nHour = rVal.Hours;
|
||||
sal_Int32 nMin = rVal.Minutes;
|
||||
sal_Int32 nSec = rVal.Seconds;
|
||||
sal_Int32 n100Sec = rVal.HundredthSeconds;
|
||||
sal_Int32 nNanoSec = rVal.NanoSeconds;
|
||||
|
||||
return ((nHour*3600000)+(nMin*60000)+(nSec*1000)+(n100Sec*10));
|
||||
return ((nHour*3600000)+(nMin*60000)+(nSec*1000)+(nNanoSec/1000000));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
sal_Int64 DBTypeConversion::getNsFromTime(const Time& rVal)
|
||||
{
|
||||
sal_Int32 nHour = rVal.Hours;
|
||||
sal_Int32 nMin = rVal.Minutes;
|
||||
sal_Int32 nSec = rVal.Seconds;
|
||||
sal_Int32 nNanoSec = rVal.NanoSeconds;
|
||||
|
||||
return nNanoSec +
|
||||
nSec * nanoSecInSec +
|
||||
nMin * (secInMin * nanoSecInSec) +
|
||||
nHour * (minInHour * secInMin * nanoSecInSec);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -195,7 +225,7 @@ namespace dbtools
|
||||
return nDays;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
static void implBuildFromRelative( sal_Int32 nDays, sal_uInt16& rDay, sal_uInt16& rMonth, sal_uInt16& rYear)
|
||||
static void implBuildFromRelative( sal_Int32 nDays, sal_uInt16& rDay, sal_uInt16& rMonth, sal_Int16& rYear)
|
||||
{
|
||||
sal_Int32 nTempDays;
|
||||
sal_Int32 i = 0;
|
||||
@@ -250,7 +280,7 @@ namespace dbtools
|
||||
//------------------------------------------------------------------------------
|
||||
double DBTypeConversion::toDouble(const Time& rVal)
|
||||
{
|
||||
return (double)getMsFromTime(rVal) / fMilliSecondsPerDay;
|
||||
return (double)getNsFromTime(rVal) / fNanoSecondsPerDay;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -262,7 +292,7 @@ namespace dbtools
|
||||
aTimePart.Hours = _rVal.Hours;
|
||||
aTimePart.Minutes = _rVal.Minutes;
|
||||
aTimePart.Seconds = _rVal.Seconds;
|
||||
aTimePart.HundredthSeconds = _rVal.HundredthSeconds;
|
||||
aTimePart.NanoSeconds = _rVal.NanoSeconds;
|
||||
|
||||
return ((double)nTime) + toDouble(aTimePart);
|
||||
}
|
||||
@@ -325,12 +355,12 @@ namespace dbtools
|
||||
Time DBTypeConversion::toTime(double dVal)
|
||||
{
|
||||
sal_Int32 nDays = (sal_Int32)dVal;
|
||||
sal_Int32 nMS = sal_Int32((dVal - (double)nDays) * fMilliSecondsPerDay + 0.5);
|
||||
sal_Int32 nNS = sal_Int32((dVal - (double)nDays) * fNanoSecondsPerDay + 0.5);
|
||||
|
||||
sal_Int16 nSign;
|
||||
if ( nMS < 0 )
|
||||
if ( nNS < 0 )
|
||||
{
|
||||
nMS *= -1;
|
||||
nNS *= -1;
|
||||
nSign = -1;
|
||||
}
|
||||
else
|
||||
@@ -339,24 +369,28 @@ namespace dbtools
|
||||
Time xRet;
|
||||
// normalize time
|
||||
// we have to sal_Int32 here because otherwise we get an overflow
|
||||
sal_Int32 nHundredthSeconds = nMS/10;
|
||||
sal_Int32 nSeconds = nHundredthSeconds / 100;
|
||||
sal_Int32 nMinutes = nSeconds / 60;
|
||||
sal_Int32 nNanoSeconds = nNS;
|
||||
sal_Int32 nSeconds = nNanoSeconds / nanoSecInSec;
|
||||
sal_Int32 nMinutes = nSeconds / secInMin;
|
||||
|
||||
xRet.HundredthSeconds = (sal_uInt16)(nHundredthSeconds % 100);
|
||||
xRet.Seconds = (sal_uInt16)(nSeconds % 60);
|
||||
xRet.Hours = (sal_uInt16)(nMinutes / 60);
|
||||
xRet.Minutes = (sal_uInt16)(nMinutes % 60);
|
||||
xRet.NanoSeconds = nNanoSeconds % nanoSecInSec;
|
||||
xRet.Seconds = nSeconds % secInMin;
|
||||
xRet.Hours = nMinutes / minInHour;
|
||||
xRet.Minutes = nMinutes % minInHour;
|
||||
|
||||
// assemble time
|
||||
sal_Int32 nTime = (sal_Int32)(xRet.HundredthSeconds + (xRet.Seconds*100) + (xRet.Minutes*10000) + (xRet.Hours*1000000)) * nSign;
|
||||
sal_Int64 nTime = nSign *
|
||||
(xRet.NanoSeconds +
|
||||
xRet.Seconds * secMask +
|
||||
xRet.Minutes * minMask +
|
||||
xRet.Hours * hourMask);
|
||||
|
||||
if(nTime < 0)
|
||||
{
|
||||
xRet.HundredthSeconds = 99;
|
||||
xRet.Minutes = 59;
|
||||
xRet.Seconds = 59;
|
||||
xRet.Hours = 23;
|
||||
xRet.NanoSeconds = nanoSecInSec-1;
|
||||
xRet.Seconds = secInMin-1;
|
||||
xRet.Minutes = minInHour-1;
|
||||
xRet.Hours = 23;
|
||||
}
|
||||
return xRet;
|
||||
}
|
||||
@@ -368,14 +402,14 @@ namespace dbtools
|
||||
|
||||
DateTime xRet;
|
||||
|
||||
xRet.Day = aDate.Day;
|
||||
xRet.Month = aDate.Month;
|
||||
xRet.Year = aDate.Year;
|
||||
xRet.Day = aDate.Day;
|
||||
xRet.Month = aDate.Month;
|
||||
xRet.Year = aDate.Year;
|
||||
|
||||
xRet.HundredthSeconds = aTime.HundredthSeconds;
|
||||
xRet.Minutes = aTime.Minutes;
|
||||
xRet.Seconds = aTime.Seconds;
|
||||
xRet.Hours = aTime.Hours;
|
||||
xRet.NanoSeconds = aTime.NanoSeconds;
|
||||
xRet.Minutes = aTime.Minutes;
|
||||
xRet.Seconds = aTime.Seconds;
|
||||
xRet.Hours = aTime.Hours;
|
||||
|
||||
|
||||
return xRet;
|
||||
@@ -415,7 +449,8 @@ namespace dbtools
|
||||
if ( -1 != nSeparation )
|
||||
aTime = toTime( _sSQLString.copy( nSeparation ) );
|
||||
|
||||
return DateTime(aTime.HundredthSeconds,aTime.Seconds,aTime.Minutes,aTime.Hours,aDate.Day,aDate.Month,aDate.Year);
|
||||
return DateTime(aTime.NanoSeconds, aTime.Seconds, aTime.Minutes, aTime.Hours,
|
||||
aDate.Day, aDate.Month, aDate.Year);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -426,8 +461,8 @@ namespace dbtools
|
||||
sal_Int32 nIndex = 0;
|
||||
sal_uInt16 nHour = 0,
|
||||
nMinute = 0,
|
||||
nSecond = 0,
|
||||
nHundredthSeconds = 0;
|
||||
nSecond = 0;
|
||||
sal_uInt32 nNanoSeconds = 0;
|
||||
nHour = (sal_uInt16)_sSQLString.getToken(0,sTimeSep,nIndex).toInt32();
|
||||
if(nIndex != -1)
|
||||
{
|
||||
@@ -437,17 +472,10 @@ namespace dbtools
|
||||
nSecond = (sal_uInt16)_sSQLString.getToken(0,sTimeSep,nIndex).toInt32();
|
||||
nIndex = 0;
|
||||
OUString sNano(_sSQLString.getToken(1,'.',nIndex));
|
||||
if ( !sNano.isEmpty() )
|
||||
{
|
||||
// our time struct only supports hundredth seconds
|
||||
sNano = sNano.copy(0,::std::min<sal_Int32>(sNano.getLength(),2));
|
||||
const static OUString s_Zeros("00");
|
||||
sNano += s_Zeros.copy(0,s_Zeros.getLength() - sNano.getLength());
|
||||
nHundredthSeconds = static_cast<sal_uInt16>(sNano.toInt32());
|
||||
}
|
||||
nNanoSeconds = sNano.toInt32();
|
||||
}
|
||||
}
|
||||
return Time(nHundredthSeconds,nSecond,nMinute,nHour);
|
||||
return Time(nNanoSeconds, nSecond, nMinute, nHour);
|
||||
}
|
||||
|
||||
//.........................................................................
|
||||
|
||||
@@ -370,12 +370,12 @@ static void lcl_SetValue( ORowSetValue& rValue, const Reference<XSpreadsheet>& x
|
||||
{
|
||||
double fCellVal = xCell->getValue();
|
||||
double fTime = fCellVal - rtl::math::approxFloor( fCellVal );
|
||||
long nIntTime = (long)rtl::math::round( fTime * 8640000.0 );
|
||||
if ( nIntTime == 8640000 )
|
||||
nIntTime = 0; // 23:59:59.995 and above is 00:00:00.00
|
||||
sal_Int64 nIntTime = static_cast<sal_Int64>(rtl::math::round( fTime * static_cast<double>(::Time::nanoSecPerDay) ));
|
||||
if ( nIntTime == ::Time::nanoSecPerDay)
|
||||
nIntTime = 0; // 23:59:59.9999999995 and above is 00:00:00.00
|
||||
::com::sun::star::util::Time aTime;
|
||||
aTime.HundredthSeconds = (sal_uInt16)( nIntTime % 100 );
|
||||
nIntTime /= 100;
|
||||
aTime.NanoSeconds = (sal_uInt32)( nIntTime % ::Time::nanoSecPerSec );
|
||||
nIntTime /= ::Time::nanoSecPerSec;
|
||||
aTime.Seconds = (sal_uInt16)( nIntTime % 60 );
|
||||
nIntTime /= 60;
|
||||
aTime.Minutes = (sal_uInt16)( nIntTime % 60 );
|
||||
@@ -394,17 +394,17 @@ static void lcl_SetValue( ORowSetValue& rValue, const Reference<XSpreadsheet>& x
|
||||
double fDays = ::rtl::math::approxFloor( fCellVal );
|
||||
double fTime = fCellVal - fDays;
|
||||
long nIntDays = (long)fDays;
|
||||
long nIntTime = (long)::rtl::math::round( fTime * 8640000.0 );
|
||||
if ( nIntTime == 8640000 )
|
||||
sal_Int64 nIntTime = ::rtl::math::round( fTime * static_cast<double>(::Time::nanoSecPerDay) );
|
||||
if ( nIntTime == ::Time::nanoSecPerDay )
|
||||
{
|
||||
nIntTime = 0; // 23:59:59.995 and above is 00:00:00.00
|
||||
nIntTime = 0; // 23:59:59.9999999995 and above is 00:00:00.00
|
||||
++nIntDays; // (next day)
|
||||
}
|
||||
|
||||
::com::sun::star::util::DateTime aDateTime;
|
||||
|
||||
aDateTime.HundredthSeconds = (sal_uInt16)( nIntTime % 100 );
|
||||
nIntTime /= 100;
|
||||
aDateTime.NanoSeconds = (sal_uInt16)( nIntTime % ::Time::nanoSecPerSec );
|
||||
nIntTime /= ::Time::nanoSecPerSec;
|
||||
aDateTime.Seconds = (sal_uInt16)( nIntTime % 60 );
|
||||
nIntTime /= 60;
|
||||
aDateTime.Minutes = (sal_uInt16)( nIntTime % 60 );
|
||||
|
||||
@@ -108,7 +108,7 @@ void lcl_CalcJulDate(sal_Int32& _nJulianDate,sal_Int32& _nJulianTime,const com::
|
||||
aDateTime.Month++;
|
||||
}
|
||||
|
||||
_nJulianTime = ((aDateTime.Hours*3600000)+(aDateTime.Minutes*60000)+(aDateTime.Seconds*1000)+(aDateTime.HundredthSeconds*10));
|
||||
_nJulianTime = ((aDateTime.Hours*3600000)+(aDateTime.Minutes*60000)+(aDateTime.Seconds*1000)+(aDateTime.NanoSeconds/1000000));
|
||||
/* conversion factors */
|
||||
sal_uInt16 iy0;
|
||||
sal_uInt16 im0;
|
||||
|
||||
@@ -263,7 +263,7 @@ ORowSetValue OOp_CurTime::operate(const ::std::vector<ORowSetValue>& lhs) const
|
||||
return ORowSetValue();
|
||||
|
||||
Time aCurTime( Time::SYSTEM );
|
||||
return ::com::sun::star::util::Time(aCurTime.Get100Sec(),aCurTime.GetSec(),aCurTime.GetMin(),aCurTime.GetHour());
|
||||
return ::com::sun::star::util::Time(aCurTime.GetNanoSec(),aCurTime.GetSec(),aCurTime.GetMin(),aCurTime.GetHour());
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
ORowSetValue OOp_Now::operate(const ::std::vector<ORowSetValue>& lhs) const
|
||||
@@ -272,7 +272,7 @@ ORowSetValue OOp_Now::operate(const ::std::vector<ORowSetValue>& lhs) const
|
||||
return ORowSetValue();
|
||||
|
||||
DateTime aCurTime( DateTime::SYSTEM );
|
||||
return ::com::sun::star::util::DateTime(aCurTime.Get100Sec(),aCurTime.GetSec(),aCurTime.GetMin(),aCurTime.GetHour(),
|
||||
return ::com::sun::star::util::DateTime(aCurTime.GetNanoSec(),aCurTime.GetSec(),aCurTime.GetMin(),aCurTime.GetHour(),
|
||||
aCurTime.GetDay(),aCurTime.GetMonth(),aCurTime.GetYear());
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
||||
@@ -97,8 +97,8 @@ namespace comphelper { namespace log { namespace convert
|
||||
{
|
||||
char buffer[ 30 ];
|
||||
const size_t buffer_size = sizeof( buffer );
|
||||
snprintf( buffer, buffer_size, "%02i:%02i:%02i.%02i",
|
||||
(int)_rTime.Hours, (int)_rTime.Minutes, (int)_rTime.Seconds, (int)_rTime.HundredthSeconds );
|
||||
snprintf( buffer, buffer_size, "%02i:%02i:%02i.%09i",
|
||||
(int)_rTime.Hours, (int)_rTime.Minutes, (int)_rTime.Seconds, (int)_rTime.NanoSeconds );
|
||||
return OUString::createFromAscii( buffer );
|
||||
}
|
||||
|
||||
@@ -107,9 +107,9 @@ namespace comphelper { namespace log { namespace convert
|
||||
{
|
||||
char buffer[ 30 ];
|
||||
const size_t buffer_size = sizeof( buffer );
|
||||
snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%02i",
|
||||
snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%09i",
|
||||
(int)_rDateTime.Year, (int)_rDateTime.Month, (int)_rDateTime.Day,
|
||||
(int)_rDateTime.Hours, (int)_rDateTime.Minutes, (int)_rDateTime.Seconds, (int)_rDateTime.HundredthSeconds );
|
||||
(int)_rDateTime.Hours, (int)_rDateTime.Minutes, (int)_rDateTime.Seconds, (int)_rDateTime.NanoSeconds );
|
||||
return OUString::createFromAscii( buffer );
|
||||
}
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ DateTime SAL_CALL KabResultSet::getTimestamp(sal_Int32 columnIndex) throw(SQLExc
|
||||
nRet.Hours = nRevision.time().hour();
|
||||
nRet.Minutes = nRevision.time().minute();
|
||||
nRet.Seconds = nRevision.time().second();
|
||||
nRet.HundredthSeconds = nRevision.time().msec() / 10;
|
||||
nRet.NanoSeconds = nRevision.time().msec() * ::Time::nanoPerMilli;
|
||||
return nRet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace connectivity
|
||||
nRet.Hours = ptm->tm_hour;
|
||||
nRet.Minutes = ptm->tm_min;
|
||||
nRet.Seconds = ptm->tm_sec;
|
||||
nRet.HundredthSeconds = 0;
|
||||
nRet.NanoSeconds = 0;
|
||||
return nRet;
|
||||
}
|
||||
|
||||
|
||||
@@ -436,7 +436,7 @@ OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex )
|
||||
OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP,m_bWasNull,**this,&aTime,sizeof aTime);
|
||||
else
|
||||
m_bWasNull = sal_True;
|
||||
return DateTime((sal_uInt16)aTime.fraction/ODBC_FRACTION_UNITS_PER_HSECOND,aTime.second,aTime.minute,aTime.hour,aTime.day,aTime.month,aTime.year);
|
||||
return DateTime(aTime.fraction,aTime.second,aTime.minute,aTime.hour,aTime.day,aTime.month,aTime.year);
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -411,14 +411,27 @@ void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date&
|
||||
|
||||
void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& aVal ) throw(SQLException, RuntimeException)
|
||||
{
|
||||
const sal_uInt16 hundredths (aVal.HundredthSeconds);
|
||||
SQLULEN nColSize;
|
||||
if(hundredths == 0)
|
||||
if(aVal.NanoSeconds == 0)
|
||||
nColSize = 8;
|
||||
else if(hundredths % 10 == 0)
|
||||
else if(aVal.NanoSeconds % 100000000 == 0)
|
||||
nColSize = 10;
|
||||
else
|
||||
else if(aVal.NanoSeconds % 10000000 == 0)
|
||||
nColSize = 11;
|
||||
else if(aVal.NanoSeconds % 1000000 == 0)
|
||||
nColSize = 12;
|
||||
else if(aVal.NanoSeconds % 100000 == 0)
|
||||
nColSize = 13;
|
||||
else if(aVal.NanoSeconds % 10000 == 0)
|
||||
nColSize = 14;
|
||||
else if(aVal.NanoSeconds % 1000 == 0)
|
||||
nColSize = 15;
|
||||
else if(aVal.NanoSeconds % 100 == 0)
|
||||
nColSize = 16;
|
||||
else if(aVal.NanoSeconds % 10 == 0)
|
||||
nColSize = 17;
|
||||
else
|
||||
nColSize = 18;
|
||||
TIME_STRUCT x(OTools::TimeToOdbcTime(aVal));
|
||||
setScalarParameter<TIME_STRUCT&>(parameterIndex, DataType::TIME, nColSize, x);
|
||||
}
|
||||
@@ -426,20 +439,32 @@ void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time&
|
||||
|
||||
void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& aVal ) throw(SQLException, RuntimeException)
|
||||
{
|
||||
sal_uInt16 s(aVal.Seconds);
|
||||
sal_uInt16 hundredths(aVal.HundredthSeconds);
|
||||
SQLULEN nColSize;
|
||||
if(hundredths == 0)
|
||||
if(aVal.NanoSeconds == 0)
|
||||
{
|
||||
if (s == 0)
|
||||
if (aVal.Seconds == 0)
|
||||
nColSize=16;
|
||||
else
|
||||
nColSize=19;
|
||||
}
|
||||
else if(hundredths % 10 == 0)
|
||||
else if(aVal.NanoSeconds % 100000000 == 0)
|
||||
nColSize = 21;
|
||||
else
|
||||
else if(aVal.NanoSeconds % 10000000 == 0)
|
||||
nColSize = 22;
|
||||
else if(aVal.NanoSeconds % 1000000 == 0)
|
||||
nColSize = 23;
|
||||
else if(aVal.NanoSeconds % 100000 == 0)
|
||||
nColSize = 24;
|
||||
else if(aVal.NanoSeconds % 10000 == 0)
|
||||
nColSize = 25;
|
||||
else if(aVal.NanoSeconds % 1000 == 0)
|
||||
nColSize = 26;
|
||||
else if(aVal.NanoSeconds % 100 == 0)
|
||||
nColSize = 27;
|
||||
else if(aVal.NanoSeconds % 10 == 0)
|
||||
nColSize = 28;
|
||||
else
|
||||
nColSize = 29;
|
||||
|
||||
TIMESTAMP_STRUCT x(OTools::DateTimeToTimestamp(aVal));
|
||||
setScalarParameter<TIMESTAMP_STRUCT&>(parameterIndex, DataType::TIMESTAMP, nColSize, x);
|
||||
|
||||
@@ -663,7 +663,7 @@ DateTime OResultSet::impl_getTimestamp( sal_Int32 columnIndex ) throw(SQLExcepti
|
||||
TIMESTAMP_STRUCT aTime = impl_getValue< TIMESTAMP_STRUCT > ( columnIndex,
|
||||
m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP );
|
||||
|
||||
return DateTime(static_cast<sal_uInt16>(aTime.fraction/ODBC_FRACTION_UNITS_PER_HSECOND),
|
||||
return DateTime(aTime.fraction,
|
||||
aTime.second,
|
||||
aTime.minute,
|
||||
aTime.hour,
|
||||
|
||||
@@ -107,6 +107,7 @@ namespace pq_sdbc_driver
|
||||
|
||||
OUString date2String( const com::sun::star::util::Date & x )
|
||||
{
|
||||
// TODO FIXME: replace by DBTypeConversion::toDateString
|
||||
char buffer[64];
|
||||
sprintf( buffer, "%d-%02d-%02d", x.Year, x.Month, x.Day );
|
||||
return OUString::createFromAscii( buffer );
|
||||
@@ -114,6 +115,7 @@ OUString date2String( const com::sun::star::util::Date & x )
|
||||
|
||||
com::sun::star::util::Date string2Date( const OUString &date )
|
||||
{
|
||||
// TODO FIXME: replace by DBTypeConversion::toDate (if it parses the same format)
|
||||
// Format: Year-Month-Day
|
||||
com::sun::star::util::Date ret;
|
||||
|
||||
@@ -135,15 +137,17 @@ com::sun::star::util::Date string2Date( const OUString &date )
|
||||
|
||||
OUString time2String( const com::sun::star::util::Time & x )
|
||||
{
|
||||
char buffer[64];
|
||||
sprintf( buffer, "%02d:%02d:%02d.%02d", x.Hours, x.Minutes, x.Seconds, x.HundredthSeconds );
|
||||
// TODO FIXME: replace by DBTypeConversion::toTimeString
|
||||
const size_t buflen = 19;
|
||||
char buffer[buflen];
|
||||
snprintf( buffer, buflen, "%02d:%02d:%02d.%09d", x.Hours, x.Minutes, x.Seconds, x.NanoSeconds );
|
||||
return OUString::createFromAscii( buffer );
|
||||
|
||||
}
|
||||
|
||||
|
||||
com::sun::star::util::Time string2Time( const OUString & time )
|
||||
{
|
||||
// TODO FIXME: replace by DBTypeConversion::toTime
|
||||
com::sun::star::util::Time ret;
|
||||
|
||||
sal_Unicode temp[4];
|
||||
@@ -163,7 +167,8 @@ com::sun::star::util::Time string2Time( const OUString & time )
|
||||
|
||||
if( time.getLength() >9 )
|
||||
{
|
||||
ret.HundredthSeconds = (sal_Int32)rtl_ustr_toInt32( &time.getStr()[9] , 10 );
|
||||
// FIXME does not take into account shorter precision
|
||||
ret.NanoSeconds = (sal_Int32)rtl_ustr_toInt32( &time.getStr()[9] , 10 );
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -173,16 +178,18 @@ com::sun::star::util::Time string2Time( const OUString & time )
|
||||
|
||||
OUString dateTime2String( const com::sun::star::util::DateTime & x )
|
||||
{
|
||||
// TODO FIXME: replace by DBTypeConversion::toDateTimeString
|
||||
char buffer[128];
|
||||
sprintf( buffer, "%d-%02d-%02d %02d:%02d:%02d.%02d",
|
||||
sprintf( buffer, "%d-%02d-%02d %02d:%02d:%02d.%09d",
|
||||
x.Year, x.Month, x.Day,
|
||||
x.Hours, x.Minutes, x.Seconds, x.HundredthSeconds );
|
||||
x.Hours, x.Minutes, x.Seconds, x.NanoSeconds );
|
||||
return OUString::createFromAscii( buffer );
|
||||
|
||||
}
|
||||
|
||||
com::sun::star::util::DateTime string2DateTime( const OUString & dateTime )
|
||||
{
|
||||
// TODO FIXME: replace by DBTypeConversion::toDateTime (if same format)
|
||||
int space = dateTime.indexOf( ' ' );
|
||||
com::sun::star::util::DateTime ret;
|
||||
|
||||
@@ -197,7 +204,7 @@ com::sun::star::util::DateTime string2DateTime( const OUString & dateTime )
|
||||
ret.Hours = time.Hours;
|
||||
ret.Minutes = time.Minutes;
|
||||
ret.Seconds = time.Seconds;
|
||||
ret.HundredthSeconds = time.HundredthSeconds;
|
||||
ret.NanoSeconds = time.NanoSeconds;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,6 @@ namespace connectivity
|
||||
{
|
||||
class OConnection;
|
||||
|
||||
const sal_uInt32 ODBC_FRACTION_UNITS_PER_HSECOND = 10000000L;
|
||||
const sal_Int32 MAX_PUT_DATA_LENGTH = 2000;
|
||||
|
||||
class OOO_DLLPUBLIC_ODBCBASE OTools
|
||||
@@ -166,7 +165,7 @@ namespace connectivity
|
||||
aVal.hour = x.Hours;
|
||||
aVal.minute = x.Minutes;
|
||||
aVal.second = x.Seconds;
|
||||
aVal.fraction = x.HundredthSeconds * ODBC_FRACTION_UNITS_PER_HSECOND;
|
||||
aVal.fraction = x.NanoSeconds;
|
||||
return aVal;
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -85,7 +85,7 @@ SvxFieldData* SvxFieldData::Create(const uno::Reference<text::XTextContent>& xTe
|
||||
if (nFieldType != text::textfield::Type::TIME && nFieldType != text::textfield::Type::DATE)
|
||||
{
|
||||
util::DateTime aDateTime = xPropSet->getPropertyValue(UNO_TC_PROP_DATE_TIME).get<util::DateTime>();
|
||||
Time aTime(aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.HundredthSeconds);
|
||||
Time aTime(aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds);
|
||||
|
||||
sal_Bool bIsFixed = false;
|
||||
xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
|
||||
|
||||
@@ -208,7 +208,7 @@ static util::DateTime getTime( long nTime )
|
||||
|
||||
Time aTempTime( nTime );
|
||||
|
||||
aTime.HundredthSeconds = aTempTime.Get100Sec();
|
||||
aTime.NanoSeconds = aTempTime.GetNanoSec();
|
||||
aTime.Seconds = aTempTime.GetSec();
|
||||
aTime.Minutes = aTempTime.GetMin();
|
||||
aTime.Hours = aTempTime.GetHour();
|
||||
@@ -218,7 +218,7 @@ static util::DateTime getTime( long nTime )
|
||||
|
||||
inline Time setTime( util::DateTime& rDate )
|
||||
{
|
||||
return Time( rDate.Hours, rDate.Minutes, rDate.Seconds, rDate.HundredthSeconds );
|
||||
return Time( rDate.Hours, rDate.Minutes, rDate.Seconds, rDate.NanoSeconds );
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
@@ -263,14 +263,14 @@ namespace logging
|
||||
// ISO 8601
|
||||
char buffer[ 30 ];
|
||||
const size_t buffer_size = sizeof( buffer );
|
||||
snprintf( buffer, buffer_size, "%04i-%02i-%02iT%02i:%02i:%02i.%02i",
|
||||
snprintf( buffer, buffer_size, "%04i-%02i-%02iT%02i:%02i:%02i.%09i",
|
||||
(int)record.LogTime.Year,
|
||||
(int)record.LogTime.Month,
|
||||
(int)record.LogTime.Day,
|
||||
(int)record.LogTime.Hours,
|
||||
(int)record.LogTime.Minutes,
|
||||
(int)record.LogTime.Seconds,
|
||||
(int)record.LogTime.HundredthSeconds );
|
||||
(int)record.LogTime.NanoSeconds );
|
||||
aLogEntry.appendAscii( buffer );
|
||||
aLogEntry.append(comma_char);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace logging
|
||||
aTimeStamp.Hours = aDateTime.Hours;
|
||||
aTimeStamp.Minutes = aDateTime.Minutes;
|
||||
aTimeStamp.Seconds = aDateTime.Seconds;
|
||||
aTimeStamp.HundredthSeconds = ::sal::static_int_cast< sal_Int16 >( aDateTime.NanoSeconds / 10000000 );
|
||||
aTimeStamp.NanoSeconds = aDateTime.NanoSeconds;
|
||||
|
||||
return LogRecord(
|
||||
_rLoggerName,
|
||||
|
||||
@@ -129,9 +129,9 @@ namespace logging
|
||||
aLogEntry.appendAscii( buffer );
|
||||
aLogEntry.appendAscii( " " );
|
||||
|
||||
snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%02i",
|
||||
snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%09i",
|
||||
(int)_rRecord.LogTime.Year, (int)_rRecord.LogTime.Month, (int)_rRecord.LogTime.Day,
|
||||
(int)_rRecord.LogTime.Hours, (int)_rRecord.LogTime.Minutes, (int)_rRecord.LogTime.Seconds, (int)_rRecord.LogTime.HundredthSeconds );
|
||||
(int)_rRecord.LogTime.Hours, (int)_rRecord.LogTime.Minutes, (int)_rRecord.LogTime.Seconds, (int)_rRecord.LogTime.NanoSeconds );
|
||||
aLogEntry.appendAscii( buffer );
|
||||
aLogEntry.appendAscii( " " );
|
||||
|
||||
|
||||
@@ -590,7 +590,7 @@ namespace pcr
|
||||
{
|
||||
util::Time aTime;
|
||||
OSL_VERIFY( _rControlValue >>= aTime );
|
||||
aPropertyValue <<= (sal_Int32)DBTypeConversion::toINT32( aTime );
|
||||
aPropertyValue <<= DBTypeConversion::toINT64( aTime );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -726,7 +726,7 @@ namespace pcr
|
||||
case PROPERTY_ID_DEFAULT_TIME:
|
||||
case PROPERTY_ID_TIME:
|
||||
{
|
||||
sal_Int32 nTime = 0;
|
||||
sal_Int64 nTime = 0;
|
||||
OSL_VERIFY( _rPropertyValue >>= nTime );
|
||||
aControlValue <<= DBTypeConversion::toTime( nTime );
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace pcr
|
||||
}
|
||||
else
|
||||
{
|
||||
::Time aTime( aUNOTime.Hours, aUNOTime.Minutes, aUNOTime.Seconds, aUNOTime.HundredthSeconds );
|
||||
::Time aTime( aUNOTime.Hours, aUNOTime.Minutes, aUNOTime.Seconds, aUNOTime.NanoSeconds );
|
||||
getTypedControlWindow()->SetTime( aTime );
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace pcr
|
||||
if ( !getTypedControlWindow()->GetText().isEmpty() )
|
||||
{
|
||||
::Time aTime( getTypedControlWindow()->GetTime() );
|
||||
util::Time aUNOTime( aTime.Get100Sec(), aTime.GetSec(), aTime.GetMin(), aTime.GetHour() );
|
||||
util::Time aUNOTime( aTime.GetNanoSec(), aTime.GetSec(), aTime.GetMin(), aTime.GetHour() );
|
||||
aPropValue <<= aUNOTime;
|
||||
}
|
||||
return aPropValue;
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <rtl/strbuf.hxx>
|
||||
#include <tools/time.hxx>
|
||||
|
||||
// PPT ColorScheme Slots
|
||||
#define PPT_COLSCHEME (0x08000000)
|
||||
@@ -2673,11 +2674,11 @@ void ImportComment10( SvxMSDffManager& rMan, SvStream& rStCtrl, SdrPage* pPage,
|
||||
>> aDateTime.Hours
|
||||
>> aDateTime.Minutes
|
||||
>> aDateTime.Seconds
|
||||
>> aDateTime.HundredthSeconds
|
||||
>> aDateTime.NanoSeconds
|
||||
>> nPosX
|
||||
>> nPosY;
|
||||
|
||||
aDateTime.HundredthSeconds /= 10;
|
||||
aDateTime.NanoSeconds *= ::Time::nanoPerMilli;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -70,11 +70,11 @@ public class TimeValidator extends integration.forms.ControlValidator
|
||||
|
||||
private boolean isInvalidTime( com.sun.star.util.Time timeValue )
|
||||
{
|
||||
return ( timeValue.Hours == -1 ) && ( timeValue.Minutes == -1 ) && ( timeValue.Seconds == -1 ) && ( timeValue.HundredthSeconds == -1 );
|
||||
return ( timeValue.Hours == -1 ) && ( timeValue.Minutes == -1 ) && ( timeValue.Seconds == -1 ) && ( timeValue.NanoSeconds == -1 );
|
||||
}
|
||||
|
||||
private boolean isFullHour( com.sun.star.util.Time timeValue )
|
||||
{
|
||||
return ( timeValue.Minutes == 0 ) && ( timeValue.Seconds == 0 ) && ( timeValue.HundredthSeconds == 0 );
|
||||
return ( timeValue.Minutes == 0 ) && ( timeValue.Seconds == 0 ) && ( timeValue.NanoSeconds == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ sal_Bool OTimeModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
|
||||
util::Time aTime;
|
||||
if ( !( aControlValue >>= aTime ) )
|
||||
{
|
||||
sal_Int32 nAsInt(0);
|
||||
sal_Int64 nAsInt(0);
|
||||
aControlValue >>= nAsInt;
|
||||
aTime = DBTypeConversion::toTime(nAsInt);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ sal_Bool OTimeModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
|
||||
else
|
||||
{
|
||||
util::DateTime aDateTime = m_xColumn->getTimestamp();
|
||||
aDateTime.HundredthSeconds = aTime.HundredthSeconds;
|
||||
aDateTime.NanoSeconds = aTime.NanoSeconds;
|
||||
aDateTime.Seconds = aTime.Seconds;
|
||||
aDateTime.Minutes = aTime.Minutes;
|
||||
aDateTime.Hours = aTime.Hours;
|
||||
@@ -279,7 +279,7 @@ void OTimeModel::impl_translateControlValueToUNOTime( Any& _rUNOValue ) const
|
||||
_rUNOValue = getControlValue();
|
||||
if ( _rUNOValue.hasValue() )
|
||||
{
|
||||
sal_Int32 nTime = 0;
|
||||
sal_Int64 nTime = 0;
|
||||
OSL_VERIFY( _rUNOValue >>= nTime );
|
||||
if ( nTime == ::Time( 99, 99, 99 ).GetTime() )
|
||||
// "invalid time" in VCL is different from "invalid time" in UNO
|
||||
@@ -305,7 +305,7 @@ Any OTimeModel::translateExternalValueToControlValue( const Any& _rExternalValue
|
||||
{
|
||||
util::Time aTime;
|
||||
OSL_VERIFY( _rExternalValue >>= aTime );
|
||||
aControlValue <<= DBTypeConversion::toINT32( aTime );
|
||||
aControlValue <<= DBTypeConversion::toINT64( aTime );
|
||||
}
|
||||
return aControlValue;
|
||||
}
|
||||
@@ -325,8 +325,9 @@ Any OTimeModel::translateDbColumnToControlValue()
|
||||
if ( m_xColumn->wasNull() )
|
||||
m_aSaveValue.clear();
|
||||
else
|
||||
// the aggregated set expects an Int32 as value ...
|
||||
m_aSaveValue <<= DBTypeConversion::toINT32( aTime );
|
||||
// TODO FIXME: "the aggregated set expects an Int32 as value ..."
|
||||
// need to fix it for int64
|
||||
m_aSaveValue <<= DBTypeConversion::toINT64( aTime );
|
||||
|
||||
return m_aSaveValue;
|
||||
}
|
||||
|
||||
@@ -33,13 +33,14 @@
|
||||
#include <com/sun/star/util/Date.hpp>
|
||||
#include <com/sun/star/util/DateTime.hpp>
|
||||
#include <com/sun/star/util/Time.hpp>
|
||||
#include <unotools/datetime.hxx>
|
||||
|
||||
using xforms::Convert;
|
||||
using com::sun::star::uno::Any;
|
||||
using com::sun::star::uno::makeAny;
|
||||
using com::sun::star::util::Time;
|
||||
using namespace std;
|
||||
using namespace o3tl;
|
||||
using namespace utl;
|
||||
|
||||
typedef com::sun::star::util::Date UNODate;
|
||||
typedef com::sun::star::util::Time UNOTime;
|
||||
@@ -279,30 +280,7 @@ namespace
|
||||
|
||||
UNODate aDate( 1, 1, 1900 );
|
||||
|
||||
sal_Int32 nToken = 0;
|
||||
StringTokenizer aTokenizer( rString, '-' );
|
||||
while ( aTokenizer.hasNextToken() )
|
||||
{
|
||||
sal_Int32 nTokenValue = 0;
|
||||
if ( !aTokenizer.getNextToken().toInt32( nTokenValue ) )
|
||||
{
|
||||
bWellformed = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( nToken == 0 )
|
||||
aDate.Year = (sal_uInt16)nTokenValue;
|
||||
else if ( nToken == 1 )
|
||||
aDate.Month = (sal_uInt16)nTokenValue;
|
||||
else if ( nToken == 2 )
|
||||
aDate.Day = (sal_uInt16)nTokenValue;
|
||||
else
|
||||
{
|
||||
bWellformed = false;
|
||||
break;
|
||||
}
|
||||
++nToken;
|
||||
}
|
||||
bWellformed = ISO8601parseDate(rString, aDate);
|
||||
|
||||
// sanity checks
|
||||
if ( ( aDate.Year > 9999 ) || ( aDate.Month < 1 ) || ( aDate.Month > 12 ) || ( aDate.Day < 1 ) || ( aDate.Day > 31 ) )
|
||||
@@ -337,10 +315,15 @@ namespace
|
||||
lcl_appendInt32ToBuffer( rTime.Minutes, sInfo, 2 );
|
||||
sInfo.appendAscii( ":" );
|
||||
lcl_appendInt32ToBuffer( rTime.Seconds, sInfo, 2 );
|
||||
if ( rTime.HundredthSeconds )
|
||||
if ( rTime.NanoSeconds != 0 )
|
||||
{
|
||||
sInfo.appendAscii( "." );
|
||||
lcl_appendInt32ToBuffer( rTime.HundredthSeconds, sInfo, 2 );
|
||||
OSL_ENSURE(rTime.NanoSeconds < 1000000000,"NanoSeconds cannot be more than 999 999 999");
|
||||
sInfo.append('.');
|
||||
std::ostringstream ostr;
|
||||
ostr.fill('0');
|
||||
ostr.width(9);
|
||||
ostr << rTime.NanoSeconds;
|
||||
sInfo.append(OUString::createFromAscii(ostr.str().c_str()));
|
||||
}
|
||||
|
||||
return sInfo.makeStringAndClear();
|
||||
@@ -361,62 +344,7 @@ namespace
|
||||
|
||||
UNOTime aTime( 0, 0, 0, 0 );
|
||||
|
||||
OUString sString( rString );
|
||||
// see if there's a decimal separator for the seconds,
|
||||
// and if so, handle it separately
|
||||
sal_Int32 nDecimalSepPos = rString.indexOf( '.' );
|
||||
if ( nDecimalSepPos == -1 )
|
||||
// ISO 8601 allows for both a comma and a dot
|
||||
nDecimalSepPos = rString.indexOf( ',' );
|
||||
if ( nDecimalSepPos != -1 )
|
||||
{
|
||||
// handle fractional seconds
|
||||
OUString sFractional = sString.copy( nDecimalSepPos + 1 );
|
||||
if ( sFractional.getLength() > 2 )
|
||||
// our precision is HundrethSeconds - it's all a css.util.Time can hold
|
||||
sFractional = sFractional.copy( 0, 2 );
|
||||
if ( !sFractional.isEmpty() )
|
||||
{
|
||||
sal_Int32 nFractional = 0;
|
||||
if ( StringTokenizer( sFractional, 0 ).getNextToken().toInt32( nFractional ) )
|
||||
{
|
||||
aTime.HundredthSeconds = (sal_uInt16)nFractional;
|
||||
if ( nFractional < 10 )
|
||||
aTime.HundredthSeconds *= 10;
|
||||
}
|
||||
else
|
||||
bWellformed = false;
|
||||
}
|
||||
|
||||
// strip the fraction before further processing
|
||||
sString = sString.copy( 0, nDecimalSepPos );
|
||||
}
|
||||
|
||||
// split into the tokens which are separated by colon
|
||||
sal_Int32 nToken = 0;
|
||||
StringTokenizer aTokenizer( sString, ':' );
|
||||
while ( aTokenizer.hasNextToken() )
|
||||
{
|
||||
sal_Int32 nTokenValue = 0;
|
||||
if ( !aTokenizer.getNextToken().toInt32( nTokenValue ) )
|
||||
{
|
||||
bWellformed = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( nToken == 0 )
|
||||
aTime.Hours = (sal_uInt16)nTokenValue;
|
||||
else if ( nToken == 1 )
|
||||
aTime.Minutes = (sal_uInt16)nTokenValue;
|
||||
else if ( nToken == 2 )
|
||||
aTime.Seconds = (sal_uInt16)nTokenValue;
|
||||
else
|
||||
{
|
||||
bWellformed = false;
|
||||
break;
|
||||
}
|
||||
++nToken;
|
||||
}
|
||||
bWellformed = ISO8601parseTime(rString, aTime);
|
||||
|
||||
// sanity checks
|
||||
// note that Seconds == 60 denotes leap seconds. Normally, they're not allowed everywhere,
|
||||
@@ -431,7 +359,7 @@ namespace
|
||||
&& ( aTime.Hours == 24 )
|
||||
&& ( ( aTime.Minutes != 0 )
|
||||
|| ( aTime.Seconds != 0 )
|
||||
|| ( aTime.HundredthSeconds != 0 )
|
||||
|| ( aTime.NanoSeconds != 0 )
|
||||
)
|
||||
)
|
||||
bWellformed = false;
|
||||
@@ -458,7 +386,7 @@ namespace
|
||||
UNODate aDate( aDateTime.Day, aDateTime.Month, aDateTime.Year );
|
||||
OUString sDate = lcl_toXSD_UNODate_typed( aDate );
|
||||
|
||||
UNOTime aTime( aDateTime.HundredthSeconds, aDateTime.Seconds, aDateTime.Minutes, aDateTime.Hours );
|
||||
UNOTime aTime( aDateTime.NanoSeconds, aDateTime.Seconds, aDateTime.Minutes, aDateTime.Hours );
|
||||
OUString sTime = lcl_toXSD_UNOTime_typed( aTime );
|
||||
|
||||
OUStringBuffer sInfo;
|
||||
@@ -489,7 +417,7 @@ namespace
|
||||
aTime = lcl_toUNOTime( rString.copy( nDateTimeSep + 1 ) );
|
||||
}
|
||||
UNODateTime aDateTime(
|
||||
aTime.HundredthSeconds, aTime.Seconds, aTime.Minutes, aTime.Hours,
|
||||
aTime.NanoSeconds, aTime.Seconds, aTime.Minutes, aTime.Hours,
|
||||
aDate.Day, aDate.Month, aDate.Year
|
||||
);
|
||||
return makeAny( aDateTime );
|
||||
|
||||
@@ -829,7 +829,14 @@ namespace xforms
|
||||
if ( !( aTypedValue >>= aValue ) )
|
||||
return false;
|
||||
|
||||
::Time aToolsTime( aValue.Hours, aValue.Minutes, aValue.Seconds, aValue.HundredthSeconds );
|
||||
::Time aToolsTime( aValue.Hours, aValue.Minutes, aValue.Seconds, aValue.NanoSeconds );
|
||||
// no loss/rounding; IEEE 754 double-precision floating-point
|
||||
// has a mantissa of 53 bits; we need at the very most 50 bits:
|
||||
// format of aToolsTime.GetTime() is (in decimal) hhmmssnnnnnnnnn
|
||||
// and 999999999999999 = 0x38D7EA4C67FFF
|
||||
// in reality I doubt we need (much) more than
|
||||
// 240000000000000 = 0x0DA475ABF0000
|
||||
// that is 48 bits
|
||||
fValue = aToolsTime.GetTime();
|
||||
return true;
|
||||
}
|
||||
@@ -846,7 +853,7 @@ namespace xforms
|
||||
{
|
||||
Time aValue;
|
||||
OSL_VERIFY( _rValue >>= aValue );
|
||||
::Time aToolsTime( aValue.Hours, aValue.Minutes, aValue.Seconds, aValue.HundredthSeconds );
|
||||
::Time aToolsTime( aValue.Hours, aValue.Minutes, aValue.Seconds, aValue.NanoSeconds );
|
||||
_rDoubleValue = aToolsTime.GetTime();
|
||||
}
|
||||
|
||||
@@ -869,7 +876,7 @@ namespace xforms
|
||||
{
|
||||
::DateTime aToolsValue(
|
||||
::Date( _rValue.Day, _rValue.Month, _rValue.Year ),
|
||||
::Time( _rValue.Hours, _rValue.Minutes, _rValue.Seconds, _rValue.HundredthSeconds )
|
||||
::Time( _rValue.Hours, _rValue.Minutes, _rValue.Seconds, _rValue.NanoSeconds )
|
||||
);
|
||||
|
||||
double fValue = 0;
|
||||
|
||||
@@ -567,6 +567,7 @@ sal_Bool isEnabled( const OUString& sAdminTime ,
|
||||
|
||||
// We check for "isEnabled()" here only.
|
||||
// Note further: ISO8601 formated strings can be compared as strings directly!
|
||||
// FIXME: this is not true! "T1215" is the same time as "T12:15" or "T121500"
|
||||
return (
|
||||
(!bValidAdmin && !bValidUser ) ||
|
||||
( bValidAdmin && bValidUser && sAdminTime>=sUserTime)
|
||||
|
||||
@@ -70,11 +70,11 @@ public class TimeValidator extends ControlValidator
|
||||
|
||||
private boolean isInvalidTime( com.sun.star.util.Time timeValue )
|
||||
{
|
||||
return ( timeValue.Hours == -1 ) && ( timeValue.Minutes == -1 ) && ( timeValue.Seconds == -1 ) && ( timeValue.HundredthSeconds == -1 );
|
||||
return ( timeValue.Hours == -1 ) && ( timeValue.Minutes == -1 ) && ( timeValue.Seconds == -1 ) && ( timeValue.NanoSeconds == -1 );
|
||||
}
|
||||
|
||||
private boolean isFullHour( com.sun.star.util.Time timeValue )
|
||||
{
|
||||
return ( timeValue.Minutes == 0 ) && ( timeValue.Seconds == 0 ) && ( timeValue.HundredthSeconds == 0 );
|
||||
return ( timeValue.Minutes == 0 ) && ( timeValue.Seconds == 0 ) && ( timeValue.NanoSeconds == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ published struct Date
|
||||
|
||||
/** contains the year.
|
||||
*/
|
||||
unsigned short Year;
|
||||
short Year;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -28,10 +28,9 @@ module com { module sun { module star { module util {
|
||||
*/
|
||||
published struct DateTime
|
||||
{
|
||||
/** contains the hundredth seconds (0-99).
|
||||
/** contains the nanoseconds (0 - 999 999 999).
|
||||
*/
|
||||
unsigned short HundredthSeconds;
|
||||
|
||||
unsigned long NanoSeconds;
|
||||
|
||||
/** contains the seconds (0-59).
|
||||
*/
|
||||
@@ -60,7 +59,9 @@ published struct DateTime
|
||||
|
||||
/** is the year.
|
||||
*/
|
||||
unsigned short Year;
|
||||
short Year;
|
||||
|
||||
/** TODO: timezone **/
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ module com { module sun { module star { module util {
|
||||
*/
|
||||
published struct DateTimeRange
|
||||
{
|
||||
/** contains the start hundredth seconds (0-99) for the range.
|
||||
/** contains the start nanoseconds (0 - 999 999 999) for the range.
|
||||
*/
|
||||
unsigned short StartHundredthSeconds;
|
||||
unsigned long StartNanoSeconds;
|
||||
|
||||
/** contains the start seconds (0-59) for the range.
|
||||
*/
|
||||
@@ -54,11 +54,11 @@ published struct DateTimeRange
|
||||
|
||||
/** contains the start year for the range.
|
||||
*/
|
||||
unsigned short StartYear;
|
||||
short StartYear;
|
||||
|
||||
/** contains the end hundredth seconds (0-99) for the range.
|
||||
/** contains the end nanoseconds (0 - 999 999 999) for the range.
|
||||
*/
|
||||
unsigned short EndHundredthSeconds;
|
||||
unsigned long EndNanoSeconds;
|
||||
|
||||
/** contains the end seconds (0-59) for the range.
|
||||
*/
|
||||
@@ -82,8 +82,9 @@ published struct DateTimeRange
|
||||
|
||||
/** contains the end year for the range.
|
||||
*/
|
||||
unsigned short EndYear;
|
||||
short EndYear;
|
||||
|
||||
/** TODO timezones **/
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -69,9 +69,9 @@ struct Duration
|
||||
*/
|
||||
unsigned short Seconds;
|
||||
|
||||
/** contains the milliseconds.
|
||||
/** contains the nanoseconds.
|
||||
*/
|
||||
unsigned short MilliSeconds;
|
||||
unsigned long NanoSeconds;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ module com { module sun { module star { module util {
|
||||
*/
|
||||
published struct Time
|
||||
{
|
||||
/** contains the hundredth seconds (0-99).
|
||||
/** contains the nanoseconds (0 - 999 999 999).
|
||||
*/
|
||||
unsigned short HundredthSeconds;
|
||||
unsigned long NanoSeconds;
|
||||
|
||||
/** contains the seconds (0-59).
|
||||
*/
|
||||
|
||||
Binary file not shown.
@@ -482,10 +482,12 @@ writeElement( FSHelperPtr pDoc, sal_Int32 nXmlElement, const util::DateTime& rTi
|
||||
FSEND );
|
||||
|
||||
char pStr[200];
|
||||
snprintf( pStr, sizeof( pStr ), "%d-%02d-%02dT%02d:%02d:%02d.%02dZ",
|
||||
// FIXME: my guess is that precision greater than millisecond in undesirable
|
||||
// (forbidden by the standard???)
|
||||
snprintf( pStr, sizeof( pStr ), "%d-%02d-%02dT%02d:%02d:%02d.%09dZ",
|
||||
rTime.Year, rTime.Month, rTime.Day,
|
||||
rTime.Hours, rTime.Minutes, rTime.Seconds,
|
||||
rTime.HundredthSeconds );
|
||||
rTime.NanoSeconds);
|
||||
|
||||
pDoc->write( pStr );
|
||||
|
||||
|
||||
@@ -2285,11 +2285,11 @@ util::DateTime InputObjectBase::dumpFileTime( const String& rName )
|
||||
}
|
||||
// the day
|
||||
aDateTime.Day = static_cast< sal_uInt16 >( nDaysInYear + 1 );
|
||||
// number of 1/100 seconds in the day
|
||||
sal_Int64 nTimeInDay = nFileTime % sal_Int64( 360000 * 24 );
|
||||
// 1/100 seconds
|
||||
aDateTime.HundredthSeconds = static_cast< sal_uInt16 >( nTimeInDay % 100 );
|
||||
nTimeInDay /= 100;
|
||||
// number of nanoseconds in the day
|
||||
sal_Int64 nTimeInDay = nFileTime % sal_Int64( 86400000000000 );
|
||||
// nanoseconds
|
||||
aDateTime.NanoSeconds = static_cast< sal_uInt32 >( nTimeInDay % 1000000000 );
|
||||
nTimeInDay /= 1000000000;
|
||||
// seconds
|
||||
aDateTime.Seconds = static_cast< sal_uInt16 >( nTimeInDay % 60 );
|
||||
nTimeInDay /= 60;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "oox/ppt/comments.hxx"
|
||||
#include <com/sun/star/lang/IllegalArgumentException.hpp>
|
||||
#include <rtl/math.hxx>
|
||||
|
||||
|
||||
namespace oox { namespace ppt {
|
||||
@@ -37,7 +38,28 @@ void Comment::setDateTime (OUString datetime)
|
||||
datetime = datetime.getToken(1,'T');
|
||||
aDateTime.Hours = datetime.getToken(0,':').toInt32();
|
||||
aDateTime.Minutes = datetime.getToken(1,':').toInt32();
|
||||
aDateTime.HundredthSeconds = int(datetime.getToken(2,':').toDouble() + .5);
|
||||
double seconds = datetime.getToken(2,':').toDouble();
|
||||
aDateTime.Seconds = floor(seconds);
|
||||
seconds -= aDateTime.Seconds;
|
||||
aDateTime.NanoSeconds = ::rtl::math::round(seconds * 1000000000);
|
||||
const int secondsOverFlow = (aDateTime.Seconds == 60) ? 61 : 60;
|
||||
// normalise time part of aDateTime
|
||||
if (aDateTime.NanoSeconds == 1000000000)
|
||||
{
|
||||
aDateTime.NanoSeconds = 0;
|
||||
++aDateTime.Seconds;
|
||||
}
|
||||
if (aDateTime.Seconds == secondsOverFlow)
|
||||
{
|
||||
aDateTime.Seconds = 0;
|
||||
++aDateTime.Minutes;
|
||||
}
|
||||
if (aDateTime.Minutes == 60)
|
||||
{
|
||||
aDateTime.Minutes = 0;
|
||||
++aDateTime.Hours;
|
||||
}
|
||||
// if overflow goes into date, I give up
|
||||
}
|
||||
|
||||
OUString Comment::getAuthor ( const CommentAuthorList& list )
|
||||
|
||||
@@ -636,11 +636,11 @@ public class ODatabaseForm extends TestCase {
|
||||
d.Day = 26; d.Month = 1; d.Year = 2001;
|
||||
params.add(d) ;
|
||||
Time t = new Time();
|
||||
t.Hours = 1; t.HundredthSeconds = 12; t.Minutes = 25; t.Seconds = 14;
|
||||
t.Hours = 1; t.NanoSeconds = 123456789; t.Minutes = 25; t.Seconds = 14;
|
||||
params.add(t) ;
|
||||
DateTime dt = new DateTime();
|
||||
dt.Day = 26; dt.Month = 1; dt.Year = 2001; dt.Hours = 1;
|
||||
dt.HundredthSeconds = 12; dt.Minutes = 25; dt.Seconds = 14;
|
||||
dt.NanoSeconds = 123456789; dt.Minutes = 25; dt.Seconds = 14;
|
||||
params.add(dt) ;
|
||||
tEnv.addObjRelation("XParameters.ParamValues", params);
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ public class SDBCReportData implements DataSource
|
||||
str.append(' ');
|
||||
str.append(getTimeString(unoTs.Hours, unoTs.Minutes, unoTs.Seconds));
|
||||
str.append('.');
|
||||
str.append(unoTs.HundredthSeconds);
|
||||
str.append(String.format("%09d", unoTs.NanoSeconds));
|
||||
ts = java.sql.Timestamp.valueOf(str.toString());
|
||||
}
|
||||
else
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <tools/datetime.hxx>
|
||||
#include <unotools/datetime.hxx>
|
||||
#include <com/sun/star/util/DateTime.hpp>
|
||||
#include <rtl/math.hxx>
|
||||
|
||||
#define TYPE_DATE 1
|
||||
#define TYPE_TIME 2
|
||||
@@ -301,7 +302,7 @@ Any OXMLControlProperty::convertString(const ::com::sun::star::uno::Type& _rExpe
|
||||
::com::sun::star::util::Date aDate = implGetDate(nValue);
|
||||
|
||||
::com::sun::star::util::DateTime aDateTime;
|
||||
aDateTime.HundredthSeconds = aTime.HundredthSeconds;
|
||||
aDateTime.NanoSeconds = aTime.NanoSeconds;
|
||||
aDateTime.Seconds = aTime.Seconds;
|
||||
aDateTime.Minutes = aTime.Minutes;
|
||||
aDateTime.Hours = aTime.Hours;
|
||||
@@ -329,10 +330,9 @@ Any OXMLControlProperty::convertString(const ::com::sun::star::uno::Type& _rExpe
|
||||
::com::sun::star::util::Time OXMLControlProperty::implGetTime(double _nValue)
|
||||
{
|
||||
::com::sun::star::util::Time aTime;
|
||||
sal_uInt32 nIntValue = sal_Int32(_nValue * 8640000);
|
||||
nIntValue *= 8640000;
|
||||
aTime.HundredthSeconds = (sal_uInt16)( nIntValue % 100 );
|
||||
nIntValue /= 100;
|
||||
sal_uInt64 nIntValue = ::rtl::math::round(_nValue * 86400000000000.0);
|
||||
aTime.NanoSeconds = (sal_uInt16)( nIntValue % 1000000000 );
|
||||
nIntValue /= 1000000000;
|
||||
aTime.Seconds = (sal_uInt16)( nIntValue % 60 );
|
||||
nIntValue /= 60;
|
||||
aTime.Minutes = (sal_uInt16)( nIntValue % 60 );
|
||||
|
||||
@@ -88,7 +88,7 @@ static bool eqDuration(util::Duration a, util::Duration b) {
|
||||
return a.Years == b.Years && a.Months == b.Months && a.Days == b.Days
|
||||
&& a.Hours == b.Hours && a.Minutes == b.Minutes
|
||||
&& a.Seconds == b.Seconds
|
||||
&& a.MilliSeconds == b.MilliSeconds
|
||||
&& a.NanoSeconds == b.NanoSeconds
|
||||
&& a.Negative == b.Negative;
|
||||
}
|
||||
|
||||
@@ -97,9 +97,10 @@ static void doTest(util::Duration const & rid, char const*const pis,
|
||||
{
|
||||
char const*const pos((i_pos) ? i_pos : pis);
|
||||
util::Duration od;
|
||||
OUString is(OUString::createFromAscii(pis));
|
||||
OUString is(::rtl::OUString::createFromAscii(pis));
|
||||
SAL_INFO("sax.cppunit","about to convert '" << is << "'");
|
||||
bool bSuccess = Converter::convertDuration(od, is);
|
||||
SAL_INFO("sax.cppunit","" << od.Negative << " " << od.Years << "Y " << od.Months << "M " << od.Days << "D " << od.Hours << "H " << od.Minutes << "M " << od.Seconds << "S " << od.MilliSeconds << "m");
|
||||
SAL_INFO("sax.cppunit","" << (od.Negative ? "-" : "+") << " " << od.Years << "Y " << od.Months << "M " << od.Days << "D " << od.Hours << "H " << od.Minutes << "M " << od.Seconds << "S " << od.NanoSeconds << "n");
|
||||
CPPUNIT_ASSERT(bSuccess);
|
||||
CPPUNIT_ASSERT(eqDuration(rid, od));
|
||||
OUStringBuffer buf;
|
||||
@@ -113,7 +114,7 @@ static void doTestDurationF(char const*const pis)
|
||||
util::Duration od;
|
||||
bool bSuccess = Converter::convertDuration(od,
|
||||
OUString::createFromAscii(pis));
|
||||
SAL_INFO("sax.cppunit","" << od.Negative << " " << od.Years << "Y " << od.Months << "M " << od.Days << "D " << od.Hours << "H " << od.Minutes << "M " << od.Seconds << "S " << od.MilliSeconds << "H");
|
||||
SAL_INFO("sax.cppunit","" << (od.Negative ? "-" : "+") << " " << od.Years << "Y " << od.Months << "M " << od.Days << "D " << od.Hours << "H " << od.Minutes << "M " << od.Seconds << "S " << od.NanoSeconds << "n");
|
||||
CPPUNIT_ASSERT(!bSuccess);
|
||||
}
|
||||
|
||||
@@ -126,14 +127,15 @@ void ConverterTest::testDuration()
|
||||
doTest( util::Duration(false, 0, 0, 0, 52, 0, 0, 0), "PT52H" );
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 717, 0, 0), "PT717M" );
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 0, 121, 0), "PT121S" );
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 190), "PT0.19S" );
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 90), "PT0.09S" );
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 9), "PT0.009S" );
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 0, 9, 999),
|
||||
"PT9.999999999999999999999999999999S", "PT9.999S" );
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 190000000), "PT0.19S", "PT0.190000000S");
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 90000000), "PT0.09S", "PT0.090000000S" );
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 9000000), "PT0.009S", "PT0.009000000S" );
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 9), "PT0.000000009S", "PT0.000000009S" );
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 0, 9, 999999999),
|
||||
"PT9.999999999999999999999999999999S", "PT9.999999999S" );
|
||||
doTest( util::Duration(true , 0, 0, 9999, 0, 0, 0, 0), "-P9999D" );
|
||||
doTest( util::Duration(true , 7, 6, 5, 4, 3, 2, 10),
|
||||
"-P7Y6M5DT4H3M2.01S" );
|
||||
doTest( util::Duration(true , 7, 6, 5, 4, 3, 2, 10000000),
|
||||
"-P7Y6M5DT4H3M2.01S", "-P7Y6M5DT4H3M2.010000000S" );
|
||||
doTest( util::Duration(false, 0, 6, 0, 0, 3, 0, 0), "P6MT3M" );
|
||||
doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 0), "P0D" );
|
||||
doTestDurationF("1Y1M"); // invalid: no ^P
|
||||
@@ -155,7 +157,7 @@ static bool eqDateTime(util::DateTime a, util::DateTime b) {
|
||||
return a.Year == b.Year && a.Month == b.Month && a.Day == b.Day
|
||||
&& a.Hours == b.Hours && a.Minutes == b.Minutes
|
||||
&& a.Seconds == b.Seconds
|
||||
&& a.HundredthSeconds == b.HundredthSeconds;
|
||||
&& a.NanoSeconds == b.NanoSeconds;
|
||||
}
|
||||
|
||||
static void doTest(util::DateTime const & rdt, char const*const pis,
|
||||
@@ -164,8 +166,9 @@ static void doTest(util::DateTime const & rdt, char const*const pis,
|
||||
char const*const pos((i_pos) ? i_pos : pis);
|
||||
OUString is(OUString::createFromAscii(pis));
|
||||
util::DateTime odt;
|
||||
SAL_INFO("sax.cppunit","about to convert '" << is << "'");
|
||||
bool bSuccess( Converter::convertDateTime(odt, is) );
|
||||
SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << " M:" << odt.Minutes << " S:" << odt.Seconds << " H:" << odt.HundredthSeconds);
|
||||
SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << " M:" << odt.Minutes << " S:" << odt.Seconds << " nS:" << odt.NanoSeconds);
|
||||
CPPUNIT_ASSERT(bSuccess);
|
||||
CPPUNIT_ASSERT(eqDateTime(rdt, odt));
|
||||
OUStringBuffer buf;
|
||||
@@ -179,7 +182,7 @@ static void doTestDateTimeF(char const*const pis)
|
||||
util::DateTime odt;
|
||||
bool bSuccess = Converter::convertDateTime(odt,
|
||||
OUString::createFromAscii(pis));
|
||||
SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << "H M:" << odt.Minutes << " S:" << odt.Seconds << " H:" << odt.HundredthSeconds);
|
||||
SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << "H M:" << odt.Minutes << " S:" << odt.Seconds << " nS:" << odt.NanoSeconds);
|
||||
CPPUNIT_ASSERT(!bSuccess);
|
||||
}
|
||||
|
||||
@@ -201,16 +204,16 @@ void ConverterTest::testDateTime()
|
||||
doTest( util::DateTime(0, 0, 0, 0, 2, 1, 1)/*(0, 0, 12, 0, 1, 1, 1)*/,
|
||||
"0001-01-02T00:00:00+12:00", "0001-01-02T00:00:00" );
|
||||
// "0001-01-01T12:00:00" );
|
||||
doTest( util::DateTime(99, 59, 59, 23, 31, 12, 9999),
|
||||
"9999-12-31T23:59:59.99" );
|
||||
doTest( util::DateTime(99, 59, 59, 23, 31, 12, 9999),
|
||||
"9999-12-31T23:59:59.99Z", "9999-12-31T23:59:59.99" );
|
||||
doTest( util::DateTime(99, 59, 59, 23, 31, 12, 9999),
|
||||
doTest( util::DateTime(990000000, 59, 59, 23, 31, 12, 9999),
|
||||
"9999-12-31T23:59:59.99", "9999-12-31T23:59:59.990000000" );
|
||||
doTest( util::DateTime(990000000, 59, 59, 23, 31, 12, 9999),
|
||||
"9999-12-31T23:59:59.99Z", "9999-12-31T23:59:59.990000000" );
|
||||
doTest( util::DateTime(999999999, 59, 59, 23, 31, 12, 9999),
|
||||
"9999-12-31T23:59:59.9999999999999999999999999999999999999",
|
||||
"9999-12-31T23:59:59.99" );
|
||||
doTest( util::DateTime(99, 59, 59, 23, 31, 12, 9999),
|
||||
"9999-12-31T23:59:59.999999999" );
|
||||
doTest( util::DateTime(999999999, 59, 59, 23, 31, 12, 9999),
|
||||
"9999-12-31T23:59:59.9999999999999999999999999999999999999Z",
|
||||
"9999-12-31T23:59:59.99" );
|
||||
"9999-12-31T23:59:59.999999999" );
|
||||
doTest( util::DateTime(0, 0, 0, 0, 29, 2, 2000), // leap year
|
||||
"2000-02-29T00:00:00-00:00", "2000-02-29T00:00:00" );
|
||||
doTest( util::DateTime(0, 0, 0, 0, 29, 2, 1600), // leap year
|
||||
|
||||
+103
-101
@@ -29,6 +29,8 @@
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#include <rtl/math.hxx>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace com::sun::star;
|
||||
using namespace com::sun::star::uno;
|
||||
using namespace com::sun::star::util;
|
||||
@@ -43,8 +45,7 @@ static const sal_Char* gpsPT = "pt";
|
||||
static const sal_Char* gpsINCH = "in";
|
||||
static const sal_Char* gpsPC = "pc";
|
||||
|
||||
const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 11;
|
||||
const sal_Int8 XML_MAXDIGITSCOUNT_DATETIME = 6;
|
||||
const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 14;
|
||||
|
||||
/** convert string to measure using optional min and max values*/
|
||||
bool Converter::convertMeasure( sal_Int32& rValue,
|
||||
@@ -658,15 +659,15 @@ void Converter::convertDuration(OUStringBuffer& rBuffer,
|
||||
fValue *= 60;
|
||||
double fSecsValue = ::rtl::math::approxFloor (fValue);
|
||||
fValue -= fSecsValue;
|
||||
double f100SecsValue;
|
||||
if (fValue > 0.00001)
|
||||
f100SecsValue = ::rtl::math::round( fValue, XML_MAXDIGITSCOUNT_TIME - 5);
|
||||
double fNanoSecsValue;
|
||||
if (fValue > 0.00000000001)
|
||||
fNanoSecsValue = ::rtl::math::round( fValue, XML_MAXDIGITSCOUNT_TIME - 5);
|
||||
else
|
||||
f100SecsValue = 0.0;
|
||||
fNanoSecsValue = 0.0;
|
||||
|
||||
if (f100SecsValue == 1.0)
|
||||
if (fNanoSecsValue == 1.0)
|
||||
{
|
||||
f100SecsValue = 0.0;
|
||||
fNanoSecsValue = 0.0;
|
||||
fSecsValue += 1.0;
|
||||
}
|
||||
if (fSecsValue >= 60.0)
|
||||
@@ -691,15 +692,15 @@ void Converter::convertDuration(OUStringBuffer& rBuffer,
|
||||
if (fSecsValue < 10)
|
||||
rBuffer.append( sal_Unicode('0'));
|
||||
rBuffer.append( sal_Int32( fSecsValue));
|
||||
if (f100SecsValue > 0.0)
|
||||
if (fNanoSecsValue > 0.0)
|
||||
{
|
||||
OUString a100th( ::rtl::math::doubleToUString( fValue,
|
||||
OUString aNS( ::rtl::math::doubleToUString( fValue,
|
||||
rtl_math_StringFormat_F, XML_MAXDIGITSCOUNT_TIME - 5, '.',
|
||||
true));
|
||||
if ( a100th.getLength() > 2 )
|
||||
if ( aNS.getLength() > 2 )
|
||||
{
|
||||
rBuffer.append( sal_Unicode('.'));
|
||||
rBuffer.append( a100th.copy( 2 ) ); // strip 0.
|
||||
rBuffer.append( aNS.copy( 2 ) ); // strip "0."
|
||||
}
|
||||
}
|
||||
rBuffer.append( sal_Unicode('S'));
|
||||
@@ -816,12 +817,10 @@ bool Converter::convertDuration(double& rfTime,
|
||||
double fHour = nHours;
|
||||
double fMin = nMins;
|
||||
double fSec = nSecs;
|
||||
double fSec100 = 0.0;
|
||||
double fFraction = sDoubleStr.toDouble();
|
||||
fTempTime = fHour / 24;
|
||||
fTempTime += fMin / (24 * 60);
|
||||
fTempTime += fSec / (24 * 60 * 60);
|
||||
fTempTime += fSec100 / (24 * 60 * 60 * 60);
|
||||
fTempTime += fFraction / (24 * 60 * 60);
|
||||
|
||||
// negative duration?
|
||||
@@ -835,7 +834,7 @@ bool Converter::convertDuration(double& rfTime,
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
/** convert util::Duration to ISO "duration" string */
|
||||
/** convert util::Duration to ISO8601 "duration" string */
|
||||
void Converter::convertDuration(OUStringBuffer& rBuffer,
|
||||
const ::util::Duration& rDuration)
|
||||
{
|
||||
@@ -844,9 +843,9 @@ void Converter::convertDuration(OUStringBuffer& rBuffer,
|
||||
rBuffer.append(sal_Unicode('-'));
|
||||
}
|
||||
rBuffer.append(sal_Unicode('P'));
|
||||
const bool bHaveDate(static_cast<sal_Int32>(rDuration.Years)
|
||||
+static_cast<sal_Int32>(rDuration.Months)
|
||||
+static_cast<sal_Int32>(rDuration.Days));
|
||||
const bool bHaveDate(rDuration.Years != 0 ||
|
||||
rDuration.Months != 0 ||
|
||||
rDuration.Days != 0);
|
||||
if (rDuration.Years)
|
||||
{
|
||||
rBuffer.append(static_cast<sal_Int32>(rDuration.Years));
|
||||
@@ -862,10 +861,10 @@ void Converter::convertDuration(OUStringBuffer& rBuffer,
|
||||
rBuffer.append(static_cast<sal_Int32>(rDuration.Days));
|
||||
rBuffer.append(sal_Unicode('D'));
|
||||
}
|
||||
const sal_Int32 nMSecs(static_cast<sal_Int32>(rDuration.Seconds)
|
||||
+ static_cast<sal_Int32>(rDuration.MilliSeconds));
|
||||
if (static_cast<sal_Int32>(rDuration.Hours) +
|
||||
static_cast<sal_Int32>(rDuration.Minutes) + nMSecs)
|
||||
if ( rDuration.Hours != 0
|
||||
|| rDuration.Minutes != 0
|
||||
|| rDuration.Seconds != 0
|
||||
|| rDuration.NanoSeconds != 0 )
|
||||
{
|
||||
rBuffer.append(sal_Unicode('T')); // time separator
|
||||
if (rDuration.Hours)
|
||||
@@ -878,37 +877,19 @@ void Converter::convertDuration(OUStringBuffer& rBuffer,
|
||||
rBuffer.append(static_cast<sal_Int32>(rDuration.Minutes));
|
||||
rBuffer.append(sal_Unicode('M'));
|
||||
}
|
||||
if (nMSecs)
|
||||
if (rDuration.Seconds != 0 || rDuration.NanoSeconds != 0)
|
||||
{
|
||||
// seconds must not be omitted (i.e. ".42S" is not valid)
|
||||
rBuffer.append(static_cast<sal_Int32>(rDuration.Seconds));
|
||||
if (rDuration.MilliSeconds)
|
||||
if (rDuration.NanoSeconds)
|
||||
{
|
||||
rBuffer.append(sal_Unicode('.'));
|
||||
const sal_Int32 nMilliSeconds(rDuration.MilliSeconds % 1000);
|
||||
if (nMilliSeconds < 100)
|
||||
{
|
||||
rBuffer.append(sal_Unicode('0'));
|
||||
}
|
||||
if (nMilliSeconds < 10)
|
||||
{
|
||||
rBuffer.append(sal_Unicode('0'));
|
||||
}
|
||||
if (0 == (nMilliSeconds % 10))
|
||||
{
|
||||
if (0 == (nMilliSeconds % 100))
|
||||
{
|
||||
rBuffer.append(nMilliSeconds / 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
rBuffer.append(nMilliSeconds / 10);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rBuffer.append(nMilliSeconds);
|
||||
}
|
||||
OSL_ENSURE(rDuration.NanoSeconds < 1000000000,"NanoSeconds cannot be more than 999 999 999");
|
||||
rBuffer.append('.');
|
||||
std::ostringstream ostr;
|
||||
ostr.fill('0');
|
||||
ostr.width(9);
|
||||
ostr << rDuration.NanoSeconds;
|
||||
rBuffer.append(OUString::createFromAscii(ostr.str().c_str()));
|
||||
}
|
||||
rBuffer.append(sal_Unicode('S'));
|
||||
}
|
||||
@@ -928,7 +909,7 @@ readUnsignedNumber(const OUString & rString,
|
||||
sal_Int32 & io_rnPos, sal_Int32 & o_rNumber)
|
||||
{
|
||||
bool bOverflow(false);
|
||||
sal_Int32 nTemp(0);
|
||||
sal_Int64 nTemp(0);
|
||||
sal_Int32 nPos(io_rnPos);
|
||||
|
||||
while (nPos < rString.getLength())
|
||||
@@ -938,7 +919,7 @@ readUnsignedNumber(const OUString & rString,
|
||||
{
|
||||
nTemp *= 10;
|
||||
nTemp += (c - sal_Unicode('0'));
|
||||
if (nTemp >= SAL_MAX_INT16)
|
||||
if (nTemp >= SAL_MAX_INT32)
|
||||
{
|
||||
bOverflow = true;
|
||||
}
|
||||
@@ -961,6 +942,50 @@ readUnsignedNumber(const OUString & rString,
|
||||
return (bOverflow) ? R_OVERFLOW : R_SUCCESS;
|
||||
}
|
||||
|
||||
static Result
|
||||
readUnsignedNumberMaxDigits(int maxDigits,
|
||||
const ::rtl::OUString & rString, sal_Int32 & io_rnPos,
|
||||
sal_Int32 & o_rNumber)
|
||||
{
|
||||
bool bOverflow(false);
|
||||
sal_Int64 nTemp(0);
|
||||
sal_Int32 nPos(io_rnPos);
|
||||
OSL_ENSURE(maxDigits >= 0, "negative amount of digits makes no sense");
|
||||
|
||||
while (nPos < rString.getLength())
|
||||
{
|
||||
const sal_Unicode c = rString[nPos];
|
||||
if ((sal_Unicode('0') <= c) && (c <= sal_Unicode('9')))
|
||||
{
|
||||
if (maxDigits > 0)
|
||||
{
|
||||
nTemp *= 10;
|
||||
nTemp += (c - sal_Unicode('0'));
|
||||
if (nTemp >= SAL_MAX_INT32)
|
||||
{
|
||||
bOverflow = true;
|
||||
}
|
||||
--maxDigits;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
++nPos;
|
||||
}
|
||||
|
||||
if (io_rnPos == nPos) // read something?
|
||||
{
|
||||
o_rNumber = -1;
|
||||
return R_NOTHING;
|
||||
}
|
||||
|
||||
io_rnPos = nPos;
|
||||
o_rNumber = nTemp;
|
||||
return (bOverflow) ? R_OVERFLOW : R_SUCCESS;
|
||||
}
|
||||
|
||||
static bool
|
||||
readDurationT(const OUString & rString, sal_Int32 & io_rnPos)
|
||||
{
|
||||
@@ -1003,7 +1028,7 @@ readDurationComponent(const OUString & rString,
|
||||
return true;
|
||||
}
|
||||
|
||||
/** convert ISO "duration" string to util::Duration */
|
||||
/** convert ISO8601 "duration" string to util::Duration */
|
||||
bool Converter::convertDuration(util::Duration& rDuration,
|
||||
const OUString& rString)
|
||||
{
|
||||
@@ -1035,7 +1060,7 @@ bool Converter::convertDuration(util::Duration& rDuration,
|
||||
sal_Int32 nHours(0);
|
||||
sal_Int32 nMinutes(0);
|
||||
sal_Int32 nSeconds(0);
|
||||
sal_Int32 nMilliSeconds(0);
|
||||
sal_Int32 nNanoSeconds(0);
|
||||
|
||||
bTimePart = readDurationT(string, nPos);
|
||||
bSuccess = (R_SUCCESS == readUnsignedNumber(string, nPos, nTemp));
|
||||
@@ -1080,7 +1105,8 @@ bool Converter::convertDuration(util::Duration& rDuration,
|
||||
// eeek! seconds are icky.
|
||||
if ((nPos < string.getLength()) && bSuccess)
|
||||
{
|
||||
if (sal_Unicode('.') == string[nPos])
|
||||
if (string[nPos] == sal_Unicode('.') ||
|
||||
string[nPos] == sal_Unicode(','))
|
||||
{
|
||||
++nPos;
|
||||
if (-1 != nTemp)
|
||||
@@ -1088,27 +1114,15 @@ bool Converter::convertDuration(util::Duration& rDuration,
|
||||
nSeconds = nTemp;
|
||||
nTemp = -1;
|
||||
const sal_Int32 nStart(nPos);
|
||||
bSuccess =
|
||||
(R_NOTHING != readUnsignedNumber(string, nPos, nTemp));
|
||||
bSuccess = readUnsignedNumberMaxDigits(9, string, nPos, nTemp) == R_SUCCESS;
|
||||
if ((nPos < string.getLength()) && bSuccess)
|
||||
{
|
||||
if (-1 != nTemp)
|
||||
{
|
||||
nTemp = -1;
|
||||
const sal_Int32 nDigits = nPos - nStart;
|
||||
OSL_ENSURE(nDigits > 0, "bad code monkey");
|
||||
const sal_Unicode cZero('0');
|
||||
nMilliSeconds = 100 * (string[nStart] - cZero);
|
||||
if (nDigits >= 2)
|
||||
{
|
||||
nMilliSeconds += 10 *
|
||||
(string[nStart+1] - cZero);
|
||||
if (nDigits >= 3)
|
||||
{
|
||||
nMilliSeconds += (string[nStart+2] - cZero);
|
||||
}
|
||||
}
|
||||
|
||||
const sal_Int32 nDigits = std::min<sal_Int32>(nPos - nStart, 9);
|
||||
OSL_ENSURE(nDigits > 0, "bad code monkey: negative digits");
|
||||
nNanoSeconds=static_cast<double>(nTemp)*(1000000000.0/pow(10.0,nDigits));
|
||||
nTemp=-1;
|
||||
if (sal_Unicode('S') == string[nPos])
|
||||
{
|
||||
++nPos;
|
||||
@@ -1164,7 +1178,7 @@ bool Converter::convertDuration(util::Duration& rDuration,
|
||||
rDuration.Hours = static_cast<sal_Int16>(nHours);
|
||||
rDuration.Minutes = static_cast<sal_Int16>(nMinutes);
|
||||
rDuration.Seconds = static_cast<sal_Int16>(nSeconds);
|
||||
rDuration.MilliSeconds = static_cast<sal_Int16>(nMilliSeconds);
|
||||
rDuration.NanoSeconds = static_cast<sal_Int32>(nNanoSeconds);
|
||||
}
|
||||
|
||||
return bSuccess;
|
||||
@@ -1232,13 +1246,14 @@ void Converter::convertDateTime(
|
||||
i_rBuffer.append(zero);
|
||||
}
|
||||
i_rBuffer.append( static_cast<sal_Int32>(i_rDateTime.Seconds) );
|
||||
if( i_rDateTime.HundredthSeconds > 0 ) {
|
||||
if( i_rDateTime.NanoSeconds > 0 ) {
|
||||
OSL_ENSURE(i_rDateTime.NanoSeconds < 1000000000,"NanoSeconds cannot be more than 999 999 999");
|
||||
i_rBuffer.append(dot);
|
||||
if( i_rDateTime.HundredthSeconds < 10 ) {
|
||||
i_rBuffer.append(zero);
|
||||
}
|
||||
i_rBuffer.append(
|
||||
static_cast<sal_Int32>(i_rDateTime.HundredthSeconds) );
|
||||
std::ostringstream ostr;
|
||||
ostr.fill('0');
|
||||
ostr.width(9);
|
||||
ostr << i_rDateTime.NanoSeconds;
|
||||
i_rBuffer.append(OUString::createFromAscii(ostr.str().c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1259,7 +1274,7 @@ bool Converter::convertDateTime( util::DateTime& rDateTime,
|
||||
rDateTime.Hours = 0;
|
||||
rDateTime.Minutes = 0;
|
||||
rDateTime.Seconds = 0;
|
||||
rDateTime.HundredthSeconds = 0;
|
||||
rDateTime.NanoSeconds = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1381,7 +1396,7 @@ bool Converter::convertDateOrDateTime(
|
||||
sal_Int32 nHours(0);
|
||||
sal_Int32 nMinutes(0);
|
||||
sal_Int32 nSeconds(0);
|
||||
sal_Int32 nMilliSeconds(0);
|
||||
sal_Int32 nNanoSeconds(0);
|
||||
if (bSuccess && bHaveTime)
|
||||
{
|
||||
{
|
||||
@@ -1419,37 +1434,26 @@ bool Converter::convertDateOrDateTime(
|
||||
bSuccess &= (0 <= nSeconds) && (nSeconds < 60);
|
||||
}
|
||||
if (bSuccess && (nPos < string.getLength()) &&
|
||||
(sal_Unicode('.') == string[nPos])) // fraction separator
|
||||
(sal_Unicode('.') == string[nPos] || sal_Unicode(',') == string[nPos])) // fraction separator
|
||||
{
|
||||
++nPos;
|
||||
const sal_Int32 nStart(nPos);
|
||||
sal_Int32 nTemp(0);
|
||||
if (R_NOTHING == readUnsignedNumber(string, nPos, nTemp))
|
||||
if (R_NOTHING == readUnsignedNumberMaxDigits(9, string, nPos, nTemp))
|
||||
{
|
||||
bSuccess = false;
|
||||
}
|
||||
if (bSuccess)
|
||||
{
|
||||
// cannot use nTemp because of possible leading zeros
|
||||
// and possible overflow => read digits directly
|
||||
const sal_Int32 nDigits(nPos - nStart);
|
||||
const sal_Int32 nDigits = std::min<sal_Int32>(nPos - nStart, 9);
|
||||
OSL_ENSURE(nDigits > 0, "bad code monkey");
|
||||
const sal_Unicode cZero('0');
|
||||
nMilliSeconds = 100 * (string[nStart] - cZero);
|
||||
if (nDigits >= 2)
|
||||
{
|
||||
nMilliSeconds += 10 * (string[nStart+1] - cZero);
|
||||
if (nDigits >= 3)
|
||||
{
|
||||
nMilliSeconds += (string[nStart+2] - cZero);
|
||||
}
|
||||
}
|
||||
nNanoSeconds=static_cast<double>(nTemp)*(1000000000.0/pow(10.0,nDigits));
|
||||
}
|
||||
}
|
||||
|
||||
if (bSuccess && (nHours == 24))
|
||||
{
|
||||
if (!((0 == nMinutes) && (0 == nSeconds) && (0 == nMilliSeconds)))
|
||||
if (!((0 == nMinutes) && (0 == nSeconds) && (0 == nNanoSeconds)))
|
||||
{
|
||||
bSuccess = false; // only 24:00:00 is valid
|
||||
}
|
||||
@@ -1533,9 +1537,7 @@ bool Converter::convertDateOrDateTime(
|
||||
rDateTime.Hours = static_cast<sal_uInt16>(nHours);
|
||||
rDateTime.Minutes = static_cast<sal_uInt16>(nMinutes);
|
||||
rDateTime.Seconds = static_cast<sal_uInt16>(nSeconds);
|
||||
// util::DateTime does not support 3 decimal digits of precision!
|
||||
rDateTime.HundredthSeconds =
|
||||
static_cast<sal_uInt16>(nMilliSeconds / 10);
|
||||
rDateTime.NanoSeconds = static_cast<sal_uInt32>(nNanoSeconds);
|
||||
rbDateTime = true;
|
||||
}
|
||||
else
|
||||
@@ -2279,7 +2281,7 @@ bool Converter::convertAny(OUStringBuffer& rsValue,
|
||||
aTempValue.Day = aDate.Day;
|
||||
aTempValue.Month = aDate.Month;
|
||||
aTempValue.Year = aDate.Year;
|
||||
aTempValue.HundredthSeconds = 0;
|
||||
aTempValue.NanoSeconds = 0;
|
||||
aTempValue.Seconds = 0;
|
||||
aTempValue.Minutes = 0;
|
||||
aTempValue.Hours = 0;
|
||||
@@ -2294,7 +2296,7 @@ bool Converter::convertAny(OUStringBuffer& rsValue,
|
||||
aTempValue.Days = 0;
|
||||
aTempValue.Months = 0;
|
||||
aTempValue.Years = 0;
|
||||
aTempValue.MilliSeconds = aTime.HundredthSeconds * 10;
|
||||
aTempValue.NanoSeconds = aTime.NanoSeconds;
|
||||
aTempValue.Seconds = aTime.Seconds;
|
||||
aTempValue.Minutes = aTime.Minutes;
|
||||
aTempValue.Hours = aTime.Hours;
|
||||
|
||||
+4
-4
@@ -925,7 +925,7 @@ class ScChangeTrack : public utl::ConfigurationListener
|
||||
bool bInDeleteTop:1;
|
||||
bool bInPasteCut:1;
|
||||
bool bUseFixDateTime:1;
|
||||
bool bTime100thSeconds:1;
|
||||
bool bTimeNanoSeconds:1;
|
||||
|
||||
// not implemented, prevent usage
|
||||
ScChangeTrack( const ScChangeTrack& );
|
||||
@@ -1235,9 +1235,9 @@ public:
|
||||
|
||||
// If time stamps of actions of this
|
||||
// ChangeTrack and a second one are to be
|
||||
// compared including 100th seconds.
|
||||
void SetTime100thSeconds( bool bVal ) { bTime100thSeconds = bVal; }
|
||||
bool IsTime100thSeconds() const { return bTime100thSeconds; }
|
||||
// compared including nanoseconds.
|
||||
void SetTimeNanoSeconds( bool bVal ) { bTimeNanoSeconds = bVal; }
|
||||
bool IsTimeNanoSeconds() const { return bTimeNanoSeconds; }
|
||||
|
||||
void AppendCloned( ScChangeAction* pAppend );
|
||||
SC_DLLPUBLIC ScChangeTrack* Clone( ScDocument* pDocument ) const;
|
||||
|
||||
@@ -109,8 +109,10 @@ void ScDatabaseDocUtil::PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB
|
||||
NUMBERFORMAT_TIME, ScGlobal::eLnge );
|
||||
|
||||
util::Time aTime = xRow->getTime(nRowPos);
|
||||
nVal = ( aTime.Hours * 3600 + aTime.Minutes * 60 +
|
||||
aTime.Seconds + aTime.HundredthSeconds / 100.0 ) / DATE_TIME_FACTOR;
|
||||
nVal = aTime.Hours / static_cast<double>(::Time::hourPerDay) +
|
||||
aTime.Minutes / static_cast<double>(::Time::minutePerDay) +
|
||||
aTime.Seconds / static_cast<double>(::Time::secondPerDay) +
|
||||
aTime.NanoSeconds / static_cast<double>(::Time::nanoSecPerDay);
|
||||
bEmptyFlag = xRow->wasNull();
|
||||
bValue = sal_True;
|
||||
}
|
||||
@@ -125,8 +127,10 @@ void ScDatabaseDocUtil::PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB
|
||||
util::DateTime aStamp = xRow->getTimestamp(nRowPos);
|
||||
nVal = ( Date( aStamp.Day, aStamp.Month, aStamp.Year ) -
|
||||
*pFormTable->GetNullDate() ) +
|
||||
( aStamp.Hours * 3600 + aStamp.Minutes * 60 +
|
||||
aStamp.Seconds + aStamp.HundredthSeconds / 100.0 ) / DATE_TIME_FACTOR;
|
||||
aStamp.Hours / static_cast<double>(::Time::hourPerDay) +
|
||||
aStamp.Minutes / static_cast<double>(::Time::minutePerDay) +
|
||||
aStamp.Seconds / static_cast<double>(::Time::secondPerDay) +
|
||||
aStamp.NanoSeconds / static_cast<double>(::Time::nanoSecPerDay);
|
||||
bEmptyFlag = xRow->wasNull();
|
||||
bValue = sal_True;
|
||||
}
|
||||
|
||||
@@ -104,8 +104,6 @@ using ::com::sun::star::beans::XPropertySet;
|
||||
|
||||
namespace {
|
||||
|
||||
const double D_TIMEFACTOR = 86400.0;
|
||||
|
||||
/**
|
||||
* Database connection implementation for UNO database API. Note that in
|
||||
* the UNO database API, column index is 1-based, whereas the interface
|
||||
@@ -220,8 +218,10 @@ void DBConnector::getValue(long nCol, ScDPItemData &rData, short& rNumType) cons
|
||||
rNumType = NUMBERFORMAT_TIME;
|
||||
|
||||
util::Time aTime = mxRow->getTime(nCol+1);
|
||||
fValue = ( aTime.Hours * 3600 + aTime.Minutes * 60 +
|
||||
aTime.Seconds + aTime.HundredthSeconds / 100.0 ) / D_TIMEFACTOR;
|
||||
fValue = aTime.Hours / static_cast<double>(::Time::hourPerDay) +
|
||||
aTime.Minutes / static_cast<double>(::Time::minutePerDay) +
|
||||
aTime.Seconds / static_cast<double>(::Time::secondPerDay) +
|
||||
aTime.NanoSeconds / static_cast<double>(::Time::nanoSecPerDay);
|
||||
rData.SetValue(fValue);
|
||||
break;
|
||||
}
|
||||
@@ -231,8 +231,10 @@ void DBConnector::getValue(long nCol, ScDPItemData &rData, short& rNumType) cons
|
||||
|
||||
util::DateTime aStamp = mxRow->getTimestamp(nCol+1);
|
||||
fValue = ( Date( aStamp.Day, aStamp.Month, aStamp.Year ) - maNullDate ) +
|
||||
( aStamp.Hours * 3600 + aStamp.Minutes * 60 +
|
||||
aStamp.Seconds + aStamp.HundredthSeconds / 100.0 ) / D_TIMEFACTOR;
|
||||
aStamp.Hours / static_cast<double>(::Time::hourPerDay) +
|
||||
aStamp.Minutes / static_cast<double>(::Time::minutePerDay) +
|
||||
aStamp.Seconds / static_cast<double>(::Time::secondPerDay) +
|
||||
aStamp.NanoSeconds / static_cast<double>(::Time::nanoSecPerDay);
|
||||
rData.SetValue(fValue);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2232,7 +2232,7 @@ void ScChangeTrack::Init()
|
||||
bInDeleteUndo = false;
|
||||
bInPasteCut = false;
|
||||
bUseFixDateTime = false;
|
||||
bTime100thSeconds = true;
|
||||
bTimeNanoSeconds = true;
|
||||
|
||||
const SvtUserOptions& rUserOpt = SC_MOD()->GetUserOptions();
|
||||
OUStringBuffer aBuf;
|
||||
@@ -4556,7 +4556,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const
|
||||
}
|
||||
|
||||
ScChangeTrack* pClonedTrack = new ScChangeTrack( pDocument );
|
||||
pClonedTrack->SetTime100thSeconds( IsTime100thSeconds() );
|
||||
pClonedTrack->SetTimeNanoSeconds( IsTimeNanoSeconds() );
|
||||
|
||||
// clone generated actions
|
||||
::std::stack< const ScChangeAction* > aGeneratedStack;
|
||||
|
||||
@@ -138,7 +138,7 @@ void ScChangeViewSettings::AdjustDateMode( const ScDocument& rDoc )
|
||||
// all together during the gap between those two times.
|
||||
aFirstDateTime += Time( 0, 1 );
|
||||
aFirstDateTime.SetSec(0);
|
||||
aFirstDateTime.Set100Sec(0);
|
||||
aFirstDateTime.SetNanoSec(0);
|
||||
}
|
||||
}
|
||||
if ( !pLast )
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
using namespace formula;
|
||||
|
||||
#define SCdEpsilon 1.0E-7
|
||||
#define D_TIMEFACTOR static_cast<double>(::Time::secondPerDay)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Datum und Zeit
|
||||
@@ -113,10 +114,10 @@ void ScInterpreter::ScGetActTime()
|
||||
Date aActDate( Date::SYSTEM );
|
||||
long nDiff = aActDate - *(pFormatter->GetNullDate());
|
||||
Time aActTime( Time::SYSTEM );
|
||||
double nTime = ((double)aActTime.Get100Sec() / 100 +
|
||||
(double)(aActTime.GetSec() +
|
||||
(aActTime.GetMin() * 60) +
|
||||
(aActTime.GetHour() * 3600))) / DATE_TIME_FACTOR;
|
||||
double nTime = aActTime.GetHour() / static_cast<double>(::Time::hourPerDay) +
|
||||
aActTime.GetMin() / static_cast<double>(::Time::minutePerDay) +
|
||||
aActTime.GetSec() / static_cast<double>(::Time::secondPerDay) +
|
||||
aActTime.GetNanoSec() / static_cast<double>(::Time::nanoSecPerDay);
|
||||
PushDouble( (double) nDiff + nTime );
|
||||
}
|
||||
|
||||
@@ -149,8 +150,8 @@ void ScInterpreter::ScGetMin()
|
||||
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScGetMin" );
|
||||
double fTime = GetDouble();
|
||||
fTime -= ::rtl::math::approxFloor(fTime); // Datumsanteil weg
|
||||
long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) % 3600;
|
||||
PushDouble( (double) (nVal/60) );
|
||||
long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) % ::Time::secondPerHour;
|
||||
PushDouble( (double) (nVal / ::Time::secondPerMinute) );
|
||||
}
|
||||
|
||||
void ScInterpreter::ScGetSec()
|
||||
@@ -158,7 +159,7 @@ void ScInterpreter::ScGetSec()
|
||||
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScGetSec" );
|
||||
double fTime = GetDouble();
|
||||
fTime -= ::rtl::math::approxFloor(fTime); // Datumsanteil weg
|
||||
long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) % 60;
|
||||
long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) % ::Time::secondPerMinute;
|
||||
PushDouble( (double) nVal );
|
||||
}
|
||||
|
||||
@@ -167,7 +168,7 @@ void ScInterpreter::ScGetHour()
|
||||
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScGetHour" );
|
||||
double fTime = GetDouble();
|
||||
fTime -= ::rtl::math::approxFloor(fTime); // Datumsanteil weg
|
||||
long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) / 3600;
|
||||
long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) / ::Time::secondPerHour;
|
||||
PushDouble((double) nVal);
|
||||
}
|
||||
|
||||
@@ -288,7 +289,7 @@ void ScInterpreter::ScGetTime()
|
||||
double nSec = GetDouble();
|
||||
double nMin = GetDouble();
|
||||
double nHour = GetDouble();
|
||||
double fTime = fmod( (nHour * 3600) + (nMin * 60) + nSec, DATE_TIME_FACTOR) / DATE_TIME_FACTOR;
|
||||
double fTime = fmod( (nHour * ::Time::secondPerHour) + (nMin * ::Time::secondPerMinute) + nSec, DATE_TIME_FACTOR) / DATE_TIME_FACTOR;
|
||||
if (fTime < 0)
|
||||
PushIllegalArgument();
|
||||
else
|
||||
|
||||
@@ -169,7 +169,7 @@ static void lcl_AddStamp( String& rStr, const String& rName,
|
||||
{
|
||||
Date aD(rDateTime.Day, rDateTime.Month, rDateTime.Year);
|
||||
Time aT(rDateTime.Hours, rDateTime.Minutes, rDateTime.Seconds,
|
||||
rDateTime.HundredthSeconds);
|
||||
rDateTime.NanoSeconds);
|
||||
DateTime aDateTime(aD,aT);
|
||||
|
||||
String aStrDate = rLoc.getDate( aDateTime );
|
||||
|
||||
@@ -58,10 +58,10 @@ inline sal_Int32 lclIsLeapYear( sal_Int32 nYear )
|
||||
return ((nYear % 4) == 0) && (((nYear % 100) != 0) || ((nYear % 400) == 0));
|
||||
}
|
||||
|
||||
void lclSkipYearBlock( sal_Int32& ornDays, sal_uInt16& ornYear, sal_Int32 nDaysInBlock, sal_Int32 nYearsPerBlock, sal_Int32 nMaxBlocks )
|
||||
void lclSkipYearBlock( sal_Int32& ornDays, sal_Int16& ornYear, sal_Int32 nDaysInBlock, sal_Int32 nYearsPerBlock, sal_Int32 nMaxBlocks )
|
||||
{
|
||||
sal_Int32 nBlocks = ::std::min< sal_Int32 >( ornDays / nDaysInBlock, nMaxBlocks );
|
||||
ornYear = static_cast< sal_uInt16 >( ornYear + nYearsPerBlock * nBlocks );
|
||||
ornYear = static_cast< sal_Int16 >( ornYear + nYearsPerBlock * nBlocks );
|
||||
ornDays -= nBlocks * nDaysInBlock;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,10 @@ static OString lcl_DateTimeToOString( const DateTime& rDateTime )
|
||||
{
|
||||
char sBuf[ 200 ];
|
||||
snprintf( sBuf, sizeof( sBuf ),
|
||||
"%d-%02d-%02dT%02d:%02d:%02d.%02dZ",
|
||||
"%d-%02d-%02dT%02d:%02d:%02d.%09dZ",
|
||||
rDateTime.GetYear(), rDateTime.GetMonth(), rDateTime.GetDay(),
|
||||
rDateTime.GetHour(), rDateTime.GetMin(), rDateTime.GetSec(),
|
||||
rDateTime.Get100Sec() );
|
||||
rDateTime.GetNanoSec() );
|
||||
return OString( sBuf );
|
||||
}
|
||||
|
||||
@@ -624,7 +624,7 @@ XclExpChTrAction::XclExpChTrAction(
|
||||
bForceInfo( false )
|
||||
{
|
||||
aDateTime.SetSec( 0 );
|
||||
aDateTime.Set100Sec( 0 );
|
||||
aDateTime.SetNanoSec( 0 );
|
||||
}
|
||||
|
||||
XclExpChTrAction::~XclExpChTrAction()
|
||||
|
||||
@@ -128,7 +128,7 @@ void XclImpChangeTrack::ReadDateTime( DateTime& rDateTime )
|
||||
rDateTime.SetHour( nHour );
|
||||
rDateTime.SetMin( nMin );
|
||||
rDateTime.SetSec( nSec );
|
||||
rDateTime.Set100Sec( 0 );
|
||||
rDateTime.SetNanoSec( 0 );
|
||||
}
|
||||
|
||||
sal_Bool XclImpChangeTrack::CheckRecord( sal_uInt16 nOpCode )
|
||||
|
||||
@@ -428,13 +428,13 @@ void ScXMLChangeTrackingImportHelper::EndChangeAction()
|
||||
void ScXMLChangeTrackingImportHelper::ConvertInfo(const ScMyActionInfo& aInfo, String& rUser, DateTime& aDateTime)
|
||||
{
|
||||
Date aDate(aInfo.aDateTime.Day, aInfo.aDateTime.Month, aInfo.aDateTime.Year);
|
||||
Time aTime(aInfo.aDateTime.Hours, aInfo.aDateTime.Minutes, aInfo.aDateTime.Seconds, aInfo.aDateTime.HundredthSeconds);
|
||||
Time aTime(aInfo.aDateTime.Hours, aInfo.aDateTime.Minutes, aInfo.aDateTime.Seconds, aInfo.aDateTime.NanoSeconds);
|
||||
aDateTime.SetDate( aDate.GetDate() );
|
||||
aDateTime.SetTime( aTime.GetTime() );
|
||||
|
||||
// old files didn't store 100th seconds, enable again
|
||||
if ( aInfo.aDateTime.HundredthSeconds )
|
||||
pTrack->SetTime100thSeconds( true );
|
||||
// old files didn't store nanoseconds, enable again
|
||||
if ( aInfo.aDateTime.NanoSeconds )
|
||||
pTrack->SetTimeNanoSeconds( true );
|
||||
|
||||
const std::set<OUString>& rUsers = pTrack->GetUserCollection();
|
||||
std::set<OUString>::const_iterator it = rUsers.find(aInfo.sUser);
|
||||
@@ -795,8 +795,8 @@ void ScXMLChangeTrackingImportHelper::CreateChangeTrack(ScDocument* pTempDoc)
|
||||
if (pDoc)
|
||||
{
|
||||
pTrack = new ScChangeTrack(pDoc, aUsers);
|
||||
// old files didn't store 100th seconds, disable until encountered
|
||||
pTrack->SetTime100thSeconds( false );
|
||||
// old files didn't store nanoseconds, disable until encountered
|
||||
pTrack->SetTimeNanoSeconds( false );
|
||||
|
||||
ScMyActions::iterator aItr(aActions.begin());
|
||||
ScMyActions::iterator aEndItr(aActions.end());
|
||||
|
||||
@@ -349,13 +349,13 @@ void ScXMLConverter::ConvertCoreToAPIDateTime(const DateTime& aDateTime, util::D
|
||||
rDateTime.Hours = aDateTime.GetHour();
|
||||
rDateTime.Minutes = aDateTime.GetMin();
|
||||
rDateTime.Seconds = aDateTime.GetSec();
|
||||
rDateTime.HundredthSeconds = aDateTime.Get100Sec();
|
||||
rDateTime.NanoSeconds = aDateTime.GetNanoSec();
|
||||
}
|
||||
|
||||
void ScXMLConverter::ConvertAPIToCoreDateTime(const util::DateTime& aDateTime, DateTime& rDateTime)
|
||||
{
|
||||
Date aDate(aDateTime.Day, aDateTime.Month, aDateTime.Year);
|
||||
Time aTime(aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.HundredthSeconds);
|
||||
Time aTime(aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds);
|
||||
DateTime aTempDateTime (aDate, aTime);
|
||||
rDateTime = aTempDateTime;
|
||||
}
|
||||
|
||||
@@ -743,7 +743,7 @@ static inline sal_Bool lcl_Equal( const ScChangeAction* pA, const ScChangeAction
|
||||
pA->GetType() == pB->GetType() &&
|
||||
pA->GetUser() == pB->GetUser() &&
|
||||
(bIgnore100Sec ?
|
||||
pA->GetDateTimeUTC().IsEqualIgnore100Sec( pB->GetDateTimeUTC() ) :
|
||||
pA->GetDateTimeUTC().IsEqualIgnoreNanoSec( pB->GetDateTimeUTC() ) :
|
||||
pA->GetDateTimeUTC() == pB->GetDateTimeUTC());
|
||||
// State nicht vergleichen, falls eine alte Aenderung akzeptiert wurde
|
||||
}
|
||||
@@ -762,7 +762,7 @@ static bool lcl_FindAction( ScDocument* pDoc, const ScChangeAction* pAction, ScD
|
||||
if ( pAction->GetType() == pA->GetType() &&
|
||||
pAction->GetUser() == pA->GetUser() &&
|
||||
(bIgnore100Sec ?
|
||||
pAction->GetDateTimeUTC().IsEqualIgnore100Sec( pA->GetDateTimeUTC() ) :
|
||||
pAction->GetDateTimeUTC().IsEqualIgnoreNanoSec( pA->GetDateTimeUTC() ) :
|
||||
pAction->GetDateTimeUTC() == pA->GetDateTimeUTC() ) &&
|
||||
pAction->GetBigRange() == pA->GetBigRange() )
|
||||
{
|
||||
@@ -807,9 +807,9 @@ void ScDocShell::MergeDocument( ScDocument& rOtherDoc, bool bShared, bool bCheck
|
||||
}
|
||||
}
|
||||
|
||||
// include 100th seconds in compare?
|
||||
sal_Bool bIgnore100Sec = !pSourceTrack->IsTime100thSeconds() ||
|
||||
!pThisTrack->IsTime100thSeconds();
|
||||
// include Nano seconds in compare?
|
||||
sal_Bool bIgnore100Sec = !pSourceTrack->IsTimeNanoSeconds() ||
|
||||
!pThisTrack->IsTimeNanoSeconds();
|
||||
|
||||
// gemeinsame Ausgangsposition suchen
|
||||
sal_uLong nFirstNewNumber = 0;
|
||||
@@ -1189,7 +1189,7 @@ bool ScDocShell::MergeSharedDocument( ScDocShell* pSharedDocShell )
|
||||
aDocument.SetChangeViewSettings( aChangeViewSet );
|
||||
|
||||
// find first merge action in this document
|
||||
sal_Bool bIgnore100Sec = !pThisTrack->IsTime100thSeconds() || !pSharedTrack->IsTime100thSeconds();
|
||||
sal_Bool bIgnore100Sec = !pThisTrack->IsTimeNanoSeconds() || !pSharedTrack->IsTimeNanoSeconds();
|
||||
ScChangeAction* pThisAction = pThisTrack->GetFirst();
|
||||
ScChangeAction* pSharedAction = pSharedTrack->GetFirst();
|
||||
while ( lcl_Equal( pThisAction, pSharedAction, bIgnore100Sec ) )
|
||||
|
||||
@@ -209,7 +209,7 @@ void ScShareDocumentDlg::UpdateView()
|
||||
|
||||
util::DateTime uDT(xDocProps->getModificationDate());
|
||||
Date d(uDT.Day, uDT.Month, uDT.Year);
|
||||
Time t(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
|
||||
Time t(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
||||
DateTime aDateTime(d,t);
|
||||
|
||||
aString += ScGlobal::pLocaleData->getDate( aDateTime );
|
||||
|
||||
@@ -950,7 +950,7 @@ void ScEditFieldObj::setPropertyValueDateTime(const OUString& rName, const uno::
|
||||
else if (rName == SC_UNONAME_DATETIME)
|
||||
{
|
||||
maDateTime = rVal.get<util::DateTime>();
|
||||
Time aTime(maDateTime.Hours, maDateTime.Minutes, maDateTime.Seconds, maDateTime.HundredthSeconds);
|
||||
Time aTime(maDateTime.Hours, maDateTime.Minutes, maDateTime.Seconds, maDateTime.NanoSeconds);
|
||||
p->SetFixTime(aTime);
|
||||
}
|
||||
else if (rName == SC_UNONAME_NUMFMT)
|
||||
@@ -1012,7 +1012,7 @@ uno::Any ScEditFieldObj::getPropertyValueDateTime(const OUString& rName)
|
||||
maDateTime.Hours = 0;
|
||||
maDateTime.Minutes = 0;
|
||||
maDateTime.Seconds = 0;
|
||||
maDateTime.HundredthSeconds = 0;
|
||||
maDateTime.NanoSeconds = 0;
|
||||
return uno::makeAny(maDateTime);
|
||||
}
|
||||
|
||||
@@ -1056,7 +1056,7 @@ uno::Any ScEditFieldObj::getPropertyValueDateTime(const OUString& rName)
|
||||
maDateTime.Hours = aT.GetHour();
|
||||
maDateTime.Minutes = aT.GetMin();
|
||||
maDateTime.Seconds = aT.GetSec();
|
||||
maDateTime.HundredthSeconds = aT.Get100Sec();
|
||||
maDateTime.NanoSeconds = aT.GetNanoSec();
|
||||
return uno::makeAny(maDateTime);
|
||||
}
|
||||
|
||||
|
||||
@@ -250,10 +250,10 @@ void ScViewFunc::InsertCurrentTime(short nCellFmt, const OUString& rUndoStr)
|
||||
Date aActDate( Date::SYSTEM );
|
||||
double fDate = aActDate - *pFormatter->GetNullDate();
|
||||
Time aActTime( Time::SYSTEM );
|
||||
double fTime =
|
||||
aActTime.Get100Sec() / 100.0 + aActTime.GetSec() +
|
||||
(aActTime.GetMin() * 60.0) + (aActTime.GetHour() * 3600.0);
|
||||
fTime /= DATE_TIME_FACTOR;
|
||||
double fTime = aActTime.GetHour() / static_cast<double>(::Time::hourPerDay) +
|
||||
aActTime.GetMin() / static_cast<double>(::Time::minutePerDay) +
|
||||
aActTime.GetSec() / static_cast<double>(::Time::secondPerDay) +
|
||||
aActTime.GetNanoSec() / static_cast<double>(::Time::nanoSecPerDay);
|
||||
pUndoMgr->EnterListAction(rUndoStr, rUndoStr);
|
||||
pDocSh->GetDocFunc().SetValueCell(aCurPos, fDate+fTime, true);
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ def hasChanged( oldDate, newDate ):
|
||||
newDate.Hours > oldDate.Hours or \
|
||||
newDate.Minutes > oldDate.Minutes or \
|
||||
newDate.Seconds > oldDate.Seconds or \
|
||||
newDate.HundredthSeconds > oldDate.HundredthSeconds
|
||||
newDate.NanoSeconds > oldDate.NanoSeconds
|
||||
|
||||
def ensureSourceState( code ):
|
||||
if code.endswith(b"\n"):
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <sfx2/docinf.hxx>
|
||||
#include <oox/export/utils.hxx>
|
||||
#include <oox/ole/olehelper.hxx>
|
||||
#include <rtl/math.hxx>
|
||||
|
||||
using namespace com::sun::star;
|
||||
using namespace ::com::sun::star::uno;
|
||||
@@ -1124,7 +1125,7 @@ void ImplExportComments( uno::Reference< drawing::XDrawPage > xPage, SvMemoryStr
|
||||
if ( !sInitials.isEmpty() )
|
||||
PPTWriter::WriteCString( rBinaryTagData10Atom, sInitials, 2 );
|
||||
|
||||
sal_Int16 nMilliSeconds = aDateTime.HundredthSeconds * 10;
|
||||
sal_Int16 nMilliSeconds = static_cast<sal_Int16>(::rtl::math::round(static_cast<double>(aDateTime.NanoSeconds) / 1000000000.0));
|
||||
EscherExAtom aCommentAtom10( rBinaryTagData10Atom, EPP_CommentAtom10 );
|
||||
rBinaryTagData10Atom << nIndex++
|
||||
<< aDateTime.Year
|
||||
|
||||
@@ -1314,7 +1314,7 @@ bool PowerPointExport::WriteComments( sal_uInt32 nPageNum )
|
||||
sal_Int32 nId = GetAuthorIdAndLastIndex ( xAnnotation->getAuthor(), nLastIndex );
|
||||
char cDateTime[32];
|
||||
|
||||
snprintf(cDateTime, 31, "%02d-%02d-%02dT%02d:%02d:%02d.%03d", aDateTime.Year, aDateTime.Month, aDateTime.Day, aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.HundredthSeconds);
|
||||
snprintf(cDateTime, 31, "%02d-%02d-%02dT%02d:%02d:%02d.%09d", aDateTime.Year, aDateTime.Month, aDateTime.Day, aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds);
|
||||
|
||||
pFS->startElementNS( XML_p, XML_cm,
|
||||
XML_authorId, I32S( nId ),
|
||||
|
||||
@@ -165,7 +165,7 @@ OUString getAnnotationDateTimeString( const Reference< XAnnotation >& xAnnotatio
|
||||
else if (aDate.IsValidAndGregorian() )
|
||||
sRet = rLocalData.getDate(aDate);
|
||||
|
||||
Time aTime( aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.HundredthSeconds );
|
||||
Time aTime( aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds );
|
||||
if(aTime.GetTime() != 0)
|
||||
sRet = sRet + " " + rLocalData.getTime( aTime,false );
|
||||
}
|
||||
|
||||
@@ -1062,7 +1062,7 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
{
|
||||
Time *const pTime = m_FrameList[i].second;
|
||||
long nTime = pTime->Get100Sec();
|
||||
long nTime = pTime->GetNanoSec();
|
||||
nTime += pTime->GetSec() * 100;
|
||||
|
||||
BitmapEx const*const pBitmapEx = m_FrameList[i].first;
|
||||
|
||||
@@ -349,7 +349,7 @@ public class DocumentProperties
|
||||
dur.Hours = 777;
|
||||
dur.Minutes = 666;
|
||||
dur.Seconds = 555;
|
||||
dur.MilliSeconds = 444;
|
||||
dur.NanoSeconds = 444444444;
|
||||
|
||||
udpc.addProperty("Frobnicate", PropertyAttribute.REMOVABLE, b);
|
||||
udpc.addProperty("FrobDuration", PropertyAttribute.REMOVABLE, dur);
|
||||
@@ -426,7 +426,7 @@ public class DocumentProperties
|
||||
// this is now a Duration!
|
||||
Duration t_dur = new Duration(false, (short)0, (short)0, (short)0,
|
||||
t.Hours, t.Minutes, t.Seconds,
|
||||
(short)(10 * t.HundredthSeconds));
|
||||
t.NanoSeconds);
|
||||
assertTrue("UserDefined time", eqDuration(t_dur, (Duration)
|
||||
udps.getPropertyValue("FrobDuration2")));
|
||||
assertTrue("UserDefined date", eqDate(date, (Date)
|
||||
@@ -476,7 +476,7 @@ public class DocumentProperties
|
||||
return a.Year == b.Year && a.Month == b.Month && a.Day == b.Day
|
||||
&& a.Hours == b.Hours && a.Minutes == b.Minutes
|
||||
&& a.Seconds == b.Seconds
|
||||
&& a.HundredthSeconds == b.HundredthSeconds;
|
||||
&& a.NanoSeconds == b.NanoSeconds;
|
||||
}
|
||||
|
||||
boolean eqDate(Date a, Date b) {
|
||||
@@ -486,14 +486,14 @@ public class DocumentProperties
|
||||
boolean eqTime(Time a, Time b) {
|
||||
return a.Hours == b.Hours && a.Minutes == b.Minutes
|
||||
&& a.Seconds == b.Seconds
|
||||
&& a.HundredthSeconds == b.HundredthSeconds;
|
||||
&& a.NanoSeconds == b.NanoSeconds;
|
||||
}
|
||||
|
||||
boolean eqDuration(Duration a, Duration b) {
|
||||
return a.Years == b.Years && a.Months == b.Months && a.Days == b.Days
|
||||
&& a.Hours == b.Hours && a.Minutes == b.Minutes
|
||||
&& a.Seconds == b.Seconds
|
||||
&& a.MilliSeconds == b.MilliSeconds
|
||||
&& a.NanoSeconds == b.NanoSeconds
|
||||
&& a.Negative == b.Negative;
|
||||
}
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ void SfxPickList::Notify( SfxBroadcaster&, const SfxHint& rHint )
|
||||
xDocProps->setAuthor( SvtUserOptions().GetFullName() );
|
||||
::DateTime now( ::DateTime::SYSTEM );
|
||||
xDocProps->setCreationDate( util::DateTime(
|
||||
now.Get100Sec(), now.GetSec(), now.GetMin(),
|
||||
now.GetNanoSec(), now.GetSec(), now.GetMin(),
|
||||
now.GetHour(), now.GetDay(), now.GetMonth(),
|
||||
now.GetYear() ) );
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ void SfxFrameHTMLWriter::Out_DocInfo( SvStream& rStrm, const String& rBaseURL,
|
||||
// created
|
||||
::util::DateTime uDT = i_xDocProps->getCreationDate();
|
||||
Date aD(uDT.Day, uDT.Month, uDT.Year);
|
||||
Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
|
||||
Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
||||
String sOut = OUString::number(aD.GetDate());
|
||||
sOut += ';';
|
||||
sOut += OUString::number(aT.GetTime());
|
||||
@@ -188,7 +188,7 @@ void SfxFrameHTMLWriter::Out_DocInfo( SvStream& rStrm, const String& rBaseURL,
|
||||
// changed
|
||||
uDT = i_xDocProps->getModificationDate();
|
||||
Date aD2(uDT.Day, uDT.Month, uDT.Year);
|
||||
Time aT2(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
|
||||
Time aT2(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
||||
sOut = OUString::number(aD2.GetDate());
|
||||
sOut += ';';
|
||||
sOut += OUString::number(aT2.GetTime());
|
||||
|
||||
@@ -99,7 +99,7 @@ bool operator==(const util::DateTime &i_rLeft, const util::DateTime &i_rRight)
|
||||
&& i_rLeft.Hours == i_rRight.Hours
|
||||
&& i_rLeft.Minutes == i_rRight.Minutes
|
||||
&& i_rLeft.Seconds == i_rRight.Seconds
|
||||
&& i_rLeft.HundredthSeconds == i_rRight.HundredthSeconds;
|
||||
&& i_rLeft.NanoSeconds == i_rRight.NanoSeconds;
|
||||
}
|
||||
|
||||
// STATIC DATA -----------------------------------------------------------
|
||||
@@ -174,7 +174,7 @@ String ConvertDateTime_Impl( const String& rName,
|
||||
const util::DateTime& uDT, const LocaleDataWrapper& rWrapper )
|
||||
{
|
||||
Date aD(uDT.Day, uDT.Month, uDT.Year);
|
||||
Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
|
||||
Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
||||
const String pDelim ( ", " );
|
||||
String aStr( rWrapper.getDate( aD ) );
|
||||
aStr += pDelim;
|
||||
@@ -352,7 +352,7 @@ void SfxDocumentInfoItem::resetUserData(const OUString & i_rAuthor)
|
||||
setAuthor(i_rAuthor);
|
||||
DateTime now( DateTime::SYSTEM );
|
||||
setCreationDate( util::DateTime(
|
||||
now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(),
|
||||
now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(),
|
||||
now.GetDay(), now.GetMonth(), now.GetYear() ) );
|
||||
setModifiedBy(OUString());
|
||||
setPrintedBy(OUString());
|
||||
@@ -798,7 +798,7 @@ IMPL_LINK_NOARG(SfxDocumentPage, DeleteHdl)
|
||||
const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
|
||||
DateTime now( DateTime::SYSTEM );
|
||||
util::DateTime uDT(
|
||||
now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(),
|
||||
now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(),
|
||||
now.GetDay(), now.GetMonth(), now.GetYear() );
|
||||
m_pCreateValFt->SetText( ConvertDateTime_Impl( aName, uDT, rLocaleWrapper ) );
|
||||
OUString aEmpty;
|
||||
@@ -1241,7 +1241,7 @@ DurationDialog_Impl::DurationDialog_Impl(
|
||||
aHourNF.SetValue(rDuration.Hours );
|
||||
aMinuteNF.SetValue(rDuration.Minutes);
|
||||
aSecondNF.SetValue(rDuration.Seconds);
|
||||
aMSecondNF.SetValue(rDuration.MilliSeconds);
|
||||
aMSecondNF.SetValue(rDuration.NanoSeconds);
|
||||
}
|
||||
|
||||
DurationDialog_Impl::~DurationDialog_Impl()
|
||||
@@ -1258,7 +1258,7 @@ util::Duration DurationDialog_Impl::GetDuration() const
|
||||
aRet.Hours = aHourNF.GetValue( );
|
||||
aRet.Minutes = aMinuteNF.GetValue();
|
||||
aRet.Seconds = aSecondNF.GetValue();
|
||||
aRet.MilliSeconds = aMSecondNF.GetValue();
|
||||
aRet.NanoSeconds = aMSecondNF.GetValue();
|
||||
return aRet;
|
||||
}
|
||||
|
||||
@@ -1752,7 +1752,7 @@ void CustomPropertiesWindow::AddLine( const OUString& sName, Any& rAny )
|
||||
else if ( rAny >>= aTmpDateTime )
|
||||
{
|
||||
pNewLine->m_aDateField.SetDate( Date( aTmpDateTime.Day, aTmpDateTime.Month, aTmpDateTime.Year ) );
|
||||
pNewLine->m_aTimeField.SetTime( Time( aTmpDateTime.Hours, aTmpDateTime.Minutes, aTmpDateTime.Seconds, aTmpDateTime.HundredthSeconds ) );
|
||||
pNewLine->m_aTimeField.SetTime( Time( aTmpDateTime.Hours, aTmpDateTime.Minutes, aTmpDateTime.Seconds, aTmpDateTime.NanoSeconds ) );
|
||||
|
||||
nType = CUSTOM_TYPE_DATETIME;
|
||||
}
|
||||
@@ -1866,7 +1866,7 @@ Sequence< beans::PropertyValue > CustomPropertiesWindow::GetCustomProperties() c
|
||||
{
|
||||
Date aTmpDate = pLine->m_aDateField.GetDate();
|
||||
Time aTmpTime = pLine->m_aTimeField.GetTime();
|
||||
util::DateTime aDateTime(aTmpTime.Get100Sec(), aTmpTime.GetSec(), aTmpTime.GetMin(), aTmpTime.GetHour(),
|
||||
util::DateTime aDateTime(aTmpTime.GetNanoSec(), aTmpTime.GetSec(), aTmpTime.GetMin(), aTmpTime.GetHour(),
|
||||
aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear() );
|
||||
aPropertiesSeq[i].Value <<= aDateTime;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ SfxVersionTableDtor::SfxVersionTableDtor( const uno::Sequence < util::RevisionTa
|
||||
pInfo->aAuthor = rInfo[n].Author;
|
||||
|
||||
Date aDate ( rInfo[n].TimeStamp.Day, rInfo[n].TimeStamp.Month, rInfo[n].TimeStamp.Year );
|
||||
Time aTime ( rInfo[n].TimeStamp.Hours, rInfo[n].TimeStamp.Minutes, rInfo[n].TimeStamp.Seconds, rInfo[n].TimeStamp.HundredthSeconds );
|
||||
Time aTime ( rInfo[n].TimeStamp.Hours, rInfo[n].TimeStamp.Minutes, rInfo[n].TimeStamp.Seconds, rInfo[n].TimeStamp.NanoSeconds );
|
||||
|
||||
pInfo->aCreationDate = DateTime( aDate, aTime );
|
||||
aTableList.push_back( pInfo );
|
||||
|
||||
@@ -412,7 +412,7 @@ bool operator== (const css::util::DateTime &i_rLeft,
|
||||
&& i_rLeft.Hours == i_rRight.Hours
|
||||
&& i_rLeft.Minutes == i_rRight.Minutes
|
||||
&& i_rLeft.Seconds == i_rRight.Seconds
|
||||
&& i_rLeft.HundredthSeconds == i_rRight.HundredthSeconds;
|
||||
&& i_rLeft.NanoSeconds == i_rRight.NanoSeconds;
|
||||
}
|
||||
|
||||
// NB: keep these two arrays in sync!
|
||||
@@ -633,7 +633,7 @@ OUString SAL_CALL durationToText(sal_Int32 i_value) throw ()
|
||||
ud.Hours = static_cast<sal_Int16>((i_value % (24 * 3600)) / 3600);
|
||||
ud.Minutes = static_cast<sal_Int16>((i_value % 3600) / 60);
|
||||
ud.Seconds = static_cast<sal_Int16>(i_value % 60);
|
||||
ud.MilliSeconds = 0;
|
||||
ud.NanoSeconds = 0;
|
||||
return durationToText(ud);
|
||||
}
|
||||
|
||||
@@ -967,7 +967,7 @@ propsToStrings(css::uno::Reference<css::beans::XPropertySet> const & i_xPropSet)
|
||||
ud.Hours = ut.Hours;
|
||||
ud.Minutes = ut.Minutes;
|
||||
ud.Seconds = ut.Seconds;
|
||||
ud.MilliSeconds = 10 * ut.HundredthSeconds;
|
||||
ud.NanoSeconds = ut.NanoSeconds;
|
||||
values.push_back(durationToText(ud));
|
||||
as.push_back(std::make_pair(vt,
|
||||
OUString("time")));
|
||||
@@ -1837,7 +1837,7 @@ SfxDocumentMetaData::resetUserData(const OUString & the_value)
|
||||
bool bModified( false );
|
||||
bModified |= setMetaText("meta:initial-creator", the_value);
|
||||
::DateTime now( ::DateTime::SYSTEM );
|
||||
css::util::DateTime uDT(now.Get100Sec(), now.GetSec(), now.GetMin(),
|
||||
css::util::DateTime uDT(now.GetNanoSec(), now.GetSec(), now.GetMin(),
|
||||
now.GetHour(), now.GetDay(), now.GetMonth(), now.GetYear());
|
||||
bModified |= setMetaText("meta:creation-date", dateTimeToText(uDT));
|
||||
bModified |= setMetaText("dc:creator", OUString());
|
||||
|
||||
@@ -100,8 +100,8 @@ bool operator> (const util::DateTime& i_rLeft, const util::DateTime& i_rRight)
|
||||
if ( i_rLeft.Seconds != i_rRight.Seconds )
|
||||
return i_rLeft.Seconds > i_rRight.Seconds;
|
||||
|
||||
if ( i_rLeft.HundredthSeconds != i_rRight.HundredthSeconds )
|
||||
return i_rLeft.HundredthSeconds > i_rRight.HundredthSeconds;
|
||||
if ( i_rLeft.NanoSeconds != i_rRight.NanoSeconds )
|
||||
return i_rLeft.NanoSeconds > i_rRight.NanoSeconds;
|
||||
|
||||
return sal_False;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ void SfxObjectShell::UpdateDocInfoForSave()
|
||||
// update ModificationAuthor, revision and editing time
|
||||
::DateTime now( ::DateTime::SYSTEM );
|
||||
xDocProps->setModificationDate( util::DateTime(
|
||||
now.Get100Sec(), now.GetSec(), now.GetMin(),
|
||||
now.GetNanoSec(), now.GetSec(), now.GetMin(),
|
||||
now.GetHour(), now.GetDay(), now.GetMonth(),
|
||||
now.GetYear() ) );
|
||||
xDocProps->setModifiedBy( aUserName );
|
||||
@@ -833,7 +833,7 @@ void SfxObjectShell::ResetFromTemplate( const String& rTemplateName, const Strin
|
||||
|
||||
::DateTime now( ::DateTime::SYSTEM );
|
||||
xDocProps->setTemplateDate( util::DateTime(
|
||||
now.Get100Sec(), now.GetSec(), now.GetMin(),
|
||||
now.GetNanoSec(), now.GetSec(), now.GetMin(),
|
||||
now.GetHour(), now.GetDay(), now.GetMonth(),
|
||||
now.GetYear() ) );
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ bool operator==(const util::DateTime &i_rLeft, const util::DateTime &i_rRight)
|
||||
&& i_rLeft.Hours == i_rRight.Hours
|
||||
&& i_rLeft.Minutes == i_rRight.Minutes
|
||||
&& i_rLeft.Seconds == i_rRight.Seconds
|
||||
&& i_rLeft.HundredthSeconds == i_rRight.HundredthSeconds;
|
||||
&& i_rLeft.NanoSeconds == i_rRight.NanoSeconds;
|
||||
}
|
||||
|
||||
static
|
||||
@@ -586,7 +586,7 @@ void SfxOleFileTimeProperty::ImplLoad( SvStream& rStrm )
|
||||
maDateTime.Hours = aDateTime.GetHour();
|
||||
maDateTime.Minutes = aDateTime.GetMin();
|
||||
maDateTime.Seconds = aDateTime.GetSec();
|
||||
maDateTime.HundredthSeconds = aDateTime.Get100Sec();
|
||||
maDateTime.NanoSeconds = aDateTime.GetNanoSec();
|
||||
}
|
||||
|
||||
void SfxOleFileTimeProperty::ImplSave( SvStream& rStrm )
|
||||
@@ -600,7 +600,7 @@ void SfxOleFileTimeProperty::ImplSave( SvStream& rStrm )
|
||||
static_cast< sal_uIntPtr >( maDateTime.Hours ),
|
||||
static_cast< sal_uIntPtr >( maDateTime.Minutes ),
|
||||
static_cast< sal_uIntPtr >( maDateTime.Seconds ),
|
||||
static_cast< sal_uIntPtr >( maDateTime.HundredthSeconds ) ) );
|
||||
static_cast< sal_uIntPtr >( maDateTime.NanoSeconds ) ) );
|
||||
// invalid time stamp is not converted to UTC
|
||||
// heuristic to detect editing durations (which we assume to be < 1 year):
|
||||
// check only the year, not the entire date
|
||||
|
||||
@@ -317,7 +317,7 @@ void SfxPrinterController::jobStarted()
|
||||
::DateTime now( ::DateTime::SYSTEM );
|
||||
|
||||
xDocProps->setPrintDate( util::DateTime(
|
||||
now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(),
|
||||
now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(),
|
||||
now.GetDay(), now.GetMonth(), now.GetYear() ) );
|
||||
|
||||
SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_PRINTDOC, GlobalEventConfig::GetEventName( STR_EVENT_PRINTDOC ), mpObjectShell ) );
|
||||
|
||||
@@ -163,7 +163,7 @@ bool SfxDateTimeItem::PutValue( const com::sun::star::uno::Any& rVal,
|
||||
Time( aValue.Hours,
|
||||
aValue.Minutes,
|
||||
aValue.Seconds,
|
||||
aValue.HundredthSeconds ) );
|
||||
aValue.NanoSeconds ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ bool SfxDateTimeItem::QueryValue( com::sun::star::uno::Any& rVal,
|
||||
sal_uInt8 nMemberId ) const
|
||||
{
|
||||
nMemberId &= ~CONVERT_TWIPS;
|
||||
com::sun::star::util::DateTime aValue( aDateTime.Get100Sec(),
|
||||
com::sun::star::util::DateTime aValue( aDateTime.GetNanoSec(),
|
||||
aDateTime.GetSec(),
|
||||
aDateTime.GetMin(),
|
||||
aDateTime.GetHour(),
|
||||
|
||||
@@ -49,7 +49,7 @@ sal_Bool FStatHelper::GetModifiedDateTimeOfFile( const OUString& rURL,
|
||||
*pDate = Date( pDT->Day, pDT->Month, pDT->Year );
|
||||
if( pTime )
|
||||
*pTime = Time( pDT->Hours, pDT->Minutes,
|
||||
pDT->Seconds, pDT->HundredthSeconds );
|
||||
pDT->Seconds, pDT->NanoSeconds );
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
|
||||
@@ -150,7 +150,7 @@ void ODocumentInfoPreview::insertDateTime(
|
||||
DateTime aToolsDT(
|
||||
Date(value.Day, value.Month, value.Year),
|
||||
Time(
|
||||
value.Hours, value.Minutes, value.Seconds, value.HundredthSeconds));
|
||||
value.Hours, value.Minutes, value.Seconds, value.NanoSeconds));
|
||||
if (aToolsDT.IsValidAndGregorian()) {
|
||||
const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
|
||||
OUStringBuffer buf(rLocaleWrapper.getDate(aToolsDT));
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace svt
|
||||
|
||||
#define CONVERT_DATETIME( aUnoDT, aToolsDT ) \
|
||||
aToolsDT = ::DateTime( Date( aUnoDT.Day, aUnoDT.Month, aUnoDT.Year ), \
|
||||
Time( aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds, aUnoDT.HundredthSeconds ) );
|
||||
Time( aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds, aUnoDT.NanoSeconds ) );
|
||||
|
||||
using ::com::sun::star::uno::Reference;
|
||||
using ::com::sun::star::uno::Sequence;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace svt
|
||||
//---------------------------------------------------------------------
|
||||
SvStream& operator << ( SvStream& _rStorage, const util::DateTime& _rDate )
|
||||
{
|
||||
_rStorage << _rDate.HundredthSeconds;
|
||||
_rStorage << _rDate.NanoSeconds;
|
||||
_rStorage << _rDate.Seconds;
|
||||
_rStorage << _rDate.Minutes;
|
||||
_rStorage << _rDate.Hours;
|
||||
@@ -71,7 +71,7 @@ namespace svt
|
||||
//---------------------------------------------------------------------
|
||||
SvStream& operator >> ( SvStream& _rStorage, util::DateTime& _rDate )
|
||||
{
|
||||
_rStorage >> _rDate.HundredthSeconds;
|
||||
_rStorage >> _rDate.NanoSeconds;
|
||||
_rStorage >> _rDate.Seconds;
|
||||
_rStorage >> _rDate.Minutes;
|
||||
_rStorage >> _rDate.Hours;
|
||||
@@ -85,7 +85,7 @@ namespace svt
|
||||
//---------------------------------------------------------------------
|
||||
sal_Bool operator == ( const util::DateTime& _rLHS, const util::DateTime& _rRHS )
|
||||
{
|
||||
return _rLHS.HundredthSeconds == _rRHS.HundredthSeconds
|
||||
return _rLHS.NanoSeconds == _rRHS.NanoSeconds
|
||||
&& _rLHS.Seconds == _rRHS.Seconds
|
||||
&& _rLHS.Minutes == _rRHS.Minutes
|
||||
&& _rLHS.Hours == _rRHS.Hours
|
||||
@@ -123,7 +123,7 @@ namespace svt
|
||||
private:
|
||||
inline void implResetDate( )
|
||||
{
|
||||
m_aLastModified.HundredthSeconds = m_aLastModified.Seconds = m_aLastModified.Minutes = m_aLastModified.Hours = 0;
|
||||
m_aLastModified.NanoSeconds = m_aLastModified.Seconds = m_aLastModified.Minutes = m_aLastModified.Hours = 0;
|
||||
m_aLastModified.Day = m_aLastModified.Month = m_aLastModified.Year = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2170,7 +2170,7 @@ bool HTMLParser::ParseMetaOptionsImpl(
|
||||
Date aDate( (sal_uLong)aContent.GetToken(0).ToInt32() );
|
||||
Time aTime( (sal_uLong)aContent.GetToken(1).ToInt32() );
|
||||
DateTime aDateTime( aDate, aTime );
|
||||
::util::DateTime uDT(aDateTime.Get100Sec(),
|
||||
::util::DateTime uDT(aDateTime.GetNanoSec(),
|
||||
aDateTime.GetSec(), aDateTime.GetMin(),
|
||||
aDateTime.GetHour(), aDateTime.GetDay(),
|
||||
aDateTime.GetMonth(), aDateTime.GetYear());
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace svt
|
||||
|
||||
// time part
|
||||
returnValue += lcl_convertTimeToDays(
|
||||
aDateTimeValue.Hours, aDateTimeValue.Minutes, aDateTimeValue.Seconds, aDateTimeValue.HundredthSeconds );
|
||||
aDateTimeValue.Hours, aDateTimeValue.Minutes, aDateTimeValue.Seconds, aDateTimeValue.NanoSeconds );
|
||||
|
||||
// done
|
||||
return returnValue;
|
||||
@@ -300,7 +300,7 @@ namespace svt
|
||||
|
||||
// convert
|
||||
returnValue += lcl_convertTimeToDays(
|
||||
aTimeValue.Hours, aTimeValue.Minutes, aTimeValue.Seconds, aTimeValue.HundredthSeconds );
|
||||
aTimeValue.Hours, aTimeValue.Minutes, aTimeValue.Seconds, aTimeValue.NanoSeconds );
|
||||
|
||||
// done
|
||||
return returnValue;
|
||||
|
||||
@@ -2398,7 +2398,7 @@ namespace
|
||||
_rField.SetText( sTime );
|
||||
else
|
||||
{
|
||||
_rField.SetTime( ::Time( aValue.Hours, aValue.Minutes, aValue.Seconds, aValue.HundredthSeconds ) );
|
||||
_rField.SetTime( ::Time( aValue.Hours, aValue.Minutes, aValue.Seconds, aValue.NanoSeconds ) );
|
||||
sTime = _rField.GetText();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1654,7 +1654,7 @@ void SwCompareData::SetRedlinesToDoc( sal_Bool bUseDocInfo )
|
||||
? xDocProps->getCreationDate()
|
||||
: xDocProps->getModificationDate() );
|
||||
Date d(uDT.Day, uDT.Month, uDT.Year);
|
||||
Time t(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
|
||||
Time t(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
||||
DateTime aDT(d,t);
|
||||
|
||||
if( aTmp.Len() )
|
||||
|
||||
@@ -272,7 +272,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const String& rPath, bool bOutline, c
|
||||
OSL_ENSURE(xDocProps.is(), "Doc has no DocumentProperties");
|
||||
// the GlobalDoc is the template
|
||||
xDocProps->setTemplateName(aEmptyStr);
|
||||
::util::DateTime uDT(aTmplDate.Get100Sec(),
|
||||
::util::DateTime uDT(aTmplDate.GetNanoSec(),
|
||||
aTmplDate.GetSec(), aTmplDate.GetMin(),
|
||||
aTmplDate.GetHour(), aTmplDate.GetDay(),
|
||||
aTmplDate.GetMonth(), aTmplDate.GetYear());
|
||||
|
||||
@@ -2994,7 +2994,7 @@ SwRedlineData::SwRedlineData( RedlineType_t eT, sal_uInt16 nAut )
|
||||
eType( eT ), nAuthor( nAut ), nSeqNo( 0 )
|
||||
{
|
||||
aStamp.SetSec( 0 );
|
||||
aStamp.Set100Sec( 0 );
|
||||
aStamp.SetNanoSec( 0 );
|
||||
}
|
||||
|
||||
SwRedlineData::SwRedlineData( const SwRedlineData& rCpy, sal_Bool bCpyNext )
|
||||
|
||||
@@ -973,7 +973,7 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat,
|
||||
String aName( xDocProps->getAuthor() );
|
||||
util::DateTime uDT( xDocProps->getCreationDate() );
|
||||
Date aD(uDT.Day, uDT.Month, uDT.Year);
|
||||
Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
|
||||
Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
||||
DateTime aDate(aD,aT);
|
||||
if( nSub == DI_CREATE )
|
||||
; // das wars schon!!
|
||||
@@ -982,7 +982,7 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat,
|
||||
aName = xDocProps->getModifiedBy();
|
||||
uDT = xDocProps->getModificationDate();
|
||||
Date bD(uDT.Day, uDT.Month, uDT.Year);
|
||||
Time bT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
|
||||
Time bT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
||||
DateTime bDate(bD,bT);
|
||||
aDate = bDate;
|
||||
}
|
||||
@@ -991,7 +991,7 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat,
|
||||
aName = xDocProps->getPrintedBy();
|
||||
uDT = xDocProps->getPrintDate();
|
||||
Date bD(uDT.Day, uDT.Month, uDT.Year);
|
||||
Time bT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
|
||||
Time bT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
||||
DateTime bDate(bD,bT);
|
||||
aDate = bDate;
|
||||
}
|
||||
@@ -1068,8 +1068,8 @@ SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const
|
||||
template<class T>
|
||||
static double lcl_TimeToDouble( const T& rTime )
|
||||
{
|
||||
const double fMilliSecondsPerDay = 86400000.0;
|
||||
return ((rTime.Hours*3600000)+(rTime.Minutes*60000)+(rTime.Seconds*1000)+(rTime.HundredthSeconds*10)) / fMilliSecondsPerDay;
|
||||
const double fNanoSecondsPerDay = 86400000000000.0;
|
||||
return ((rTime.Hours*3600000)+(rTime.Minutes*60000)+(rTime.Seconds*1000)+(rTime.NanoSeconds)) / fNanoSecondsPerDay;
|
||||
}
|
||||
|
||||
template<class D>
|
||||
@@ -1904,7 +1904,7 @@ bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
||||
case FIELD_PROP_DATE_TIME:
|
||||
{
|
||||
util::DateTime DateTimeValue;
|
||||
DateTimeValue.HundredthSeconds = aDateTime.Get100Sec();
|
||||
DateTimeValue.NanoSeconds = aDateTime.GetNanoSec();
|
||||
DateTimeValue.Seconds = aDateTime.GetSec();
|
||||
DateTimeValue.Minutes = aDateTime.GetMin();
|
||||
DateTimeValue.Hours = aDateTime.GetHour();
|
||||
@@ -1957,7 +1957,7 @@ bool SwPostItField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
||||
util::DateTime aDateTimeValue;
|
||||
if(!(rAny >>= aDateTimeValue))
|
||||
return sal_False;
|
||||
aDateTime.Set100Sec(aDateTimeValue.HundredthSeconds);
|
||||
aDateTime.SetNanoSec(aDateTimeValue.NanoSeconds);
|
||||
aDateTime.SetSec(aDateTimeValue.Seconds);
|
||||
aDateTime.SetMin(aDateTimeValue.Minutes);
|
||||
aDateTime.SetHour(aDateTimeValue.Hours);
|
||||
|
||||
@@ -194,7 +194,7 @@ bool SwDateTimeField::QueryValue( uno::Any& rVal, sal_uInt16 nWhichId ) const
|
||||
DateTime aDateTime(GetDate(), GetTime());
|
||||
|
||||
util::DateTime DateTimeValue;
|
||||
DateTimeValue.HundredthSeconds = aDateTime.Get100Sec();
|
||||
DateTimeValue.NanoSeconds = aDateTime.GetNanoSec();
|
||||
DateTimeValue.Seconds = aDateTime.GetSec();
|
||||
DateTimeValue.Minutes = aDateTime.GetMin();
|
||||
DateTimeValue.Hours = aDateTime.GetHour();
|
||||
@@ -239,7 +239,7 @@ bool SwDateTimeField::PutValue( const uno::Any& rVal, sal_uInt16 nWhichId )
|
||||
if(!(rVal >>= aDateTimeValue))
|
||||
return false;
|
||||
DateTime aDateTime( DateTime::EMPTY );
|
||||
aDateTime.Set100Sec(aDateTimeValue.HundredthSeconds);
|
||||
aDateTime.SetNanoSec(aDateTimeValue.NanoSeconds);
|
||||
aDateTime.SetSec(aDateTimeValue.Seconds);
|
||||
aDateTime.SetMin(aDateTimeValue.Minutes);
|
||||
aDateTime.SetHour(aDateTimeValue.Hours);
|
||||
|
||||
@@ -240,7 +240,7 @@ bool UCB_GetFileListOfFolder( const String& rURL,
|
||||
::Time( aStamp.Hours,
|
||||
aStamp.Minutes,
|
||||
aStamp.Seconds,
|
||||
aStamp.HundredthSeconds ));
|
||||
aStamp.NanoSeconds ));
|
||||
pDateTimeList->push_back( pDateTime );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ static util::DateTime lcl_DateTimeToUno(const DateTime& rDT)
|
||||
aRetDT.Hours = rDT.GetHour();
|
||||
aRetDT.Minutes = rDT.GetMin();
|
||||
aRetDT.Seconds = rDT.GetSec();
|
||||
aRetDT.HundredthSeconds = rDT.Get100Sec();
|
||||
aRetDT.NanoSeconds = rDT.GetNanoSec();
|
||||
return aRetDT;
|
||||
}
|
||||
|
||||
|
||||
@@ -284,15 +284,15 @@ static void WriteDop( WW8Export& rWrt )
|
||||
{
|
||||
::util::DateTime uDT = xDocProps->getCreationDate();
|
||||
Date aD(uDT.Day, uDT.Month, uDT.Year);
|
||||
Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
|
||||
Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
||||
rDop.dttmCreated = sw::ms::DateTime2DTTM(DateTime(aD,aT));
|
||||
uDT = xDocProps->getModificationDate();
|
||||
Date aD2(uDT.Day, uDT.Month, uDT.Year);
|
||||
Time aT2(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
|
||||
Time aT2(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
||||
rDop.dttmRevised = sw::ms::DateTime2DTTM(DateTime(aD2,aT2));
|
||||
uDT = xDocProps->getPrintDate();
|
||||
Date aD3(uDT.Day, uDT.Month, uDT.Year);
|
||||
Time aT3(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
|
||||
Time aT3(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
|
||||
rDop.dttmLastPrint = sw::ms::DateTime2DTTM(DateTime(aD3,aT3));
|
||||
}
|
||||
|
||||
|
||||
@@ -1487,7 +1487,7 @@ void SwWW8ImplReader::ImportDop()
|
||||
{
|
||||
DateTime aLastPrinted(
|
||||
msfilter::util::DTTM2DateTime(pWDop->dttmLastPrint));
|
||||
::util::DateTime uDT(aLastPrinted.Get100Sec(),
|
||||
::util::DateTime uDT(aLastPrinted.GetNanoSec(),
|
||||
aLastPrinted.GetSec(), aLastPrinted.GetMin(),
|
||||
aLastPrinted.GetHour(), aLastPrinted.GetDay(),
|
||||
aLastPrinted.GetMonth(), aLastPrinted.GetYear());
|
||||
|
||||
@@ -723,7 +723,7 @@ SwRedlineData* XMLRedlineImportHelper::ConvertRedline(
|
||||
aDT.SetHour( pRedlineInfo->aDateTime.Hours );
|
||||
aDT.SetMin( pRedlineInfo->aDateTime.Minutes );
|
||||
aDT.SetSec( pRedlineInfo->aDateTime.Seconds );
|
||||
aDT.Set100Sec( pRedlineInfo->aDateTime.HundredthSeconds );
|
||||
aDT.SetNanoSec( pRedlineInfo->aDateTime.NanoSeconds );
|
||||
|
||||
// 3) recursively convert next redline
|
||||
// ( check presence and sanity of hierarchical redline info )
|
||||
|
||||
@@ -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,\
|
||||
|
||||
@@ -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
|
||||
|
||||
+33
-17
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
+168
-82
@@ -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);
|
||||
}
|
||||
|
||||
static Time Sec100ToTime( sal_Int32 nSec100 )
|
||||
{
|
||||
short nSign;
|
||||
if ( nSec100 < 0 )
|
||||
sal_Int64 TimeToNanoSec( const Time& rTime )
|
||||
{
|
||||
nSec100 *= -1;
|
||||
nSign = -1;
|
||||
}
|
||||
else
|
||||
nSign = 1;
|
||||
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();
|
||||
|
||||
Time aTime( 0, 0, 0, nSec100 );
|
||||
aTime.SetTime( aTime.GetTime() * nSign );
|
||||
return aTime;
|
||||
}
|
||||
sal_Int64 nRet = nNanoSec;
|
||||
nRet += nSec * nanoSecInSec;
|
||||
nRet += nMin * secInMin * nanoSecInSec;
|
||||
nRet += nHour * minInHour * secInMin * nanoSecInSec;
|
||||
|
||||
return (nRet * nSign);
|
||||
}
|
||||
|
||||
Time NanoSecToTime( sal_Int64 nNanoSec )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
} // 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 = (((sal_Int32)nNew100Sec) + (nSec*100) + (nMin*10000) +
|
||||
(nHour*1000000)) * nSign;
|
||||
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;
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user