|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
Date.parse("28/03/2008") gives me an error? I get: ArgumentError: invalid date. Any ideas how to fix this? Versions: Ruby 1.8.6 Rails 2.0.2 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Hello,
On Sun, Jun 8, 2008 at 12:35 PM, Greg Hauptmann <greg.hauptmann.ruby@gmail.com> wrote: > > Date.parse("28/03/2008") gives me an error? Try: Date.parse("03/28/2008") -- Nico |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
but that's not the format I get the data in
I'm in Australia.Any ideas? On 6/8/08, Nicolas Pelletier <nicolas.pelletier3@gmail.com> wrote: > Hello, > > On Sun, Jun 8, 2008 at 12:35 PM, Greg Hauptmann > <greg.hauptmann.ruby@gmail.com> wrote: >> >> Date.parse("28/03/2008") gives me an error? > > Try: > > Date.parse("03/28/2008") > > -- > Nico > > |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Jun 8, 12:04am, Greg Hauptmann <greg.hauptmann.r...@gmail.com>
wrote: > but that's not the format I get the data in I'm in Australia.> > Any ideas? > > On 6/8/08, Nicolas Pelletier <nicolas.pelleti...@gmail.com> wrote: > > > Hello, > > > On Sun, Jun 8, 2008 at 12:35 PM, Greg Hauptmann > > <greg.hauptmann.r...@gmail.com> wrote: > > >> Date.parse("28/03/2008") gives me an error? > > > Try: > > > Date.parse("03/28/2008") > > > -- > > Nico > > Perhaps this link I found can be of use: http://source.mihelac.org/2006/9/13/...-in-ruby-rails -- MilesZS |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Jun 7, 2008, at 9:43 PM, miles.sterrett@gmail.com wrote: > On Jun 8, 12:04 am, Greg Hauptmann <greg.hauptmann.r...@gmail.com> > wrote: >> but that's not the format I get the data in I'm in Australia.>> >> Any ideas? >> >> On 6/8/08, Nicolas Pelletier <nicolas.pelleti...@gmail.com> wrote: >> >>> Hello, >> >>> On Sun, Jun 8, 2008 at 12:35 PM, Greg Hauptmann >>> <greg.hauptmann.r...@gmail.com> wrote: >> >>>> Date.parse("28/03/2008") gives me an error? >> >>> Try: >> >>> Date.parse("03/28/2008") >> >>> -- >>> Nico >> >> > > Perhaps this link I found can be of use: > http://source.mihelac.org/2006/9/13/...-in-ruby-rails That would work, but so would this: Date.strptime('28/03/2008', '%d/%m/%Y') Ray |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
[Note: parts of this message were removed to make it a legal post.]
excellent thanks, You'd think Ruby would provide some internationalisation type way of solving this? (e.g. specifying your location/country or something). Guess not? On Sun, Jun 8, 2008 at 3:13 PM, Ray Baxter <ray.baxter@gmail.com> wrote: > > On Jun 7, 2008, at 9:43 PM, miles.sterrett@gmail.com wrote: > > On Jun 8, 12:04 am, Greg Hauptmann <greg.hauptmann.r...@gmail.com> >> wrote: >> >>> but that's not the format I get the data in I'm in Australia.>>> >>> Any ideas? >>> >>> On 6/8/08, Nicolas Pelletier <nicolas.pelleti...@gmail.com> wrote: >>> >>> Hello, >>>> >>> >>> On Sun, Jun 8, 2008 at 12:35 PM, Greg Hauptmann >>>> <greg.hauptmann.r...@gmail.com> wrote: >>>> >>> >>> Date.parse("28/03/2008") gives me an error? >>>>> >>>> >>> Try: >>>> >>> >>> Date.parse("03/28/2008") >>>> >>> >>> -- >>>> Nico >>>> >>> >>> >>> >> Perhaps this link I found can be of use: >> >> http://source.mihelac.org/2006/9/13/...-in-ruby-rails >> > > That would work, but so would this: > > Date.strptime('28/03/2008', '%d/%m/%Y') > > > > Ray > > > > |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Greg Hauptmann wrote:
> excellent thanks, > You'd think Ruby would provide some internationalisation type way of > solving > this? (e.g. specifying your location/country or something). Guess not? Hello, Unfortunately for me, the solution by Ray doesn't seem to work too. For instance I'm doing this.. dateStr = params[:startdate].to_s logger.info "date - " + dateStr startdate =Date.strptime(dateStr, '%m/%d/%Y').to_s and though I get the string quite correctly as date - 05/16/2008 I end up getting the ArgumentError - invalid date. Please let me know if I am doing anything incorrect here. Regards, Shankar. -- Posted via http://www.ruby-forum.com/. |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
> Unfortunately for me, the solution by Ray doesn't seem to work too. For
> instance I'm doing this.. > > dateStr = params[:startdate].to_s > logger.info "date - " + dateStr > startdate =Date.strptime(dateStr, '%m/%d/%Y').to_s > > and though I get the string quite correctly as > > date - 05/16/2008 > > I end up getting the ArgumentError - invalid date. Please let me know if > I am doing anything incorrect here. Doesn't look like it. Date.strptime("05/16/2008", '%m/%d/%Y').to_s works for me. |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
Mark Thomas wrote:
>> >> I end up getting the ArgumentError - invalid date. Please let me know if >> I am doing anything incorrect here. > > Doesn't look like it. > Date.strptime("05/16/2008", '%m/%d/%Y').to_s > works for me. Does it have anything to do with the version of Ruby/Rails ? I'm using Rails 1.1.6 and Ruby 1.8.4. Another wierd thing about this is dateStr.to_time works while dateStr.to_date again gives me the same exception. -- Posted via http://www.ruby-forum.com/. |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
On Jun 25, 10:31am, Shankar Narayanan <subscribe...@gmail.com> wrote:
> Mark Thomas wrote: > > >> I end up getting the ArgumentError - invalid date. Please let me know if > >> I am doing anything incorrect here. > > > Doesn't look like it. > > Date.strptime("05/16/2008", '%m/%d/%Y').to_s > > works for me. > > Does it have anything to do with the version of Ruby/Rails ? I'm using > Rails 1.1.6 and Ruby 1.8.4. Another wierd thing about this is > dateStr.to_time works while dateStr.to_date again gives me the same > exception. It might. I'm using 1.8.6 |
|
![]() |
| Outils de la discussion | |
|
|