Yesterday was a leap day (feb 29) and facets displayed March 2015 rather than February 2015. The reason for this is we use DateTime::createFromFormat('Y-m', $value), but that creates the wrong date on a leap day (1st of march rather than 29 feb).

See https://bugs.php.net/bug.php?id=71690

CommentFileSizeAuthor
#2 2678856-1.patch849 bytesstefan.r

Comments

stefan.r created an issue. See original summary.

stefan.r’s picture

Status: Active » Needs review
StatusFileSize
new849 bytes
drunken monkey’s picture

The explanation for closing that PHP bug report sounds utterly ridiculous. Why should "any not-parsed date item" being "initialised with the current values" mean that February becomes March?
If you're the Stefan from the PHP issue I'd try to re-open it. I don't think "derick" read it correctly.

However, if I understand this correctly, it would also mean this would fail on the 29th, 30th or 31st of any other month, right? Is there any way in PHP to set the current time, so we could test this easily?
However, it seems like this would make sense even if there weren't any bugs caused by this, simply conceptually – we don't care about any parts of the current time, so we should definitely reset them.

Your patch seems to solve that pretty neatly, and I can't find anything wrong with it. So, after getting your feedback on my comment, and if no-one else objects, I'll commit this in the next days.
In any case, thanks a lot for reporting this issue!

stefan.r’s picture

The explanation for closing that PHP bug report sounds utterly ridiculous.

Par for the course sadly... I've seen much worse bugs closed for "not being a bug" :)

Is there any way in PHP to set the current time, so we could test this easily?

I don't think so!

Not sure about the 30th/31st, may be worth testing.

drunken monkey’s picture

Status: Needs review » Fixed

OK, in any case I'll believe that this fixes the problem. (No way to test now, it seems.)
So, committed. Thanks again!

Not sure about the 30th/31st, may be worth testing.

OK, I've made a note to try it out at the end of the month. That would be considerably worse than being wrong once every four years.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

drunken monkey’s picture

It really is also wrong at the end of each month. Your testing code from the PHP issue just spit out a datetime on March 1 for me.
So, thanks a lot for spotting this! No telling how much confusion this has already caused!