Skip to content

Commit 65bc74a

Browse files
committed
ZK-5861: Select a date in December causes an invalid result under locale pt
1 parent 9303769 commit 65bc74a

File tree

5 files changed

+67
-2
lines changed

5 files changed

+67
-2
lines changed

zkdoc/release-note

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ZK 10.2.0
22
* Features
33
ZK-5824: separate fragment widget into an independent library or another jar
4+
ZK-5861: Select a date in December causes an invalid result under locale pt
45

56
* Bugs
67

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
B102-ZK-5861.zul
4+
5+
Purpose:
6+
7+
Description:
8+
9+
History:
10+
Tue Dec 24 11:31:22 CST 2024, Created by jameschu
11+
12+
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
13+
-->
14+
<zk>
15+
<label>select any date and see the correct date, not error popup</label>
16+
<separator/>
17+
<zscript><![CDATA[
18+
import java.time.Instant;
19+
import java.util.Date;
20+
21+
Date date = Date.from(Instant.parse("2024-12-25T00:00:00.000Z"))
22+
]]></zscript>
23+
<datebox cols="30" format="long" value="${date}" locale="pt"/>
24+
</zk>

zktest/src/main/webapp/test2/config.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3150,6 +3150,9 @@ B90-ZK-4431.zul=A,E,Multislider
31503150
##zats##B101-ZK-5810.zul=A,E,XEL,ZUL,ClientMVVM
31513151
##zats##B101-ZK-5777.zul=A,E,SendRedirect,Encoding
31523152

3153+
## B102
3154+
##zats##B102-ZK-5861.zul=A,E,locale,pt,datebox,format
3155+
31533156
##
31543157
# Features - 3.0.x version
31553158
##
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* B102_ZK_5861Test.java
2+
3+
Purpose:
4+
5+
Description:
6+
7+
History:
8+
Tue Dec 24 11:31:22 CST 2024, Created by jameschu
9+
10+
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
11+
*/
12+
package org.zkoss.zktest.zats.test2;
13+
14+
import static org.junit.jupiter.api.Assertions.assertFalse;
15+
16+
import org.junit.jupiter.api.Test;
17+
18+
import org.zkoss.test.webdriver.WebDriverTestCase;
19+
20+
/**
21+
* @author jameschu
22+
*/
23+
24+
public class B102_ZK_5861Test extends WebDriverTestCase {
25+
@Test
26+
public void test() throws Exception {
27+
connect();
28+
waitResponse();
29+
click(jq(".z-datebox-button"));
30+
waitResponse();
31+
click(jq(".z-calendar-cell.z-calendar-weekday").eq(10)); //random date
32+
waitResponse();
33+
assertFalse(jq(".z-errorbox").exists());
34+
}
35+
}

zul/src/main/resources/web/js/zul/db/datefmt.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ function removeLiteral(str: string, literals: string[]): string {
8989
if (literals.length === 0) {
9090
return str;
9191
}
92-
var pattern = new RegExp(literals.join('|'), 'g');
93-
return str.replace(pattern, ' ');
92+
for (let literal of literals) {
93+
str = str.replace('\'' + literal + '\'', ' ');
94+
}
95+
return str;
9496
}
9597
function _digitFixed(val: string | number, digits?: number): string {
9698
var s = String(val);

0 commit comments

Comments
 (0)