ngx-mask icon indicating copy to clipboard operation
ngx-mask copied to clipboard

Extra Zero Added for Months 10, 11, 12 with leadZeroDateTime in Mask Pattern 0000-M0-d0 for Year Range 1932–1999

Open AmitRDesai opened this issue 7 months ago • 0 comments

🐞 bug report

Description

Issue Description:

Mask pattern 0000-M0-d0 with leadZeroDateTime enabled adds an extra zero for months 10, 11, and 12 when the user types the data continuously without hyphens (-).

Steps to Reproduce:

  1. Use the mask pattern 0000-M0-d0 with leadZeroDateTime option enabled.
  2. Type the following date without hyphens: 19901221.
  3. While typing, observe that when the user types 1 for the month (October, November, or December), the mask automatically adds an extra zero (0) and moves the cursor to the day section.
  4. The result becomes 1990-01-02 instead of 1990-12-21.

Expected Behavior: The mask should correctly interpret months 10, 11, and 12 without adding an extra zero when the user types the date without hyphens.

Observed Behavior: The issue occurs only for the year range 1932 to 1999. However, it works as expected for:

  • Years between 1900 to 1931
  • Years between 2000 to 2031

Additional Information: The issue appears to be related to how the mask interprets the month section for certain year ranges.

🔬 Minimal Reproduction

https://stackblitz.com/edit/stackblitz-starters-vp6oajjy?file=src%2Fmain.ts

🌍 Your Environment

Angular Version:


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 18.1.0
Node: 22.14.0
Package Manager: npm 10.9.2
OS: linux x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1801.0
@angular-devkit/core         18.1.0
@angular-devkit/schematics   18.1.0
@schematics/angular          18.1.0

AmitRDesai avatar Mar 04 '25 08:03 AmitRDesai