ngx-mask
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
🐞 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:
- Use the mask pattern
0000-M0-d0withleadZeroDateTimeoption enabled. - Type the following date without hyphens:
19901221. - While typing, observe that when the user types
1for the month (October, November, or December), the mask automatically adds an extra zero (0) and moves the cursor to the day section. - The result becomes
1990-01-02instead of1990-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