From bb0543f6de926a2d89797162a974bb01772d890d Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Wed, 10 May 2017 15:58:45 +0200 Subject: tdf#107677 html import: Import ISO8601 datetime in html meta tags too. Change-Id: I51073f5c9e433fb1d9dd2c62bcfea38b299aa010 --- svtools/source/svhtml/parhtml.cxx | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'svtools') diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx index c35856b9ba88..0906aab472fa 100644 --- a/svtools/source/svhtml/parhtml.cxx +++ b/svtools/source/svhtml/parhtml.cxx @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -1962,18 +1963,29 @@ bool HTMLParser::ParseMetaOptionsImpl( case HtmlMeta::Created: case HtmlMeta::Changed: - if ( i_xDocProps.is() && !aContent.isEmpty() && - comphelper::string::getTokenCount(aContent, ';') == 2 ) + if (i_xDocProps.is() && !aContent.isEmpty()) { - Date aDate( (sal_uLong)aContent.getToken(0, ';').toInt32() ); - tools::Time aTime( (sal_uLong)aContent.getToken(1, ';').toInt32() ); - DateTime aDateTime( aDate, aTime ); - ::util::DateTime uDT = aDateTime.GetUNODateTime(); - if ( HtmlMeta::Created==nAction ) - i_xDocProps->setCreationDate( uDT ); - else - i_xDocProps->setModificationDate( uDT ); - bChanged = true; + ::util::DateTime uDT; + bool valid = false; + if (comphelper::string::getTokenCount(aContent, ';') == 2) + { + Date aDate((sal_uLong)aContent.getToken(0, ';').toInt32()); + tools::Time aTime((sal_uLong)aContent.getToken(1, ';').toInt32()); + DateTime aDateTime(aDate, aTime); + uDT = aDateTime.GetUNODateTime(); + valid = true; + } + else if (utl::ISO8601parseDateTime(aContent, uDT)) + valid = true; + + if (valid) + { + bChanged = true; + if (HtmlMeta::Created == nAction) + i_xDocProps->setCreationDate(uDT); + else + i_xDocProps->setModificationDate(uDT); + } } break; -- cgit