# ParseDate.parsedate() and Time.now()

**URL:** <https://www.ruby-forum.com/t/parsedate-parsedate-and-time-now/102148>\
**Category:** Ruby\
**Created:** [August 11, 2006, 6:10pm UTC](https://www.ruby-forum.com/t/parsedate-parsedate-and-time-now/102148 "2006-08-11T18:10:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkspence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pkspence](https://www.ruby-forum.com/u/pkspence)\
**Post date:** [August 11, 2006, 6:10pm UTC](https://www.ruby-forum.com/t/parsedate-parsedate-and-time-now/102148/1 "2006-08-11T18:10:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pkspence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pkspence](https://www.ruby-forum.com/u/pkspence)\
**Post date:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/parsedate-parsedate-and-time-now/102148/2 "2006-08-15T14:17:15Z")

</div>

On Sat, 12 Aug 2006 01:10:58 +0900, Patrick S. 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]

---

<div class="post-metadata">

**Author:** ![pkspence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pkspence](https://www.ruby-forum.com/u/pkspence)\
**Post date:** [August 15, 2006, 2:49pm UTC](https://www.ruby-forum.com/t/parsedate-parsedate-and-time-now/102148/3 "2006-08-15T14:49:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pkspence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pkspence](https://www.ruby-forum.com/u/pkspence)\
**Post date:** [August 15, 2006, 6:14pm UTC](https://www.ruby-forum.com/t/parsedate-parsedate-and-time-now/102148/4 "2006-08-15T18:14:59Z")

</div>

“Austin Z.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> incorrect, because most date systems are sensible.  
> It’s time to make use of missing/strftime.c when on Windows.

---

<div class="post-metadata">

**Author:** ![pkspence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pkspence](https://www.ruby-forum.com/u/pkspence)\
**Post date:** [August 15, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/parsedate-parsedate-and-time-now/102148/5 "2006-08-15T15:13:23Z")

</div>

On 8/15/06, Patrick S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://RubyForge.org). If  
you can figure out a patch, that’s even better and you can also put it  
in the same place.

-austin
