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

Datetime format used in the nginx samples can't be parsed by native js Date object #4847

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Amndeep7
Copy link
Contributor

@Amndeep7 Amndeep7 commented Aug 20, 2023

image

node and at least firefox from the browsers have a parsing incompatibility. it seems like 2017-09-22 14:12:44 -0400 is parsable by the Date constructor in node but not in firefox.

tested against chrome and it works fine there.

the issue with firefox has been historical (results of the caat export from previous releases)
image

the error just bubbles all the way to the top now because of using the formatter class. the date class itself just silently accepts the erroneous output.

static formatDate(date: Date, delimiter: string): string {
return [
Intl.DateTimeFormat('en-US', {month: '2-digit'}),
Intl.DateTimeFormat('en-US', {day: '2-digit'}),
Intl.DateTimeFormat('en-US', {year: 'numeric'})
]
.map((formatter) => formatter.format(date))
.join(delimiter);
}

Signed-off-by: Amndeep Singh Mann <amann@mitre.org>
Signed-off-by: Amndeep Singh Mann <amann@mitre.org>
Signed-off-by: Amndeep Singh Mann <amann@mitre.org>
@sonarcloud
Copy link

sonarcloud bot commented Aug 20, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@Amndeep7
Copy link
Contributor Author

long term solution is to move to consistently using a datetime library whenever interacting with dates. we have a mix of plain js and momentjs. momentjs is no longer being actively maintained so we should find a replacement library. their official recommendation is luxon. luxon is able to (eventually) find the correct format type.

image

@Amndeep7 Amndeep7 changed the title Release issues aug23 Datetime format used in the nginx samples can't be parsed by native js Date object Aug 20, 2023
@Amndeep7 Amndeep7 added bug Something isn't working chore Dealing with linting, some kinds of technical debt, repetitive work labels Aug 20, 2023
@Amndeep7 Amndeep7 marked this pull request as draft August 20, 2023 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working chore Dealing with linting, some kinds of technical debt, repetitive work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant