summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2019-03-04 16:44:48 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2019-03-20 07:31:10 +0100
commitdfb2feca54147e1939b3a38f841aad566751a479 (patch)
tree93771b1445e4bb5cd0fa4b272cf46824e45ad967 /forms
parent86e6396acb7683e6916c7a502177ecf232468d78 (diff)
Improve parseDateTime tokenization and reduce OUString copies
Change-Id: If84f455c235176d56d72bdc11d813f1ee1e3122e Reviewed-on: https://gerrit.libreoffice.org/69241 Tested-by: Jenkins Reviewed-by: Matteo Casalin <matteo.casalin@yahoo.com>
Diffstat (limited to 'forms')
-rw-r--r--forms/source/xforms/xpathlib/xpathlib.cxx19
1 files changed, 6 insertions, 13 deletions
diff --git a/forms/source/xforms/xpathlib/xpathlib.cxx b/forms/source/xforms/xpathlib/xpathlib.cxx
index 9ff6426ec456..ac73ec7990df 100644
--- a/forms/source/xforms/xpathlib/xpathlib.cxx
+++ b/forms/source/xforms/xpathlib/xpathlib.cxx
@@ -294,20 +294,13 @@ static bool parseDateTime(const OUString& aString, DateTime& aDateTime)
if (aDateTimeString.getLength() < 19 || aDateTimeString.getLength() > 20)
return false;
- sal_Int32 nDateLength = 10;
- sal_Int32 const nTimeLength = 8;
-
- OUString aDateString = aDateTimeString.copy(0, nDateLength);
- OUString aTimeString = aDateTimeString.copy(nDateLength+1, nTimeLength);
-
sal_Int32 nIndex = 0;
- sal_Int32 nYear = aDateString.getToken(0, '-', nIndex).toInt32();
- sal_Int32 nMonth = aDateString.getToken(0, '-', nIndex).toInt32();
- sal_Int32 nDay = aDateString.getToken(0, '-', nIndex).toInt32();
- nIndex = 0;
- sal_Int32 nHour = aTimeString.getToken(0, ':', nIndex).toInt32();
- sal_Int32 nMinute = aTimeString.getToken(0, ':', nIndex).toInt32();
- sal_Int32 nSecond = aTimeString.getToken(0, ':', nIndex).toInt32();
+ sal_Int32 nYear = aDateTimeString.getToken(0, '-', nIndex).toInt32();
+ sal_Int32 nMonth = aDateTimeString.getToken(0, '-', nIndex).toInt32();
+ sal_Int32 nDay = aDateTimeString.getToken(0, 'T', nIndex).toInt32();
+ sal_Int32 nHour = aDateTimeString.getToken(0, ':', nIndex).toInt32();
+ sal_Int32 nMinute = aDateTimeString.getToken(0, ':', nIndex).toInt32();
+ sal_Int32 nSecond = aDateTimeString.getToken(0, 'Z', nIndex).toInt32();
Date tmpDate(static_cast<sal_uInt16>(nDay), static_cast<sal_uInt16>(nMonth), static_cast<sal_uInt16>(nYear));
tools::Time tmpTime(nHour, nMinute, nSecond);