-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
- Be in a month with less than 31 days
import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';- Call
format('2025-03-31') - See result
01-03-2025(dutch locale) or03-01-2025(us locale)
Expected behavior
Expected result: 31-03-2025 (dutch locale) or 03-31-2025 (us locale)
Additional context
This is caused by this code:
const date = new Date();
date.setDate(day);
date.setMonth(month);
date.setFullYear(year);First a date object is instantiated on the current date. Then it sets the day of the month to the 31st; if the current month does not have 31 days, then the date will overflow to the first of the next month (or beyond if the current month is februari), then the month and year are set.
How to fix this:
const date = new Date();
date.setFullYear(year, month, day);Metadata
Metadata
Assignees
Labels
No labels