# Parsedate doesn't work on Time.now.to\_s

**URL:** <https://rubytalk.org/t/parsedate-doesnt-work-on-time-now-to-s/27104>\
**Category:** ruby-talk\
**Created:** [2 May 2006 19:53 UTC](https://rubytalk.org/t/parsedate-doesnt-work-on-time-now-to-s/27104 "2006-05-02T19:53:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Berger\_Daniel1](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@Berger\_Daniel1](https://rubytalk.org/u/Berger_Daniel1)\
**Post date:** [2 May 2006 19:53 UTC](https://rubytalk.org/t/parsedate-doesnt-work-on-time-now-to-s/27104/1 "2006-05-02T19:53:02Z")

</div>

> From: list-bounce@example.com  
> [mailto:list-bounce@example.com] On Behalf Of Julian Gall  
> Sent: Tuesday, May 02, 2006 1:22 PM  
> To: ruby-talk ML  
> Subject: parsedate doesn't work on Time.now.to\_s
> 
> require 'parsedate'  
> Time.now  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=\> Tue May 02 20:17:57 GMT Standard Time 2006  
> ParseDate.parsedate(Time.now.to\_s)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=\> [nil, 5, 2, 20, 17, 57, "GMT", 2]
> 
> It seems that parsedate is not able to detect the year from  
> the standard  
> string conversion of a date/time. Is there another way to do  
> this? Is it  
> the same in the US as for me here in the UK? It seems rather  
> inconsistent.
> 
> Julian

It's not an issue specific to the UK:

irb(main):003:0\> Time.now.to\_s  
=\> "Tue May 02 13:46:27 Mountain Daylight Time 2006"  
irb(main):043:0\> ParseDate.parsedate(Time.now.to\_s)  
=\> [nil, 5, 2, 13, 46, 18, "Mountain", 2]

The problem is that ParseDate does not handle long time zone  
names, only abbreviated forms. Consider:

irb(main):006:0\> time = "Tue May 02 13:46:27 MST 2006"  
=\> "Tue May 02 13:46:27 MST 2006"  
irb(main):007:0\> ParseDate.parsedate(time)  
=\> [2006, 5, 2, 13, 46, 27, "MST", 2]

Regards,

Dan

This communication is the property of Qwest and may contain confidential or  
privileged information. Unauthorized use of this communication is strictly  
prohibited and may be unlawful. If you have received this communication  
in error, please immediately notify the sender by reply e-mail and destroy  
all copies of the communication and any attachments.
