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 /xmloff/source/core | |
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 'xmloff/source/core')
-rw-r--r-- | xmloff/source/core/xmluconv.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index 5ea85f108975..6ceb8850b014 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -436,9 +436,16 @@ void SvXMLUnitConverter::convertDateTime( OUStringBuffer& rBuffer, aDate += 1; } } - rBuffer.append( sal_Int32( aDate.GetYear())); + sal_uInt16 nTemp = aDate.GetYear(); + if (nTemp < 1000) + rBuffer.append( sal_Unicode('0')); + if (nTemp < 100) + rBuffer.append( sal_Unicode('0')); + if (nTemp < 10) + rBuffer.append( sal_Unicode('0')); + rBuffer.append( sal_Int32( nTemp)); rBuffer.append( sal_Unicode('-')); - sal_uInt16 nTemp = aDate.GetMonth(); + nTemp = aDate.GetMonth(); if (nTemp < 10) rBuffer.append( sal_Unicode('0')); rBuffer.append( sal_Int32( nTemp)); |