diff options
author | Eike Rathke <erack@redhat.com> | 2011-11-30 02:05:25 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2011-11-30 02:05:25 +0100 |
commit | 7613359985a89a42417a746bcdbb25f072784733 (patch) | |
tree | d7ed828c6839d323a1766adeaf57b92e3b8b8e88 /sax/source | |
parent | 07a7b2937a9427b2feb3307804ec0f527091bb92 (diff) |
handle dates with year < 1000
* Read dates with years consisting of less than 4 digits.
ISO 8601 specifies that years are to be written with a minimum of 4 digits.
However, be lenient in what we accept.
* Write years < 1000 with leading zeros to comply with ISO 8601 YYYY.
Diffstat (limited to 'sax/source')
-rw-r--r-- | sax/source/tools/converter.cxx | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx index b1629c8ec572..0c0779bac959 100644 --- a/sax/source/tools/converter.cxx +++ b/sax/source/tools/converter.cxx @@ -1345,15 +1345,26 @@ bool Converter::convertDateOrDateTime( const ::rtl::OUString string = rString.trim().toAsciiUpperCase(); sal_Int32 nPos(0); - if ((string.getLength() > nPos) && (sal_Unicode('-') == string[nPos])) + if (string.getLength() > nPos) { - //Negative Number - ++nPos; + if (sal_Unicode('-') == string[nPos]) + { + //Negative Number + ++nPos; + } + else if (sal_Unicode('+') == string[nPos]) + { + //Positive Number, explicit AD/CE + ++nPos; + } } sal_Int32 nYear(0); { - bSuccess = readDateTimeComponent(string, nPos, nYear, 4, false); + // While ISO 8601 specifies years with a minimum of 4 digits, be + // leninent in what we accept for years < 1000. One digit is acceptable + // if the remainders match. + bSuccess = readDateTimeComponent(string, nPos, nYear, 1, false); bSuccess &= (0 < nYear); bSuccess &= (nPos < string.getLength()); // not last token } |