doc-en icon indicating copy to clipboard operation
doc-en copied to clipboard

Outdated info regarding multiple consecutive number signs

Open esnard opened this issue 1 year ago • 9 comments

Description

The following code:

<?php

echo ((new \DateTimeImmutable("--1 year"))->format('Y'));

Resulted in this output in 8.2.25 / 8.3.13:

2025

But I expected this output instead (8.2.0 - 8.2.24, 8.3.0 - 8.3.12):

2023

This used to output 2025 in PHP < 8.2, but from my understanding, this behavior was intentionally changed.

I couldn’t find anything in the changelog about this change, and the Changelog section in the documentation hasn't been updated. I'm opening this issue to confirm if this is now the intended behavior.

esnard avatar Oct 28 '24 09:10 esnard

The issue is caused by the latest update of timelib (https://github.com/php/php-src/commit/40d06fb645b42409ecb242a6ea4a4fd7207d7a0c). Note that the commit messages states:

Import timelib 2022.12

@derickr, that looks seriously wrong. We had been on 2024.2 already.

cmb69 avatar Oct 29 '24 15:10 cmb69

I would argue that the format "--1 year" is valid and IMO shouldn't be allowed. But the proper approach would be to deprecate such wrong "calculations" and change it in the next version, instead of patches.

jorgsowa avatar Oct 29 '24 17:10 jorgsowa

That had already been changed a few years ago. There has been a bad update to timelib, though. Anyhow, deprecating what we had changed quite some time ago doesn't make much sense to me.

cmb69 avatar Oct 29 '24 17:10 cmb69

I agree. Now not much can be done, but it could be handled better in the past looking at the whole thread with change.

jorgsowa avatar Oct 29 '24 20:10 jorgsowa

I've only just now seen this. Will have a look!

derickr avatar Dec 16 '24 12:12 derickr

@derickr, that looks seriously wrong. We had been on 2024.2 already.

timelib version != timezonedb version

The timelib version is indeed the correct 2022.12, and the timezonedb version the right 2024.2 version.

The 2022.12 version has this fix in it:

"Allow for multiple signs for signed numbers again (regression)" (https://github.com/derickr/timelib/commit/8b58edb2c9827ceed3cb662209a2be3d756cac1b)

So I don't think there is anything wrong now?

derickr avatar Dec 16 '24 12:12 derickr

timelib version != timezonedb version

Oops, mixed that up.

So https://3v4l.org/ALC7C is intentional? This should probably be documented in the manual then; while we usually don't document bug fixes, there is a note about the previous change in the migration guide, so users might be confused.

cmb69 avatar Dec 16 '24 13:12 cmb69

The bug even was (and is still) documented as a change in the datetime format documentation:

datetime format changelog

esnard avatar Dec 16 '24 13:12 esnard

Heh - I don't know why we documented that. In any case, it should be reverted in the documentation, as we now fixed this again.

derickr avatar Dec 16 '24 15:12 derickr