Problem/Motivation
#date_year_range property handles "0" like relative "+0" / "-0".
In result not year zero is used, but the current year.
Testing to only allow year zero (0):
0:0 // Expected: 0:0, actual: 2026:2026 (current year)
or a range starting in year zero:
0:+50 // Expected: 0:2076, actual: 2026:2076 (current year / current year+50)
Steps to reproduce
See above - to be proven!
Proposed resolution
Write a test to show the issue
Find the bug in
protected static function datetimeRangeYears($string, $date = NULL)
and fix it.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Comments
Comment #2
anybodyComment #3
anybodyIt's even more weird. Entering any value < 1000 leads to current year. Tested with 0, 1 and 999.
Only setting >= 1000 works as expected using the absolute year.
So first we should have tests for this. Maybe a nice little core testing issue for novice?
Comment #5
anybodyOkay, I found the root cause:
datetimeRangeYears()does not support years with < 4 digits:and then magically handles them like relative dates.
Relative dates should always start with a +/-. So current year should be +0, not 0.
If we can't change that without introducing a regression, we should trigger a deprecation error if someone uses
0without +/- prefix. Currently it's always treated as current year!From Drupal 13 on we should then treat
0asyear 0!Comment #6
anybody