diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2011-08-11 16:24:22 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2011-08-18 15:15:50 +0200 |
commit | eccb19aebbef1a11a38e7ffb6b51c1fa6eded7e8 (patch) | |
tree | c1bbd646f889daaa6976d7bbaeb3bf67271fa67d /writerfilter | |
parent | 10de8cf0e3749ef377d68458d5a27e952cfd58c5 (diff) |
Revert "adjust for timezone when reading datetime"
This reverts commit 7fcd99b3d261b0bd76bbf4a7f9bfcb93793be4e4.
Apparently everybody lives in UTC+0 timezone according to MSOffice,
wherever they live.
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 55 |
1 files changed, 10 insertions, 45 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 0d2e31102e00..82d2b75bc720 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -74,7 +74,6 @@ #include <rtl/string.h> #include "FieldTypes.hxx" -#include <tools/datetime.hxx> #include <tools/string.hxx> #ifdef DEBUG_DOMAINMAPPER #include <resourcemodel/QNameToString.hxx> @@ -974,60 +973,26 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap ) util::DateTime lcl_DateStringToDateTime( const ::rtl::OUString& rDateTime ) { - DateTime aDateTime; + util::DateTime aDateTime; //xsd::DateTime in the format [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm] example: 2008-01-21T10:42:00Z //OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const SAL_THROW(()) sal_Int32 nIndex = 0; ::rtl::OUString sDate = rDateTime.getToken( 0, 'T', nIndex ); + // HACK: this is broken according to the spec, but MSOffice always treats the time as local, + // and writes it as Z (=UTC+0) ::rtl::OUString sTime = rDateTime.getToken( 0, 'Z', nIndex ); - int timezonepos = nIndex; nIndex = 0; - aDateTime.SetYear( sDate.getToken( 0, '-', nIndex ).toInt32() ); - aDateTime.SetMonth( sDate.getToken( 0, '-', nIndex ).toInt32() ); - aDateTime.SetDay( sDate.copy( nIndex ).toInt32() ); + aDateTime.Year = sal_uInt16( sDate.getToken( 0, '-', nIndex ).toInt32() ); + aDateTime.Month = sal_uInt16( sDate.getToken( 0, '-', nIndex ).toInt32() ); + aDateTime.Day = sal_uInt16( sDate.copy( nIndex ).toInt32() ); nIndex = 0; - aDateTime.SetHour( sTime.getToken( 0, ':', nIndex ).toInt32() ); - aDateTime.SetMin( sTime.getToken( 0, ':', nIndex ).toInt32() ); - aDateTime.SetSec( sTime.copy( nIndex ).toInt32() ); + aDateTime.Hours = sal_uInt16( sTime.getToken( 0, ':', nIndex ).toInt32() ); + aDateTime.Minutes = sal_uInt16( sTime.getToken( 0, ':', nIndex ).toInt32() ); + aDateTime.Seconds = sal_uInt16( sTime.copy( nIndex ).toInt32() ); - if( timezonepos >= 0 ) // otherwise consider it local time - { - bool negative = false; - nIndex = timezonepos; - if( nIndex < rDateTime.getLength() && rDateTime[ nIndex ] == '-' ) - { - negative = true; - ++nIndex; - } - else if ( nIndex < rDateTime.getLength() && rDateTime[ nIndex ] == '+' ) - { - ++nIndex; - } - Time diff( 0, 0, 0 ); - if( nIndex < rDateTime.getLength()) - { - diff.SetHour( rDateTime.getToken( 0, ':', nIndex ).toInt32()); - diff.SetMin( rDateTime.getToken( 0, ':', nIndex ).toInt32()); - } - // convert to utc, then to local - if( negative ) - aDateTime -= diff; - else - aDateTime += diff; - aDateTime.ConvertToLocalTime(); - } - util::DateTime ret; - ret.Year = aDateTime.GetYear(); - ret.Month = aDateTime.GetMonth(); - ret.Day = aDateTime.GetDay(); - ret.Hours = aDateTime.GetHour(); - ret.Minutes = aDateTime.GetMin(); - ret.Seconds = aDateTime.GetSec(); - ret.HundredthSeconds = 0; - return ret; + return aDateTime; } - void DomainMapper_Impl::appendTextPortion( const ::rtl::OUString& rString, PropertyMapPtr pPropertyMap ) { if (m_aTextAppendStack.empty()) |