From bc1ad5266a57532432a4a1a7fcc74c4b2b196bc0 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Tue, 28 Oct 2025 00:29:08 +0400 Subject: [PATCH] [se] Refactor numFormat_MonthMinute determination logic --- common/NumFormat.js | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/common/NumFormat.js b/common/NumFormat.js index 76918ac543..9f0f494152 100644 --- a/common/NumFormat.js +++ b/common/NumFormat.js @@ -1306,21 +1306,24 @@ NumFormat.prototype = { //Разрешаем конфликты numFormat_MonthMinute var bRightCond = false; - //ищем вперед первый элемент с типом datetime - for(var j = i + 1; j < nFormatLength; ++j) + if (item.bElapsed) { - var subItem = this.aRawFormat[j]; - if(numFormat_Year == subItem.type || numFormat_Month == subItem.type || numFormat_Day == subItem.type || numFormat_MonthMinute == subItem.type || - numFormat_Hour == subItem.type || numFormat_Minute == subItem.type || numFormat_Second == subItem.type || numFormat_Milliseconds == subItem.type) - { - if(numFormat_Second == subItem.type) - bRightCond = true; - break; - } + bRightCond = true; } - if(this.aRawFormat[i].bElapsed) + else { - bRightCond = true + //ищем вперед первый элемент с типом datetime + for(var j = i + 1; j < nFormatLength; ++j) + { + var subItem = this.aRawFormat[j]; + if(numFormat_Year == subItem.type || numFormat_Month == subItem.type || numFormat_Day == subItem.type || numFormat_MonthMinute == subItem.type || + numFormat_Hour == subItem.type || numFormat_Minute == subItem.type || numFormat_Second == subItem.type || numFormat_Milliseconds == subItem.type) + { + if(numFormat_Second == subItem.type) + bRightCond = true; + break; + } + } } var bLeftCond = false; if(false == bRightCond) @@ -2742,8 +2745,14 @@ NumFormat.prototype = } else if(numFormat_Second == item.type) { + if (item.bElapsed) { + res += "["; + } for(var j = 0; j < item.val; ++j) res += second; + if (item.bElapsed) { + res += "]"; + } } else if(numFormat_DayOfWeek == item.type) { @@ -2787,7 +2796,6 @@ NumFormatCache.prototype = }, get : function(format, formatType) { - //return new CellFormat(format, formatType, false); var key = format + String.fromCharCode(5) + formatType; var res = this.oNumFormats[key]; if(null == res)