[Libreoffice-commits] core.git: unotools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Jan 27 15:15:05 UTC 2019
unotools/source/misc/datetime.cxx | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
New commits:
commit d423829d662ddf1974ce6aca07dfa9d551333406
Author: Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sat Jan 26 00:40:01 2019 +0100
Commit: Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Sun Jan 27 16:14:45 2019 +0100
Use getTokenCount instead of custom code
Change-Id: I645854f4e0d5d57f8507a13e29dbb920e9f1ab85
Reviewed-on: https://gerrit.libreoffice.org/66940
Tested-by: Jenkins
Reviewed-by: Matteo Casalin <matteo.casalin at yahoo.com>
diff --git a/unotools/source/misc/datetime.cxx b/unotools/source/misc/datetime.cxx
index 08b1f8f5032b..7a843db7a34a 100644
--- a/unotools/source/misc/datetime.cxx
+++ b/unotools/source/misc/datetime.cxx
@@ -27,6 +27,7 @@
#include <rtl/math.hxx>
#include <osl/diagnose.h>
#include <vcl/svapp.hxx>
+#include <comphelper/string.hxx>
#include <sstream>
namespace
@@ -347,20 +348,13 @@ bool ISO8601parseDateTime(const OUString &rString, css::util::DateTime& rDateTim
// year, week date, ordinal date
bool ISO8601parseDate(const OUString &aDateStr, css::util::Date& rDate)
{
+ const sal_Int32 nDateTokens {comphelper::string::getTokenCount(aDateStr, '-')};
bool bSuccess = true;
sal_Int32 nYear = 1899;
sal_Int32 nMonth = 12;
sal_Int32 nDay = 30;
- const sal_Unicode* pStr = aDateStr.getStr();
- sal_Int32 nDateTokens = 1;
- while ( *pStr )
- {
- if ( *pStr == '-' )
- nDateTokens++;
- pStr++;
- }
if ( nDateTokens > 3 || aDateStr.isEmpty() )
bSuccess = false;
else
More information about the Libreoffice-commits
mailing list