Converting Unix time to Ruby time

I've been passed an integer:

   1325376000

... which is the number of seconds since midnight, Jan 1, 1970 IN A
SPECIFIC TIME ZONE (in this case, Pacific). Assuming I know the time
zone (I actually don't -- see PS below), how to I convert this into a
Ruby time object? I could fudge by adding the number of seconds in the
time zone offset, but that seems suspect.

- ff

P.S.: Even if I know that 1325376000 is given in Pacific Time, I don't
know a-priori if that's UTC-0800 or UTC-0700 because of daylight savings
time. If there's an easy way to take that into account, that would be
nifty.

···

--
Posted via http://www.ruby-forum.com/.

Just curious.

A Unix epoch is UTC by definition, do you know what generates those
time zone dependent integers?

Xavier Noria wrote in post #1092798:

Just curious.

A Unix epoch is UTC by definition, do you know what generates those
time zone dependent integers?

Yes -- it's part of the GreenButton energy reporting standard. If
you're feeling masochistic, see:
   http://www.openespi.org/
   REQ.21 – Energy Services Provider Interface

I dug down into the xls code and it appears that they're ignoring
timezones altogether. Since a billing interval of "midnight to
midnight" is always in the context of the local time, this is probably a
reasonable approach.

Now that I think about it, I could just adopt that technique as well, in
which case I can always coerce to UTC:

  t = Time.at(1325376000).to_datetime.new_offset("00:00")

Perhaps there's a simpler way?

···

--
Posted via http://www.ruby-forum.com/\.

  t = Time.at(1325376000).to_datetime.new_offset("00:00")

Perhaps there's a simpler way?

Not much simpler:

DateTime.strptime(1325376000.to_s,'%s')

···

--
Posted via http://www.ruby-forum.com/\.