Because of the way Ruby handles timezones we can find ourselves in a position where a Time object is non-utc but has a timezone of UTC. If the system timezone utc, we get the following
If we use such a time object in calling local_to_utc, the is a bug in https://github.com/tzinfo/tzinfo/blob/master/lib/tzinfo/time_or_datetime.rb#L52
In that line we check for UTC in the zone. I propose we check the utc? method instead of checking the zone method.
The result is that local_to_utc may return a non-utc Time object with zone UTC. With the proposed fix we should always be returning a utc Time object.
I'm happy to submit the fix. Just wanted some feedback first.
Use time.utc? instead of time.zone == 'UTC'.
Distinguishes between actual UTC instances and local instances created
on systems using UTC as the local time zone.
Prevents Timezone#local_to_utc from returning local Time instances on
systems using UTC as the local time zone.
Thank you for the bug report.
I have committed a fix (changed to use utc? instead of zone as you propose).