[CAMPMAN-34] Calendar only works, when the user is working in the english locale Created: 05/Apr/22  Updated: 07/Apr/22  Resolved: 07/Apr/22

Status: Closed
Project: Campaign Manager
Component/s: None
Affects Version/s: 3.1.6
Fix Version/s: 3.1.7

Type: Bug Priority: High
Reporter: Markus Schwarz Assignee: Raphael Falvo
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2022-04-05-08-44-11-367.png     PNG File image-2022-04-05-08-48-34-885.png     PNG File image.png    
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[X]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

If the user has selected a different preferred language as English (for example "German") as a primary language in "Language & Region" (Mac must be restarted after this setting was made).

And if the user has selected in its browser (firefox) "User your operating system settings for ..."

And if the user opens then the dx publisher calendar or the campaign manager calendar

https://author.sales-demo-integration.eu-playground.magnolia-platform.com/.magnolia/admincentral#app:dx-publisher-app:calendar

and steps back in time, the following error should occur:



 Comments   
Comment by Raphael Falvo [ 05/Apr/22 ]

Stack trace :

Caused by: java.time.format.DateTimeParseException: Text '01.03.2022' could not be parsed at index 2
    at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949) ~[?:1.8.0_302]
    at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851) ~[?:1.8.0_302]
    at java.time.LocalDate.parse(LocalDate.java:400) ~[?:1.8.0_302]
    at info.magnolia.campaign.ui.util.DateUtils.formatDateString(DateUtils.java:172) ~[magnolia-campaign-ui-3.1.7-SNAPSHOT.jar:?]
    at info.magnolia.campaign.ui.view.calendar.vaadin.CalendarComponent.refreshEvents(CalendarComponent.java:106) ~[magnolia-campaign-ui-3.1.7-SNAPSHOT.jar:?]
    at com.vaadin.server.JavaScriptCallbackHelper$1.call(JavaScriptCallbackHelper.java:82) ~[vaadin-server-8.14.1.jar:8.14.1]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_302]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_302]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_302]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_302]
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:155) ~[vaadin-server-8.14.1.jar:8.14.1]
    ... 114 more

Comment by Raphael Falvo [ 06/Apr/22 ]

Hello mschwarz 

I found and fixed the root cause of the issue, there was a discrepancy between the date formatting done in javascript and what java code was expecting, this happened under certain circumstances.
Can you try on your side either by switching to bugfix/CAMPMAN-34 branch on campaign module, or using campaign module 3.1.7-SNAPSHOT that I just pushed to Nexus. In last case you need to ensure that you do not have already a local version of 3.1.7-SNAPSHOT, otherwise delete it first from your local repository. Please let me know how it goes and if the issue doesn't occur anymore with this version.

Comment by Markus Schwarz [ 06/Apr/22 ]

Super cool. I'll have a look.

Comment by Markus Schwarz [ 06/Apr/22 ]

Works like a charm. Thank you for fixing this.

Comment by Raphael Falvo [ 07/Apr/22 ]

Short explanation on the solution applied

 

connector.refreshEvents(info.view.currentStart.toLocaleDateString("en-GB"), info.view.currentEnd.toLocaleDateString("en-GB"));

Passing "en-GB" to toLocaleDateString method ensures that output date is formatted using format : dd/MM/yyyy, which is the format Java is expecting in CalendarComponent.java for parsing. This way there is no risk having discrepancy between JS output format and Java parsing format.

Passing the locale in parameters affect only the output formatting. It's a bit confusing, ideally it would have look better if a method accepting the format would exist, but it's unfortunately not the case.

 

Generated at Sun Feb 11 23:55:28 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.