-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix: moment deprecated date formatting #102413
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,9 +210,7 @@ function PrimaryNavigationQuotaExceeded({organization}: {organization: Organizat | |
| organization, | ||
| daysToSnooze: | ||
| -1 * | ||
| getDaysSinceDate( | ||
| subscription?.onDemandPeriodEnd ?? moment().utc().toDate().toDateString() | ||
| ), | ||
| getDaysSinceDate(subscription?.onDemandPeriodEnd ?? moment().utc().toISOString()), | ||
| isDismissed: isSnoozedForCurrentPeriod, | ||
| options: { | ||
| enabled: promptsToCheck.length > 0, | ||
|
Comment on lines
210
to
216
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: 🔍 Detailed AnalysisThe code at 💡 Suggested FixUpdate the 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
@@ -262,7 +260,7 @@ function PrimaryNavigationQuotaExceeded({organization}: {organization: Organizat | |
| ); | ||
| localStorage.setItem( | ||
| `billing-status-last-shown-date-${organization.id}`, | ||
| moment().utc().toDate().toDateString() | ||
| moment().utc().toISOString() | ||
| ); | ||
| } | ||
| }, [ | ||
|
|
||
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.
The fallback parameter passed to getDaysSinceDate has been changed to use ISO format (toISOString()), which is good practice and is now tested. However, there is an inconsistency: on line 245, the date is still being stored in localStorage using the deprecated toDateString() format ('Mon Jun 06 2022'). This means when lastShownDate is retrieved from localStorage and passed to getDaysSinceDate() on line 231, it will be in the old format. While getDaysSinceDate() appears to support both formats (as verified by the new tests), it would be more consistent and future-proof to also update line 245 to store dates in ISO format using moment().utc().toISOString() instead of moment().utc().toDate().toDateString().
Severity: MEDIUM
🤖 Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.
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've updated the localStorage to use ISO string as well. When reading from local storage, we parse the date with moment(), so it will remain compatible with both formats.