diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2019-01-26 00:40:01 +0100 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2019-01-27 16:14:45 +0100 |
commit | d423829d662ddf1974ce6aca07dfa9d551333406 (patch) | |
tree | f3d369e5598685ea28b07d21f5c599aab766f4ef | |
parent | 7fa1e75eb49bf46a745caab2265811d3e591802f (diff) |
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@yahoo.com>
-rw-r--r-- | unotools/source/misc/datetime.cxx | 10 |
1 files changed, 2 insertions, 8 deletions
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 |