edtf.js icon indicating copy to clipboard operation
edtf.js copied to clipboard

TypeError when formatting interval

Open 1ec5 opened this issue 7 months ago • 4 comments

The format() function throws a TypeError when passing in an interval. For example:

edtf.format(edtf.default('2000/2001'))

throws:

Uncaught TypeError: Cannot read properties of undefined (reading 'value')

It might be possible to format some intervals natively using Intl.DateTimeFormat.prototype.formatRange(). However, this API doesn’t accept other kinds of intervals, such as /2001 and ../2001. Ultimately, I’d like to be able to rely on this library to output something like “before 2001”.

1ec5 avatar Mar 14 '25 18:03 1ec5