Description
Hello,
I have found an issue for how some Dates are being formatted. This bug is found in a common library function so I believe the impact to be significant.
I found this while trying to listProblems
from the CloudGuard client. I was passing a JS Date for the timeFirstDetectedGreaterThanOrEqualTo
parameter and receiving a 400 Invalid Date error.
This line here is the issue.
Consider the following:
let validDate = new Date('2024-08-28T08:15:34Z'); => Wed Aug 28 2024 02:15:34 GMT-0600 (Mountain Daylight Time)
let invalidString =formatDateToRFC3339(validDate); => 2024-08-28T2:15:34Z (notice that the hour is a single digit)
new Date(invalidString); => Invalid Date
Please consider using ("0" + date.getHours()).slice(-2)
or something similar to make sure hours contains two digits.