Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
funny date parsing
Junkone
4/4/2008 6:45:00 PM
i enter 2008 and it becomes 0008
irb(main):009:0> Date.parse("04-Feb-08").strftime('%Y-%m-%d')
=> "0008-02-04"
4 Answers
David A. Black
4/4/2008 6:51:00 PM
0
Hi --
On Sat, 5 Apr 2008, Junkone wrote:
> i enter 2008 and it becomes 0008
>
> irb(main):009:0> Date.parse("04-Feb-08").strftime('%Y-%m-%d')
> => "0008-02-04"
You've entered 08, not 2008.
David
--
Rails training from David A. Black and Ruby Power and Light:
ADVANCING WITH RAILS April 14-17 New York City
INTRO TO RAILS June 9-12 Berlin
ADVANCING WITH RAILS June 16-19 Berlin
See
http://www.r...
for details and updates!
Junkone
4/4/2008 6:55:00 PM
0
On Apr 4, 2:51 pm, "David A. Black" <dbl...@rubypal.com> wrote:
> Hi --
>
> On Sat, 5 Apr 2008, Junkone wrote:
> > i enter 2008 and it becomes 0008
>
> > irb(main):009:0> Date.parse("04-Feb-08").strftime('%Y-%m-%d')
> > => "0008-02-04"
>
> You've entered 08, not 2008.
>
> David
>
> --
> Rails training from David A. Black and Ruby Power and Light:
> ADVANCING WITH RAILS April 14-17 New York City
> INTRO TO RAILS June 9-12 Berlin
> ADVANCING WITH RAILS June 16-19 Berlin
> See
http://www.ruby...
details and updates!
oh ok. but all my date formats are like that and i am trying to import
it. is n't there a y2k rule somewhere on detecting 08 as 2008. i could
be wrong. can someone give me a workaround there.
seede
Chris Shea
4/4/2008 7:03:00 PM
0
On Apr 4, 12:55 pm, Junkone <junko...@gmail.com> wrote:
> On Apr 4, 2:51 pm, "David A. Black" <dbl...@rubypal.com> wrote:
>
>
>
> > Hi --
>
> > On Sat, 5 Apr 2008, Junkone wrote:
> > > i enter 2008 and it becomes 0008
>
> > > irb(main):009:0> Date.parse("04-Feb-08").strftime('%Y-%m-%d')
> > > => "0008-02-04"
>
> > You've entered 08, not 2008.
>
> > David
>
> > --
> > Rails training from David A. Black and Ruby Power and Light:
> > ADVANCING WITH RAILS April 14-17 New York City
> > INTRO TO RAILS June 9-12 Berlin
> > ADVANCING WITH RAILS June 16-19 Berlin
> > See
http://www.rubypal.com...
and updates!
>
> oh ok. but all my date formats are like that and i am trying to import
> it. is n't there a y2k rule somewhere on detecting 08 as 2008. i could
> be wrong. can someone give me a workaround there.
>
> seede
Date.parse has an optional second argument for handling near-2000 two-
digit years.
001:0> Date.parse('04-Feb-08', true).strftime('%Y-%m-%d')
"2008-02-04"
See documentation here:
http://www.ruby-doc.org/core/classes/Date.ht...
HTH,
Chris
Junkone
4/4/2008 7:09:00 PM
0
On Apr 4, 3:03 pm, Chris Shea <cms...@gmail.com> wrote:
> On Apr 4, 12:55 pm, Junkone <junko...@gmail.com> wrote:
>
>
>
>
>
> > On Apr 4, 2:51 pm, "David A. Black" <dbl...@rubypal.com> wrote:
>
> > > Hi --
>
> > > On Sat, 5 Apr 2008, Junkone wrote:
> > > > i enter 2008 and it becomes 0008
>
> > > > irb(main):009:0> Date.parse("04-Feb-08").strftime('%Y-%m-%d')
> > > > => "0008-02-04"
>
> > > You've entered 08, not 2008.
>
> > > David
>
> > > --
> > > Rails training from David A. Black and Ruby Power and Light:
> > > ADVANCING WITH RAILS April 14-17 New York City
> > > INTRO TO RAILS June 9-12 Berlin
> > > ADVANCING WITH RAILS June 16-19 Berlin
> > > See
http://www.rubypal.comfor...
updates!
>
> > oh ok. but all my date formats are like that and i am trying to import
> > it. is n't there a y2k rule somewhere on detecting 08 as 2008. i could
> > be wrong. can someone give me a workaround there.
>
> > seede
>
> Date.parse has an optional second argument for handling near-2000 two-
> digit years.
>
> 001:0> Date.parse('04-Feb-08', true).strftime('%Y-%m-%d')
> "2008-02-04"
>
> See documentation here:
http://www.ruby-doc.org/core/classes/Date.ht...
>
> HTH,
> Chris- Hide quoted text -
>
> - Show quoted text -
thanks for the info
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
funny date parsing
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password