On 10 January 2014 19:47, Peter Hamilton <[email protected]> wrote:
> I opened a ticket at https://github.com/tzinfo/tzinfo/issues/13

Thank you for the report.

> The fix is easy, but I'm having a hard time writing a test for it.
>
> So far, other than the system being set to UTC, I can't seem to produce a
> time object like the one I show in the ticket.
>
> Is there any way to create a Time object with an arbitrary time zone? It is
> my understanding that the time is either local or UTC, so the answer to my
> question is no (which is why tzinfo exists right?).

It isn't possible to create a Time object with an arbitrary time zone.
Time instances can either use the system (local) time zone or UTC.
However, on most platforms (Windows is the notable exception) it is
possible to change the local time zone of the current process by
setting the TZ environment variable. For example:

2.1.0p0 :001 > ENV['TZ'] = 'America/Los_Angeles'
 => "America/Los_Angeles"
2.1.0p0 :002 > Time.now.zone
 => "PST"
2.1.0p0 :003 > ENV['TZ'] = 'UTC'
 => "UTC"
2.1.0p0 :004 > Time.now.zone
 => "UTC"

> If we can only create local or UTC objects, is there a way to ensure the
> local object thinks the time zone is UTC?
>
> Any other ideas for testing this?

I have committed a fix
(https://github.com/tzinfo/tzinfo/commit/ac59588270c9b8ed949f24c770bd362dbc65daeb)
with tests that temporarily adjust the TZ environment variable. On
Windows and other platforms where setting TZ doesn't change the time
zone, the tests will pass, but won't actually test for this issue.

Kind regards,

Phil
_______________________________________________
TZInfo-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/tzinfo-users

Reply via email to