question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DatePicker: dateStyleClasses shifts to wrong date

See original GitHub issue

Describe the defect When added metadata with some styles, the styles is applied to wrong date: shifts +/- one day.

Environment:

  • PF Version: 10.0
  • Time zone in browser is UTC+06:00

To Reproduce Steps to reproduce the behavior:

  1. Set time zone on you PC to UTC+06:00
  2. After 18:00 styles is shifts on next day

Solution Function toISODateString() in datepicker.js now is:

toISODateString: function (b) {
  return b.toISOString().substring(0, 10)
}

must be:

toISODateString: function (b) {
  return new Date(b.getTime() - (b.getTimezoneOffset() * 60000)).toISOString().substring(0, 10)
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mellowarecommented, May 18, 2021

If someone needs this MonkeyPatch now just apply this to your application JS.

if (PrimeFaces.widget.DatePicker) {
    $.prime.datePicker.prototype.toISODateString: function(date) {
        return new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().substring(0, 10);
    }
}
1reaction
christophs78commented, May 18, 2021

Propably not covered by integration tests. toISODateString is currently only called from renderDateCellContent during evaluation of this.options.dateStyleClasses. So we at least should not break other functionally. And dateStyleClasses is only populated via dateMetadata introduced with PF 10. (Think we have no integration tests for dateMetadata.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Material UI DatePicker Showing Wrong Date - Stack Overflow
I've faced the same problem. After all, I added a parseISO method on my date, you need to specify the timezone of the...
Read more >
[DatePicker] date select on right calendar shifts to left #2471
I'm going to mark this issue as an enhancement to provide the ability to configure this behavior since we now want the position...
Read more >
Solved: Date picker sends wrong date and wrong format
I have created two forms in PowerApps, that sends a selected date to an excel file. Settings in PowerApps: Default date: Today(). Date...
Read more >
PickerOptions | PrimeFaces JavaScript API Docs
Whether the date picker overlay is shown when the element focused. showOtherMonths. showOtherMonths: boolean. Displays days belonging to other months.
Read more >
SwiftUI Date Picker is Problematic | Apple Developer Forums
The date format is getting changed with specific dates and not everytime i select a new one. BUT, I found a workaround. You...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found