Rename getDay() and getDate() methods

Date object was introduced in ECMAScript 1 in 1997.
Among others it has methods for getting Date parts.

In my opinion methods naming are somewhat confusing.

  1. getDate() returns day of month, not Date as name says.
  2. getDay() returns day of week, which is not obvious from the name.

The idea is to rename these methods to more appropriate naming, reflecting its intention.

I propose getDate() to be renamed to getMonthDay() or getDayOfMonth() or even getDayPart().
Accordingly getDay() to be renamed to getWeekDay() or getDayOfWeek() or even getWeekDayPart().

I'm not native English speaker, so one might propose better names. The idea is to make these names closer to their semantics.

Of course, for backward compatibility 'old' methods must not be deleted but marked deprecated instead as it was with pair getYear() / getFullYear().

1 Like

Given that https://github.com/tc39/proposal-temporal is intended to basically replace Date, I don’t think there’s any value in such a disruptive change.

Agree with @ljharb.

But fwiw, great observation and proposal. I couldn't agree with you more. :wink:

@ljharb Thank you for pointing out, I didn't see the Temporal proposal. It is way better and more elaborated.
@ke67 Thanks :)

I noticed that they didn't use Time or DateTime. Probably due to common variable names. This is exciting and much needed. I appreciate your informative post.