Skip to content

dateToRFC3339String produces invalid dates #1200

@ahawkins

Description

@ahawkins

Describe the bug

My time zone is Hawaii. The offset is -10:00. One of my fixtures includes this date string: 2023-06-13T11:30:48-10:00 (equivalent to 2023-06-13T21:30:48.000Z). The timestamp breaks anything using the date or date-time object serializer dateToRFC3339String function. The serialized form is: 2023-06-13T31:30:48+10:00. Note the hour 31. The Datadog API returns a 400 Bad Request with an error on the relevant parameter.

To Reproduce
Steps to reproduce the behavior:

  1. Instantiate a date with hour 11 and offset -10
  2. Use that date for any date or date-time serialized parameter (I used start_date with V2 Estimated Cost by Org)
  3. Observe a 400 response from the Datadog API

Expected behavior

Dates in any time zone serialize properly.

Screenshots

Not/Applicable.

Environment and Versions (please complete the following information):

  • Node: v16.19.0
  • datadog-api: 1.10.10

Additional context

I think the problem is here. This causes the hour wrap around when the UTC hour plus offset exceeds 24. My test date is UTC hour 21 plus the offset (10) comes out to 31.

I don't understand why date components (ymd, hour/minute/seconds, etc) are pulled in UTC, then manipulated again by the offset. It seems easier to return something without the offset at this point.

Also, the API docs state the format is ISO860 but the code does not use it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions