ecma402 icon indicating copy to clipboard operation
ecma402 copied to clipboard

Add `kilowatt-hour` unit to Intl.NumberFormat

Open johanrd opened this issue 2 years ago • 1 comments

Electric vehicles and construction equipment have already started to report energy consumption as kilowatt-hours in their telemetry APIs, not to mention the many applications in the building and power industries. An increasing amount of web applications are going to be developed as tools to help the current electrification of society.

It would be helpful if ecmascript could make developing these web apps a tiny bit easier by providing kilowatt-hour as a supported unit in Intl.NumberFormat.

I understand the concerns about feature creep in suppoerted units (e.g. https://github.com/tc39/ecma402/issues/607), still adding this as a specific issue.

johanrd avatar Jan 04 '23 08:01 johanrd

This is a great suggestion @johanrd, would you be open to collaborating on this?

Across the energy provider, accounting, and consumer industry, a common set of power and energy units – some already defined in cldr – are used for expressing both generation and consumption when dealing with electric wind/solar/hydro/battery and natural gas.

This set is very common among both providers and consumers:

  • power-gigawatt
  • power-megawatt
  • power-kilowatt
  • power-watt
  • energy-kilowatt-hour
  • energy-therm-us

BTUs are used for comparing different kinds of energy against each other:

  • energy-british-thermal-unit

And oddly, megawatt-hours are missing from cldr, but just as common and important as kilowatt-hours, so a proposed cldr key could be:

  • energy-megawatt-hour

Since these units are used globally, there is a strong need to have them formatted according to a user’s locale settings. Adding them to the ECMAScript standard would allow everyone in this field to express these measurements in a consistent way.

kalebpace avatar Nov 09 '24 20:11 kalebpace

Introduction of these standardized units would greatly benefit developers in the energy sector and overlapping industries. I work for a data center/colocation provider, and we work with energy-related formatting quite often across our applications. Considering the advent of AI and increased interest in data centers/energy operation systems, I think it'd be the prime time to implement!

em1382 avatar Aug 01 '25 14:08 em1382

I have made a draft proposal here: https://github.com/johanrd/proposal-intl-energy-units

@kalebpace @em1382 @sffc yes! As I understand the process, we would need to attract a TC39 champion for this. Anyone in mind?

johanrd avatar Oct 24 '25 08:10 johanrd

Hi @johanrd (or anyone else here who wants to get more involved)

Thanks for making the proposal repo. If you would like, please email [email protected] and we can start the process of you joining an upcoming call to present the proposal to TG2.

https://github.com/tc39/ecma402?tab=readme-ov-file#how-to-contribute

sffc avatar Oct 24 '25 16:10 sffc

Sent over an email, thank you both!

kalebpace avatar Oct 24 '25 16:10 kalebpace

Hey @johanrd, noticed the comment you left on https://es.discourse.group/t/addition-of-power-energy-units-to-intl-numberformat/1702 I opened at the time 🙌🏽 Lovely to see that it's of interest to you as well. If possible, would love to contribute to it as well.

imjasonmiller avatar Oct 27 '25 12:10 imjasonmiller

Thank you @kalebpace for bringing this to the TC39-TG2 meeting.

Discussion notes: https://github.com/tc39/ecma402/blob/main/meetings/notes-2025-11-06.md#add-kilowatt-hour-unit-to-intlnumberformat-739

It is on the agenda for advancement to Stage 1 at the TC39 meeting this week.

sffc avatar Nov 18 '25 01:11 sffc

This proposal would then become an official TC39 proposal, then we’d write the spec text, which wouldn’t be too big – add a few things to the sanctioned items list, one of the easiest proposals you could write – but that would need to happen. (…) but we do need spec text, so start with stage 1

Thanks. @kalebpace @imjasonmiller @sffc Feel free to review the proposed Stage 0 readme for what should be included in the Stage 1 readme.

johanrd avatar Nov 18 '25 08:11 johanrd