Skip to content

Commit

Permalink
ZK-5861: Select a date in December causes an invalid result under loc…
Browse files Browse the repository at this point in the history
…ale pt
  • Loading branch information
DevChu committed Dec 27, 2024
1 parent 9303769 commit 65bc74a
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 2 deletions.
1 change: 1 addition & 0 deletions zkdoc/release-note
Original file line number Diff line number Diff line change
@@ -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

Expand Down
24 changes: 24 additions & 0 deletions zktest/src/main/webapp/test2/B102-ZK-5861.zul
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
B102-ZK-5861.zul
Purpose:
Description:
History:
Tue Dec 24 11:31:22 CST 2024, Created by jameschu
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
-->
<zk>
<label>select any date and see the correct date, not error popup</label>
<separator/>
<zscript><![CDATA[
import java.time.Instant;
import java.util.Date;
Date date = Date.from(Instant.parse("2024-12-25T00:00:00.000Z"))
]]></zscript>
<datebox cols="30" format="long" value="${date}" locale="pt"/>
</zk>
3 changes: 3 additions & 0 deletions zktest/src/main/webapp/test2/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
##
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
6 changes: 4 additions & 2 deletions zul/src/main/resources/web/js/zul/db/datefmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 65bc74a

Please sign in to comment.