Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accentuate month being 0-index in getMonth example #26734

Merged
merged 4 commits into from
May 13, 2023
Merged

Commits on May 11, 2023

  1. Accentuate month being 0-index in get month example

    `Date.getMonth` behavior differ slightly from the similar method as it return the index of the month and is 0-indexed, while the other method return ordinal values instead of index and don't have this distinction.
    
    One could be tempted to run `${year}-${month}-${day}` and `${hour}:${minutes}:${seconds}` after the code in exemple to get iso formated date and time but the month would be off by one as iso month are 1-indexed, january being 1 and december being 12.
    
    Adding a comment with the actual output put emphasis on this difference in behavior and might prevent people being surprised by that after the fact. The value chosen for the date is partly random. 2000 is the first year not starting with 19; January cause the month part to be 0 which should call attention to itself; 17 is high enough so it cannot be a month and I like it; 16 is in the 24h hour clock; 45 is high enough to not be confused with an hour; 30 is here for lack of imagination.
    gkrnours authored May 11, 2023
    Configuration menu
    Copy the full SHA
    326bc26 View commit details
    Browse the repository at this point in the history

Commits on May 13, 2023

  1. Configuration menu
    Copy the full SHA
    20779b1 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f582c83 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    94e589b View commit details
    Browse the repository at this point in the history