Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] ZK-5861: Select a date in December causes an invalid result under loc… #3244

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Preview

Copilot AI Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new implementation assumes literals are wrapped in single quotes in the input string, which is a behavior change from the original regex approach. Verify the expected input format and ensure this change is covered by tests.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
str = str.replace('\'' + literal + '\'', ' ');
}
return str;
}
function _digitFixed(val: string | number, digits?: number): string {
var s = String(val);
Expand Down
Loading