Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 218283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:44:10+00:00 2026-05-11T18:44:10+00:00

I am refactoring some code for a Ruby library. This code includes a Date

  • 0

I am refactoring some code for a Ruby library. This code includes a Date parser.
One of the tests was to parse this string “2008-02-20T8:05:00-010:00” which is supposed to be ISO 8601.

The previous code would actually output: “Wed Feb 20 18:05:00 UTC 2008”.
My new code outputs that: “Wed Feb 20 16:05:00 UTC 2008”.

My question is: which one is the right one?

Time.parse in Ruby gives the second one. But again, I want to be 100% sure that the previous code AND test were buggy.

Which one is right? (By maybe parsing the string with a library in another language? – I only know Ruby.)

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:44:11+00:00Added an answer on May 11, 2026 at 6:44 pm

    The correct UTC time is 1805. The time group indicates 0805 in zone -10, so to get UTC add the 10 to the given time. Thus 1805. Since 1805 is less than 2400 it’s the same day.

    If your code is giving 1605, then you almost certainly have the timezone set incorrectly to zone -8, which happens to be Pacific Standard Time.


    Aha, looks like your input format is messed up. Observe:

    irb(main):003:0> Time.parse("2008-02-20T8:05:00-010:00") 
    => Wed Feb 20 08:05:00 -0700 2008
    

    I happen to be in zone -7 so it’s suiting that to my locale. But

    irb(main):004:0> t=Time.parse("2008-02-20T8:05:00-010:00")
    => Wed Feb 20 08:05:00 -0700 2008
    irb(main):005:0> t
    => Wed Feb 20 08:05:00 -0700 2008
    irb(main):006:0> t.getutc
    => Wed Feb 20 15:05:00 UTC 2008
    

    I’m getting an unexpected result. Now observe:

    irb(main):007:0> t=Time.parse("2008-02-20T8:05:00-10:00")
    => Wed Feb 20 11:05:00 -0700 2008
    irb(main):008:0> t.getutc
    => Wed Feb 20 18:05:00 UTC 2008
    

    There’s the expected result. See the difference? First example vs second:

    irb(main):004:0> t=Time.parse("2008-02-20T8:05:00-010:00")
    irb(main):007:0> t=Time.parse("2008-02-20T8:05:00-10:00")
    

    I took the spurious extra 0 out (which I certainly didn’t notice either) and whoosh, it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 162k
  • Answers 162k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The API document is on a wiki page, it may… May 12, 2026 at 12:03 pm
  • Editorial Team
    Editorial Team added an answer If you put a ContentPresenter as a placeholder you can… May 12, 2026 at 12:03 pm
  • Editorial Team
    Editorial Team added an answer I do not like this approach. IMHO , it is… May 12, 2026 at 12:03 pm

Related Questions

I'm writing a microformats parser in C# and am looking for some refactoring advice.
In fairly large Ruby application, we have a situation where a given object is
I am refactoring some MFC code that is littered with ASSERT statements, and in
I am refactoring some code that I did not write, and I found a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.