Skip to content

Add Interval.toLocaleString()#1320

Merged
icambron merged 2 commits intomoment:masterfrom
fodier:interval-tolocalestring
Nov 29, 2022
Merged

Add Interval.toLocaleString()#1320
icambron merged 2 commits intomoment:masterfrom
fodier:interval-tolocalestring

Conversation

@fodier
Copy link
Copy Markdown
Contributor

@fodier fodier commented Nov 9, 2022

Hi,

Interval.toLocaleString(formatOpts, opts) works like DateTime.toLocaleString(formatOpts, opts). Example:

Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL, { locale: 'fr-FR' });
//=> 7–8 novembre 2022

It relies on Intl.DateTimeFormat.formatRange(), now well supported by browsers.
Partly closes luxon/issues#1237 (I can add toLocaleParts in this PR or a different one). Closes luxon/issues#691.

This method is like DateTime.toLocaleString() but for intervals. It
takes the same arguments. It uses the native
DateTimeFormat.formatRange() method, now well supported by browsers.
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Nov 9, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@icambron
Copy link
Copy Markdown
Contributor

Yeah, this is great. Last I'd looked at this, formatRange hadn't landed yet, I guess time flies.

This will go in 3.2.0

@icambron icambron merged commit 7e5d24d into moment:master Nov 29, 2022
@icambron
Copy link
Copy Markdown
Contributor

Thanks for contributing!

@fodier
Copy link
Copy Markdown
Contributor Author

fodier commented Nov 29, 2022

🙂 Thanks for Luxon!

@fodier fodier deleted the interval-tolocalestring branch November 29, 2022 13:40
brboi added a commit to odoo-dev/odoo that referenced this pull request Aug 30, 2023
**Changelog**

**3.4.2 (2023-08-26)**

- Fixes regression from 3.4.1 (moment/luxon#1493)

**3.4.1 (2023-08-23)**

- Fixes for regressions from 3.4.0
  (moment/luxon#1482 and moment/luxon#1488)

**3.4.0 (2023-08-08)**

- Fix type checking on input zones
- Fix Islamic months listing
- Fix normalize() for negative inputs

**3.3.0 (2023-03-03)**

- Fix off-by-one in Interval#count (moment/luxon#1308)
- Support formatting for custom zones (moment/luxon#1377)
- Fix parsing for narrow spaces (moment/luxon#1369)
- Handle leap year issue with AD 100 (moment/luxon#1390)
- Allow parsing of just an offset

**3.2.1 (2023-01-04)**

- Fix for RFC-2822 regex vulnerability
- Better handling of BCP tags with -x- extensions

**3.2.0 (2022-12-29)**

- Allow timeZone to be specified as an intl option
- Fix for diff's handling of end-of-month when crossing leap years
  (moment/luxon#1340)
- Add Interval.toLocaleString() (moment/luxon#1320)

**3.1.1 (2022-11-28)**

- Add Settings.twoDigitCutoffYear

**3.1.0 (2022-10-31)**

- Add Duration.rescale

**3.0.4 (2022-09-24)**

- Fix quarters in diffs (moment/luxon#1279)
- Export package.json in package (moment/luxon#1239)

**3.0.2 (2022-08-28)**

- Lots of doc changes
- Added DateTime.expandFormat
- Added support for custom conversion matrices in Durations
robodoo pushed a commit to odoo/odoo that referenced this pull request Sep 4, 2023
**Changelog**

**3.4.2 (2023-08-26)**

- Fixes regression from 3.4.1 (moment/luxon#1493)

**3.4.1 (2023-08-23)**

- Fixes for regressions from 3.4.0
  (moment/luxon#1482 and moment/luxon#1488)

**3.4.0 (2023-08-08)**

- Fix type checking on input zones
- Fix Islamic months listing
- Fix normalize() for negative inputs

**3.3.0 (2023-03-03)**

- Fix off-by-one in Interval#count (moment/luxon#1308)
- Support formatting for custom zones (moment/luxon#1377)
- Fix parsing for narrow spaces (moment/luxon#1369)
- Handle leap year issue with AD 100 (moment/luxon#1390)
- Allow parsing of just an offset

**3.2.1 (2023-01-04)**

- Fix for RFC-2822 regex vulnerability
- Better handling of BCP tags with -x- extensions

**3.2.0 (2022-12-29)**

- Allow timeZone to be specified as an intl option
- Fix for diff's handling of end-of-month when crossing leap years
  (moment/luxon#1340)
- Add Interval.toLocaleString() (moment/luxon#1320)

**3.1.1 (2022-11-28)**

- Add Settings.twoDigitCutoffYear

**3.1.0 (2022-10-31)**

- Add Duration.rescale

**3.0.4 (2022-09-24)**

- Fix quarters in diffs (moment/luxon#1279)
- Export package.json in package (moment/luxon#1239)

**3.0.2 (2022-08-28)**

- Lots of doc changes
- Added DateTime.expandFormat
- Added support for custom conversion matrices in Durations

closes #133599

Related: odoo/enterprise#46556
Signed-off-by: Luca Vitali (luvi) <[email protected]>
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.

Add Interval.toHuman Localise Interval output

2 participants