Open JanTvrdik opened 2 weeks ago
Hi @JanTvrdik,
I wasn't aware of this difference between brick/date-time and java.time, thanks for bringing it to my attention!
I think it's totally reasonable to expect this to work the same way as it does in Java, so let's consider this a bug report. I'll see if I can find some time to work on this in the coming days, unless you want to open a PR.
However, as this is a BC break, it will require a new version bump (0.8.0), as version 0.7.0 was released just 2 days ago.
Just to be clear:
public function plusPeriod(Period $period): ZonedDateTime
{
return ZonedDateTime::of($this->localDateTime->plusPeriod($period), $this->timeZone);
}
public function plusDuration(Duration $duration): ZonedDateTime
{
return ZonedDateTime::ofInstant($this->instant->plus($duration), $this->timeZone);
}
Change behavior is happening only when timezone changes between two points of time (like DST).
In Java 8, for example ZonedDateTime.plusMinutes operates on the instant time-line, which means that
zonedDateTime.plusMinutes(30)
is the same aszonedDateTime.plus(Duration.ofMinutes(30))
.In this library, however,
is different from
If this is intentional behavior change then I think the documenation should be improved (see very good documenation of
ZonedDateTime::of()
).If that is unintentional behavior change, that this may be considered a bug report.