diff options
author | Jan Holesovsky <kendy@collabora.com> | 2017-05-10 15:58:45 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-05-11 15:54:22 +0200 |
commit | f8dcc41b6d7b0e023096dbb213f9e182046da5cc (patch) | |
tree | e2943baa07859fc5b73a39f6038e2b61ab0b7f90 /svtools | |
parent | e30163f97c6e48998f1799946779962fe6aa4f87 (diff) |
tdf#107677 html import: Import ISO8601 datetime in html meta tags too.
Change-Id: I51073f5c9e433fb1d9dd2c62bcfea38b299aa010
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/svhtml/parhtml.cxx | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx index c09ecc59c58c..3bddc50595de 100644 --- a/svtools/source/svhtml/parhtml.cxx +++ b/svtools/source/svhtml/parhtml.cxx @@ -29,6 +29,7 @@ #include <tools/tenccvt.hxx> #include <tools/datetime.hxx> +#include <unotools/datetime.hxx> #include <svl/inettype.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> @@ -1993,18 +1994,29 @@ bool HTMLParser::ParseMetaOptionsImpl( case HTML_META_CREATED: case HTML_META_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 ( HTML_META_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 (HTML_META_CREATED == nAction) + i_xDocProps->setCreationDate(uDT); + else + i_xDocProps->setModificationDate(uDT); + } } break; |