Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > ParseDate.parsedate() and Time.now()

Reply
Thread Tools

ParseDate.parsedate() and Time.now()

 
 
Patrick Spence
Guest
Posts: n/a
 
      08-11-2006
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?

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

 
Reply With Quote
 
 
 
 
Ken Bloom
Guest
Posts: n/a
 
      08-11-2006
On Sat, 12 Aug 2006 01:10:58 +0900, Patrick Spence wrote:

> 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]


--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/
 
Reply With Quote
 
 
 
 
Patrick Spence
Guest
Posts: n/a
 
      08-15-2006
> 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.

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

 
Reply With Quote
 
Austin Ziegler
Guest
Posts: n/a
 
      08-15-2006
On 8/15/06, Patrick Spence <> wrote:
> 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
--
Austin Ziegler * * http://www.halostatue.ca/
* * http://www.halostatue.ca/feed/
*

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if and and vs if and,and titi VHDL 4 03-11-2007 05:23 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57