From 65bc74a4bc29e55aff7998aa54c3ff2c5b6a274c Mon Sep 17 00:00:00 2001 From: James Chu Date: Tue, 24 Dec 2024 17:05:48 +0800 Subject: [PATCH] ZK-5861: Select a date in December causes an invalid result under locale pt --- zkdoc/release-note | 1 + zktest/src/main/webapp/test2/B102-ZK-5861.zul | 24 +++++++++++++ .../src/main/webapp/test2/config.properties | 3 ++ .../zktest/zats/test2/B102_ZK_5861Test.java | 35 +++++++++++++++++++ .../main/resources/web/js/zul/db/datefmt.ts | 6 ++-- 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 zktest/src/main/webapp/test2/B102-ZK-5861.zul create mode 100644 zktest/src/test/java/org/zkoss/zktest/zats/test2/B102_ZK_5861Test.java diff --git a/zkdoc/release-note b/zkdoc/release-note index 7c5c8a45cc..eb8a1272c0 100644 --- a/zkdoc/release-note +++ b/zkdoc/release-note @@ -1,6 +1,7 @@ ZK 10.2.0 * Features ZK-5824: separate fragment widget into an independent library or another jar + ZK-5861: Select a date in December causes an invalid result under locale pt * Bugs diff --git a/zktest/src/main/webapp/test2/B102-ZK-5861.zul b/zktest/src/main/webapp/test2/B102-ZK-5861.zul new file mode 100644 index 0000000000..87442bea6d --- /dev/null +++ b/zktest/src/main/webapp/test2/B102-ZK-5861.zul @@ -0,0 +1,24 @@ + + + + + + + + \ No newline at end of file diff --git a/zktest/src/main/webapp/test2/config.properties b/zktest/src/main/webapp/test2/config.properties index 8ff6e9c06b..dc5353bfb4 100644 --- a/zktest/src/main/webapp/test2/config.properties +++ b/zktest/src/main/webapp/test2/config.properties @@ -3150,6 +3150,9 @@ B90-ZK-4431.zul=A,E,Multislider ##zats##B101-ZK-5810.zul=A,E,XEL,ZUL,ClientMVVM ##zats##B101-ZK-5777.zul=A,E,SendRedirect,Encoding +## B102 +##zats##B102-ZK-5861.zul=A,E,locale,pt,datebox,format + ## # Features - 3.0.x version ## diff --git a/zktest/src/test/java/org/zkoss/zktest/zats/test2/B102_ZK_5861Test.java b/zktest/src/test/java/org/zkoss/zktest/zats/test2/B102_ZK_5861Test.java new file mode 100644 index 0000000000..4b536b9743 --- /dev/null +++ b/zktest/src/test/java/org/zkoss/zktest/zats/test2/B102_ZK_5861Test.java @@ -0,0 +1,35 @@ +/* B102_ZK_5861Test.java + + Purpose: + + Description: + + History: + Tue Dec 24 11:31:22 CST 2024, Created by jameschu + +Copyright (C) 2024 Potix Corporation. All Rights Reserved. +*/ +package org.zkoss.zktest.zats.test2; + +import static org.junit.jupiter.api.Assertions.assertFalse; + +import org.junit.jupiter.api.Test; + +import org.zkoss.test.webdriver.WebDriverTestCase; + +/** + * @author jameschu + */ + +public class B102_ZK_5861Test extends WebDriverTestCase { + @Test + public void test() throws Exception { + connect(); + waitResponse(); + click(jq(".z-datebox-button")); + waitResponse(); + click(jq(".z-calendar-cell.z-calendar-weekday").eq(10)); //random date + waitResponse(); + assertFalse(jq(".z-errorbox").exists()); + } +} diff --git a/zul/src/main/resources/web/js/zul/db/datefmt.ts b/zul/src/main/resources/web/js/zul/db/datefmt.ts index b41f7ce66f..4bf94df309 100644 --- a/zul/src/main/resources/web/js/zul/db/datefmt.ts +++ b/zul/src/main/resources/web/js/zul/db/datefmt.ts @@ -89,8 +89,10 @@ function removeLiteral(str: string, literals: string[]): string { if (literals.length === 0) { return str; } - var pattern = new RegExp(literals.join('|'), 'g'); - return str.replace(pattern, ' '); + for (let literal of literals) { + str = str.replace('\'' + literal + '\'', ' '); + } + return str; } function _digitFixed(val: string | number, digits?: number): string { var s = String(val);