Use of timeZone in Instant.periodUntil

Hi,

In the library kotlinx.datetime , what is the point to specify a timeZone with the function Instant.periodUntil ?

I mean, a period between two instants is always the same, regardless of the time zone… ??

Doc : periodUntil

The return type is DateTimePeriod which is not just a “simple” duration in one length-invariant unit, but also contains length-variant units, e.g. month.
The length of different months is different and therefore the number of full months within a period can be different depending on when the period begins, i.e. which time zone is used.

Example:
Look at the period 2023-02-28 22:00 UTC till 2023-03-29 22:00 UTC.
That is a full month plus a day… at least in UTC. But go some timezones forward for the same instants: 2023-03-01 02:00 UTC+4 till 2023-03-30 02:00 UTC+4 and now it is two days less than a full month.

3 Likes

Thank you @tlin47 !