-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YearWeekIso was modified #432
Conversation
src/dateRange.ts
Outdated
const startDate = new Date(actualYear, 0, 1 + (actualWeek - 1) * 7); | ||
const endDate = new Date(actualYear, 0, 7 + (actualWeek - 1) * 7); | ||
const startDate = getDateOfISOWeek(actualWeek, actualYear); | ||
const endDate = new Date(startDate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed the logic for better understanding
src/weekUtils.ts
Outdated
@@ -21,3 +21,15 @@ export const getIsoYearByDate = (date: Date): number => { | |||
}; | |||
|
|||
export const getIsoYear = (): number => getIsoYearByDate(new Date()); | |||
|
|||
export const getDateOfISOWeek = (week: number, year: number): Date => { | |||
const simple = new Date(year, 0, 1 + (week - 1) * 7); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From reading the code we cannot tell what "simple" could be. Try to make it understandable in order to make the code easier to improve in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
@oscarfgq you guys should consider to delete this logic and use date fns instead. For example: https://date-fns.org/v4.1.0/docs/startOfISOWeek |
Absolutely 👍🏼 |
|
No description provided.