fix: correct getDayOfWeekCode to return day of week instead of day of month#6254
Open
coding-shalabh wants to merge 1 commit intoHacker0x01:mainfrom
Open
fix: correct getDayOfWeekCode to return day of week instead of day of month#6254coding-shalabh wants to merge 1 commit intoHacker0x01:mainfrom
coding-shalabh wants to merge 1 commit intoHacker0x01:mainfrom
Conversation
… month Fixes Hacker0x01#6217 Changed getDayOfWeekCode() to use format 'eee' instead of 'ddd' with enUS locale. The previous implementation used format 'ddd' which returns the day of the month (1-31) instead of the day of week code (sun, mon, tue, etc.). This was causing incorrect behavior when the function was used to determine day-of-week codes for calendar operations. As per date-fns documentation: - 'ddd' = day of month with ordinal (1st, 2nd, etc.) - 'eee' = day of week abbreviated (Sun, Mon, Tue, etc.) The fix uses 'eee' with enUS locale and converts to lowercase to return the expected day-of-week codes: sun, mon, tue, wed, thu, fri, sat. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6217 - getDayOfWeekCode in date_utils has incorrect behavior
Problem
The current implementation of
getDayOfWeekCode()returns the day of the month instead of the day of week code. This happens because the format stringdddis used with date-fns, which represents the day of month with ordinal (1st, 2nd, 3rd, etc.) rather than the day of week abbreviation.Current code:
For example, calling this on the 15th of any month would return "15" instead of the expected day code like "mon" or "tue".
Solution
Changed the format string to
eeewhich correctly returns the abbreviated day of week name, using theenUSlocale to ensure consistency, and converting to lowercase to match the expected output format.Fixed code:
This now correctly returns lowercase day-of-week codes:
sun,mon,tue,wed,thu,fri,satReference
ddd= ordinal day of month (1st, 2nd, 3rd, etc.)eee= abbreviated day of week (Sun, Mon, Tue, etc.)Testing
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com