ACR Rules

⌘K
  1. Home
  2. Docs
  3. ACR Rules
  4. Reliability (41)
  5. Week year should not be used in date formatting or parsing

Week year should not be used in date formatting or parsing

Few developers are aware of the difference between Y for “Week year” and y for Year when formatting and parsing dates. That’s likely because, for most dates, week year and year are the same, so testing at any time other than the first or last week of the year will yield the same value for both y and Y. But in the last week of December and the first week of January this can cause unexpected results.

Noncompliant example:

parseDateTime($Var, 'YYYY')

Compliant example:

parseDateTime($Var, 'yyyy')