aws-amplify / aws-amplify/amplify-codegen-ui
`convertToLocal` incorrectly parses dates between midnight and 1am
- Dominant language
- TypeScript
- Stars
- 31
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
Given the following code
```
const convertToLocal = (date) => {
const df = new Intl.DateTimeFormat("default", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
calendar: "iso8601",
numberingSystem: "latn",
hour12: false,
});
const parts = df.formatToParts(date).reduce((acc, part) => {
acc[part.type] = part.value;
return acc;
}, {});
return `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}`;
};
```
If I pass in a date like `2023-03-06T08:58:00.000Z`, It incorrectly treats the hour as 24 instead of 0. This leads to an invalid date of `2023-03-06T24:58`
Contributor guide
Research direction
Start by locating the convertToLocal entry point and reproduce the issue with 2023-03-06T08:58:00.000Z. Inspect the Intl.DateTimeFormat output for dates between midnight and 1am, then verify that the resulting local date-time string uses a valid hour instead of 24.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100