Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

[Issue 56]: Date rounding bug #57

Merged
merged 1 commit into from
May 31, 2024
Merged

[Issue 56]: Date rounding bug #57

merged 1 commit into from
May 31, 2024

Conversation

rylew1
Copy link
Collaborator

@rylew1 rylew1 commented May 29, 2024

Summary

Fixes #56

Time to review: 2 min

Changes proposed

  • Update the date creation to the parsed year/month/day so it creates the Date object using the local time - this may prevent any type of rounding
  • Add some tests to ensure the right dates are showing up on search

Copy link

Coverage report for ./frontend

St.
Category Percentage Covered / Total
🟢 Statements
83.27% (+0.02% 🔼)
846/1016
🟡 Branches 68.31% 222/325
🟡 Functions 75.46% 163/216
🟢 Lines
82.81% (+0.02% 🔼)
795/960

Test suite run success

168 tests passing in 54 suites.

Report generated by 🧪jest coverage report action from 706dd8d


// Create a new Date object using the local time
const date = new Date(year, month - 1, day);

const options: Intl.DateTimeFormatOptions = {
year: "numeric",
month: "long",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is the format date function we call from SearchResultListItem - it needs to be updated to be called from the local time instead of just the UTC time (which is I think what happens when you just do new Date(dateStr)

Copy link
Member

Choose a reason for hiding this comment

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

This subtracts 1 from the month?

Copy link
Collaborator Author

@rylew1 rylew1 May 29, 2024

Choose a reason for hiding this comment

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

The month is just 0-based - you can open chrome console and try it by enter 3 for the month - you'll see it's April:

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@andycochran I think it's ready for review now

@rylew1 rylew1 merged commit 4047895 into main May 31, 2024
11 checks passed
@rylew1 rylew1 deleted the rylew/56-date-rounding-bug branch May 31, 2024 18:20
acouch pushed a commit that referenced this pull request Sep 18, 2024
Fixes #56

- Update the date creation to the parsed year/month/day so it creates
the `Date` object using the local time - this may prevent any type of
rounding
- Add some tests to ensure the right dates are showing up on search
acouch pushed a commit that referenced this pull request Sep 18, 2024
Fixes #56

- Update the date creation to the parsed year/month/day so it creates
the `Date` object using the local time - this may prevent any type of
rounding
- Add some tests to ensure the right dates are showing up on search
acouch pushed a commit to HHS/simpler-grants-gov that referenced this pull request Sep 18, 2024
Fixes #56

- Update the date creation to the parsed year/month/day so it creates
the `Date` object using the local time - this may prevent any type of
rounding
- Add some tests to ensure the right dates are showing up on search
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Date rounding bug
2 participants