diff options
author | Eike Rathke <erack@redhat.com> | 2019-08-19 17:05:15 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2019-08-19 18:31:08 +0200 |
commit | 4ffb036fd5858c1acee9930e8f03d8b8a0d88730 (patch) | |
tree | dce1e0a0f3cecb8d5799aa4c7450a896f2d42105 /svl/source | |
parent | cc4084cf6da45c358e88d88fdb340de3ae713039 (diff) |
Resolves: tdf#72040 add predefined ISO 8601 date+time format with "T"
Still missing is selecting the format if such input is detected,
but if applied it is preserved as edit format when editing the
value.
Change-Id: Ic36a643bb90ac897a303d5d59782aa4b297a56ea
Reviewed-on: https://gerrit.libreoffice.org/77732
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'svl/source')
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index e862b45f5db4..6d8a906a0038 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -156,7 +156,8 @@ static sal_uInt32 const indexTable[NF_INDEX_TABLE_ENTRIES] = { ZF_STANDARD_FRACTION + 6, // NF_FRACTION_16 ZF_STANDARD_FRACTION + 7, // NF_FRACTION_10 ZF_STANDARD_FRACTION + 8, // NF_FRACTION_100 - ZF_STANDARD_DATETIME + 2 // NF_DATETIME_ISO_YYYYMMDD_HHMMSS + ZF_STANDARD_DATETIME + 2, // NF_DATETIME_ISO_YYYYMMDD_HHMMSS + ZF_STANDARD_DATETIME + 3 // NF_DATETIME_ISO_YYYYMMDDTHHMMSS }; /** @@ -1507,7 +1508,9 @@ sal_uInt32 SvNumberFormatter::GetEditFormat( double fNumber, sal_uInt32 nFIndex, nKey = GetTimeFormat( fNumber, eLang, true); break; case SvNumFormatType::DATETIME : - if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang) || (pFormat && pFormat->IsIso8601( 0 ))) + if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS, eLang)) + nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS, eLang ); + else if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang) || (pFormat && pFormat->IsIso8601( 0 ))) nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang ); else nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang ); @@ -2649,7 +2652,7 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio OUStringBuffer aBuf; aSingleFormatCode.Usage = i18n::KNumberFormatUsage::DATE_TIME; - // YYYY-MM-DD HH:MM:SS ISO + // YYYY-MM-DD HH:MM:SS ISO (with blank instead of 'T') aBuf.append( rKeyword[NF_KEY_YYYY]).append('-'). append( rKeyword[NF_KEY_MM]).append('-'). append( rKeyword[NF_KEY_DD]).append(' '). @@ -2660,6 +2663,19 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio ImpInsertFormat( aSingleFormatCode, CLOffset + ZF_STANDARD_DATETIME+2 /* NF_DATETIME_ISO_YYYYMMDD_HHMMSS */ ); + // YYYY-MM-DD"T"HH:MM:SS ISO + aBuf.append( rKeyword[NF_KEY_YYYY]).append('-'). + append( rKeyword[NF_KEY_MM]).append('-'). + append( rKeyword[NF_KEY_DD]).append("\"T\""). + append( rKeyword[NF_KEY_HH]).append(':'). + append( rKeyword[NF_KEY_MMI]).append(':'). + append( rKeyword[NF_KEY_SS]); + aSingleFormatCode.Code = aBuf.makeStringAndClear(); + SvNumberformat* pFormat = ImpInsertFormat( aSingleFormatCode, + CLOffset + ZF_STANDARD_DATETIME+3 /* NF_DATETIME_ISO_YYYYMMDDTHHMMSS */ ); + assert(pFormat); + pFormat->SetComment("ISO 8601"); // not to be localized + // Scientific number aFormatSeq = xNFC->getAllFormatCode( i18n::KNumberFormatUsage::SCIENTIFIC_NUMBER, aLocale ); |