date formatting bug?
Why does the year get changed in this code?
s = '2998-12-31'
date = Date.parse(s)
f = date.strftime('%d-%b-%G')
The output is 31-Dec-2999.
This doesn't seem to happen with earlier years.
This happens with Ruby 1.8.6 and JRuby 1.2.0RC2.
Posted via http://www.ruby-forum.com/.
Re: date formatting bug?
Mark Volkmann <email@example.com> wrote:
> Why does the year get changed in this code?
> require 'date'
> s = '2998-12-31'
> date = Date.parse(s)
> f = date.strftime('%d-%b-%G')
It's because you asked for %G. If you wanted the actual year component
of the date, you would have used %Y. man strftime...
matt neuburg, phd = firstname.lastname@example.org, http://www.tidbits.com/matt/
Leopard - http://www.takecontrolbooks.com/leop...stomizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com
|All times are GMT. The time now is 08:46 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.