isoformat is a JavaScript library designed for concise formatting and parsing of ISO 8601 date and date-time strings. It aims to provide a 'tidier' alternative to the standard `Date.toISOString()` by returning the shortest equivalent UTC string for formatting, and offering flexible parsing of common ISO forms. The current stable version is v0.2.1, indicating a library that is actively maintained with recent minor releases, focusing on usability and adherence to specific subsets of the ISO 8601 standard. Key differentiators include its focus on minimal output for `format` (e.g., explicitly excluding YYYY or YYYY-MM forms) and a more permissive `parse` function that handles various ISO 8601 date and time formats, including different timezone offsets and even the widely supported but non-standard -00:00, while explicitly not supporting two-digit time zone offsets (+HH or -HH).
npm install isoformatVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to format Date objects into concise ISO 8601 strings and parse various ISO strings back into Date objects, including handling invalid inputs with fallbacks.
Change your import statement from `import format from 'isoformat'` to `import { format } from 'isoformat'`.Update your code to handle `undefined` return values or provide a `fallback` argument to the `format` function (e.g., `format(date, 'Invalid Date')`).
If YYYY or YYYY-MM formats are required, you will need to manually construct these strings from the Date object or use a different formatting library.
Ensure that any ISO 8601 strings passed to `parse` use supported time zone offset formats (Z, +HH:MM, -HH:MM, +HHMM, or -HHMM).
Ensure your import statement for `format` is `import { format } from 'isoformat'`. If using CommonJS, consider modernizing to ESM or explicitly accessing `require('isoformat').format`.Update your code to check for `undefined` or provide a `fallback` argument to the `format` function, e.g., `format(myDate, 'Invalid Date')`.
Modify the input string to use a supported time zone offset format, such as `2024-01-01T00:00:00+05:00` or `2024-01-01Z`.
No dependency data recorded yet.