summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-08-02 23:46:22 +0200
committerAndras Timar <andras.timar@collabora.com>2016-08-15 10:28:38 +0200
commit56e4cffdb5c3ac465ac7ffce1dc327fffe220d48 (patch)
tree55a0183e610055032c940b6f3a1b323d8a9300d9
parent24f1246e9bb4a73f888cf0b6028768be360d9c27 (diff)
break the Excel rule for YMD and DMY, tdf#101147 follow-up
Clearly in {HH YYYY-MM-DD} the MM should not be minute. Also not in {HH DD.MM.YY}. Don't follow every bullshit. Period. It is debatable how to treat MDY, {HH:MM DD/YY} should be different from {HH MM/DD/YY}, Excel ironically takes both as minute, even in an en-US locale. (cherry picked from commit 88134dcba680418496f7a1c70a47fde0159ce390) Conflicts: svl/qa/unit/svl.cxx Change-Id: I13d39a36294e3c40cc0e9bf72026804b299bb264 Reviewed-on: https://gerrit.libreoffice.org/27814 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Laurent BP <laurent.balland-poirier@laposte.net> Reviewed-by: Eike Rathke <erack@redhat.com> (cherry picked from commit 97c0d2cf817d0d995dbc3d0901dbbfb4491e9664)
-rw-r--r--svl/source/numbers/zforscan.cxx12
1 files changed, 10 insertions, 2 deletions
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index 5fcddb0a2a11..117c7f2e698a 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -1156,9 +1156,12 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
Minute if one of:
* preceded by time keyword H (ignoring separators)
* followed by time keyword S (ignoring separators)
- * H or S was detected
+ * H or S was detected and this is the first M following
* preceded by '[' amount bracket
Else month.
+ That are the Excel rules. BUT, we break it because certainly
+ in something like {HH YYYY-MM-DD} the MM is NOT meant to be
+ minute, so not if MM is between YY and DD or DD and YY.
*/
nIndexPre = PreviousKeyword(i);
nIndexNex = NextKeyword(i);
@@ -1166,7 +1169,12 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
nIndexPre == NF_KEY_HH || // HH
nIndexNex == NF_KEY_S || // S
nIndexNex == NF_KEY_SS || // SS
- bIsTimeDetected || // tdf#101147
+ (bIsTimeDetected &&
+ !(((nIndexPre == NF_KEY_YY || nIndexPre == NF_KEY_YYYY) &&
+ (nIndexNex == NF_KEY_D || nIndexNex == NF_KEY_DD)) ||
+ ((nIndexPre == NF_KEY_D || nIndexPre == NF_KEY_DD) &&
+ (nIndexNex == NF_KEY_YY || nIndexNex == NF_KEY_YYYY)))
+ ) || // tdf#101147
PreviousChar(i) == '[' ) // [M
{
eNewType = css::util::NumberFormat::TIME;