Skip to content

Conversation

@maxwell-jordan
Copy link
Contributor

adds DateRangeToStringConverter which takes (startDate, endDate, locales, options) as parameters to output a stringified date in the specified format

Copy link
Contributor

@marchant marchant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor needed

* @param {Object} [options] - An object with formatting options for Intl.DateTimeFormat
* @returns {string} The formatted date range string
*/
convert: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't my guidance: converters only take one argument in the convert method, and since it's a DateRangeToStringConverter, the argument passed to convert has to be a Range instance. locales and options needs to be properties of the converter itself

@maxwell-jordan maxwell-jordan force-pushed the feature/date-range-to-string-converter branch from c22d8b0 to a4c9bc0 Compare February 9, 2026 19:22
* @param {Object} [options] - An object with formatting options for Intl.DateTimeFormat
*/
constructor: {
value: function DateRangeToStringConverter(locales, options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to avoid having constructors with arguments as much as possible. They can't be used with serialization/deserialization anyway, when subclassing, one has to remember to call it with the expected arguments. Their main benefit is conciseness when used in code / imperatively

const dateTimeFormat = new Intl.DateTimeFormat(locales, options);
return dateTimeFormat.formatRange(startDate, endDate);
value: function (range) {
const dateTimeFormat = new Intl.DateTimeFormat(this.locales, this.options);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason to create that object every time convert() is called, is there ?! Please refactor so the converter has only one it reuses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants