Skip to content
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

Merged
merged 4 commits into from
Jan 30, 2025
Merged

Conversation

lash1co
Copy link
Contributor

@lash1co lash1co commented Jan 30, 2025

No description provided.

@lash1co lash1co requested review from geoperez and oscarfgq January 30, 2025 01:23
@lash1co lash1co self-assigned this Jan 30, 2025
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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

@MarcoLPR
Copy link
Contributor

@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

@oscarfgq
Copy link
Contributor

Absolutely 👍🏼

@lash1co lash1co requested a review from oscarfgq January 30, 2025 05:01
@geoperez geoperez merged commit e3d2465 into master Jan 30, 2025
6 checks passed
@geoperez geoperez deleted the fix/Uno-Js-YearWeekIso-getDateOfISOWeek branch January 30, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants