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

我有更好的正则: 日期(严谨, 支持闰年判断) #311

Open
chorar opened this issue Apr 19, 2024 · 0 comments
Open

我有更好的正则: 日期(严谨, 支持闰年判断) #311

chorar opened this issue Apr 19, 2024 · 0 comments

Comments

@chorar
Copy link

chorar commented Apr 19, 2024

之前的日期严格校验存在错误.
image
主要存在

  1. 无法判断 0000-01-01
  2. 无法判断 1200-02-29 1600-02-29 的闰年 (严重)
    可以修改成

^\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\d|3[01])|(0[469]|11)-(0[1-9]|[12]\d|30)|02-(0[1-9]|1\d|2[0-8]))|(\d{2}(0[48]|[13579][26]|[2468][048])|(0[048]|[13579][26]|[2468][048])00)-02-29$
222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant