tc39 / proposals

Tracking ECMAScript Proposals

Home Page:https://tc39.github.io/process-document/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change behaviour of optional Month parameter in Date

daggy1234 opened this issue · comments

The current Date methods accept an optional parameter for month between 0 (January) and 11 (December). This is inconsistent with the Date day parameter that allows values between 1 - 31.

The code new Date(Date.UTC(2022, 2, 14, 23, 30, 0, 0)) produces the date Tue Mar 15 2022 05:00:00 GMT+0530 (India Standard Time).

I think the month parameter should be changed to start at 1 and end at 12 for the following reasons:

  • Other languages like python's datetime module and ctime CTime::GetMonth also start month with 1
  • Ensure Parity with the day parameter
  • Generally, dates are written with 1 representing January, and it's more intuitive for a user to start with 1

I understand that this is a huge, breaking change but the monthIndex in general is extremely confusing for new users and should be modified!

commented

Hi Daggy1234.

Have a look at the Temporal proposal https://github.com/tc39/proposal-temporal

Also, this GitHub issues section is not the right place to discuss such changes. Please favor this forum: https://es.discourse.group/

Thanks

I understand that this is a huge, breaking change

So it's impossible to land in JavaScript. This requires millions of people to rewrite their code. And yes, this is not the correct place for proposals.

Have a look at the Temporal proposal https://github.com/tc39/proposal-temporal

Also, this GitHub issues section is not the right place to discuss such changes. Please favor this forum: https://es.discourse.group/