Menu

A timestamp test catches seconds, milliseconds and ISO 8601 mixups.
📰

A timestamp test catches seconds, milliseconds and ISO 8601 mixups.

DEV Community: javascript·Aleksander Sekowski·about 8 hours ago
#ua6bRfSL
Reading 0:00
15s threshold

A purchase recorded at noon can appear hours, years or decades away from its intended time when one adapter guesses the unit of a field called timestamp . The JSON may remain perfectly parseable throughout the journey.

The reliable fix starts before the HTTP request. Choose an internal representation, convert it explicitly for each endpoint and test the serialized output with a fixed instant. Then check what the destination actually recorded.

This walkthrough builds a small Node.js contract test. It does not send events or require vendor credentials.

Give the internal timestamp a unit

Use a name such as occurred_at_ms if the application stores epoch milliseconds. Include the unit in the schema and function contract. A caller should not need to count digits to understand a value.

Keep occurrence time separate from the time your worker received or transmitted the event. Retries may change transmission time.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.