ParseDate.parsedate() and Time.now()

P

Patrick Spence

irb(main):029:0> timeNow = Time.now().to_s()
=> "Fri Aug 11 11:03:36 Central Daylight Time 2006"

irb(main):030:0> ParseDate.parsedate(timeNow)
=> [nil, 8, 11, 11, 3, 36, "Central", 5]

Seems to me that it should return this:
=> [2006, 8, 11, 11, 3, 36, "Central", 5]

Or is it just me?
 
K

Ken Bloom

irb(main):029:0> timeNow = Time.now().to_s()
=> "Fri Aug 11 11:03:36 Central Daylight Time 2006"

irb(main):030:0> ParseDate.parsedate(timeNow)
=> [nil, 8, 11, 11, 3, 36, "Central", 5]

Seems to me that it should return this:
=> [2006, 8, 11, 11, 3, 36, "Central", 5]

Or is it just me?

It's you. Specifically, something's wrong with your locale, because
"Central Daylight Time" should actually be replaced with the abbreviation
"CDT".

irb(main):001:0> timeNow = Time.now().to_s()
=> "Fri Aug 11 13:49:07 CDT 2006"
irb(main):002:0> ParseDate.parsedate(timeNow)
=> [2006, 8, 11, 13, 49, 7, "CDT", 5]
 
P

Patrick Spence

irb(main):029:0> timeNow = Time.now().to_s()
=> "Fri Aug 11 11:03:36 Central Daylight Time 2006"

irb(main):030:0> ParseDate.parsedate(timeNow)
=> [nil, 8, 11, 11, 3, 36, "Central", 5]

Seems to me that it should return this, note the year in the 1st element
=> [2006, 8, 11, 11, 3, 36, "Central", 5]

The point I was trying to make is that the 1st element of the array
returned by parsedate() seems that it should contain the year 2006,
intstead of a nil.

As for the issue of returning "Central" vs "CST" or "CDT", I'm not
overly concerned with that at this time. No doubt, that will change.
 
A

Austin Ziegler

As for the issue of returning "Central" vs "CST" or "CDT", I'm not
overly concerned with that at this time. No doubt, that will change.

I'm not sure it'll change. You're on Windows, and Windows is stupid
this way, preferring to spell out "Central Daylight Time" instead of
"CDT"; I have yet to figure out how to get the output from a Windows
format string to be abbreviated or better yet to return a +/- offset.

It is the "Central Daylight Time" that is causing the parsing to be
incorrect, because most date systems are sensible.

It may be worth reporting a bug to the tracker on RubyForge.org. If
you can figure out a patch, that's even better and you can also put it
in the same place.

-austin
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top