Help converting DateTime from UTC

G

Geary Eppley

I trying to convert a parsed time of "2005-12-01T18:00:00Z" to the local
equivalent.

I'm current in -800 (PST) and so and doing the following:
DateTime.parse("2005-12-01T18:00:00Z").new_offset(-8.0/24)

What I get is very close, but not what I would expect:
2005-12-01T09:59:59-0800

How do I get this to show 10:00:00? I don't really care about the
seconds, so if there is no easy solution, I'll have to write a method to
round to the nearest minute.

Thanks,
Geary
 
K

Kirk Haines

I trying to convert a parsed time of "2005-12-01T18:00:00Z" to the local
equivalent.

I'm current in -800 (PST) and so and doing the following:
DateTime.parse("2005-12-01T18:00:00Z").new_offset(-8.0/24)

What I get is very close, but not what I would expect:
2005-12-01T09:59:59-0800

DateTime.parse("2005-12-01T18:00:00Z").new_offset(Rational(-8,24))


Kirk Haines
 
P

Park Heesob

Hi,
----- Original Message -----
From: "Geary Eppley" <[email protected]>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <[email protected]>
Sent: Sunday, December 04, 2005 9:03 AM
Subject: Help converting DateTime from UTC

I trying to convert a parsed time of "2005-12-01T18:00:00Z" to the local
equivalent.

I'm current in -800 (PST) and so and doing the following:
DateTime.parse("2005-12-01T18:00:00Z").new_offset(-8.0/24)

What I get is very close, but not what I would expect:
2005-12-01T09:59:59-0800

How do I get this to show 10:00:00? I don't really care about the
seconds, so if there is no easy solution, I'll have to write a method to
round to the nearest minute.

Try
DateTime.parse("2005-12-01T18:00:00Z").new_offset(Rational(-8,24))

HTH,

Park Heesob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top