summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2023-06-23 14:44:44 +0200
committerEike Rathke <erack@redhat.com>2023-06-24 01:20:12 +0200
commitc20337889469e41cec89bd421fab533f16b4b451 (patch)
treeabf23a2be09c283e0c0d415c85f7aa4c40805e7e /unotools
parent4a92323b54e7d63a8bc0b8e62fdc6b31760dcd05 (diff)
Change LocaleDataWrapper::getDuration() parameter to tools::Duration
... instead of tools::Time Change-Id: I8e49de43a1870541d75add34089eec67b7a8be31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153533 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/i18n/localedatawrapper.cxx21
1 files changed, 13 insertions, 8 deletions
diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx
index 56524372e21f..87299810ab6b 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -41,6 +41,7 @@
#include <rtl/math.hxx>
#include <tools/date.hxx>
#include <tools/time.hxx>
+#include <tools/duration.hxx>
#include <o3tl/string_view.hxx>
#include <utility>
@@ -1173,28 +1174,32 @@ OUString LocaleDataWrapper::getTime( const tools::Time& rTime, bool bSec, bool b
return aBuf.makeStringAndClear();
}
-OUString LocaleDataWrapper::getDuration( const tools::Time& rTime, bool bSec, bool b100Sec ) const
+OUString LocaleDataWrapper::getDuration( const tools::Duration& rDuration, bool bSec, bool b100Sec ) const
{
OUStringBuffer aBuf(128);
- if ( rTime < tools::Time( 0 ) )
- aBuf.append(' ' );
+ if ( rDuration.IsNegative() )
+ aBuf.append(' ');
+ sal_Int64 nHours = static_cast<sal_Int64>(rDuration.GetDays()) * 24 +
+ (rDuration.IsNegative() ?
+ -static_cast<sal_Int64>(rDuration.GetTime().GetHour()) :
+ rDuration.GetTime().GetHour());
if ( (true) /* IsTimeLeadingZero() */ )
- ImplAddUNum( aBuf, rTime.GetHour(), 2 );
+ ImplAddNum( aBuf, nHours, 2 );
else
- ImplAddUNum( aBuf, rTime.GetHour() );
+ ImplAddNum( aBuf, nHours, 1 );
aBuf.append( aLocaleDataItem.timeSeparator );
- ImplAdd2UNum( aBuf, rTime.GetMin() );
+ ImplAdd2UNum( aBuf, rDuration.GetTime().GetMin() );
if ( bSec )
{
aBuf.append( aLocaleDataItem.timeSeparator );
- ImplAdd2UNum( aBuf, rTime.GetSec() );
+ ImplAdd2UNum( aBuf, rDuration.GetTime().GetSec() );
if ( b100Sec )
{
aBuf.append( aLocaleDataItem.time100SecSeparator );
- ImplAdd9UNum( aBuf, rTime.GetNanoSec() );
+ ImplAdd9UNum( aBuf, rDuration.GetTime().GetNanoSec() );
}
}