Is '1582-10-12' an invalid date?

Hi,

I guess this is a bug:

$ irb

require 'date'

=> true

Date.strptime('1582-11-12', '%Y-%m-%d')

=> #<Date: 1582-11-12 ((2299189j,0s,0n),+0s,2299161j)>

Date.strptime('1582-10-12', '%Y-%m-%d')

ArgumentError: invalid date
  from (irb):9:in `strptime'
  from (irb):9
  from /usr/bin/irb:11:in `<main>'

I does not understand why '1582-10-12' is not considered a valid date.
I'm testing it with Ruby 2.1.5p273, that comes with Debian Jessie.

Regards,
Daniel

Date.strptime does not support dates that are pre-unix time (January 1st 1970)

···


Sent from Mailbox

On Mon, Jun 15, 2015 at 3:00 PM, Daniel Hernandez <daniel@degu.cl> wrote:

Hi,
I guess this is a bug:
$ irb

require 'date'

=> true

Date.strptime('1582-11-12', '%Y-%m-%d')

=> #<Date: 1582-11-12 ((2299189j,0s,0n),+0s,2299161j)>

Date.strptime('1582-10-12', '%Y-%m-%d')

ArgumentError: invalid date
  from (irb):9:in `strptime'
  from (irb):9
  from /usr/bin/irb:11:in `<main>'
I does not understand why '1582-10-12' is not considered a valid date.
I'm testing it with Ruby 2.1.5p273, that comes with Debian Jessie.
Regards,
Daniel

Thanks Alec!

By the way, some one knows a Ruby module that validates XML Schema datatypes (as xsd:date)?

Regards,
Daniel

---- Activado lun, 15 jun 2015 18:03:23 -0400 Alec Joy<alec.joy39@gmail.com> escribió ----

···

Date.strptime does not support dates that are pre-unix time (January 1st 1970)

>
> —
> Sent from Mailbox
>
>
> On Mon, Jun 15, 2015 at 3:00 PM, Daniel Hernandez <daniel@degu.cl> wrote:
>
> Hi,
>
> I guess this is a bug:
>
> $ irb
> > require 'date'
> => true
> > Date.strptime('1582-11-12', '%Y-%m-%d')
> => #<Date: 1582-11-12 ((2299189j,0s,0n),+0s,2299161j)>
> > Date.strptime('1582-10-12', '%Y-%m-%d')
> ArgumentError: invalid date
> from (irb):9:in `strptime'
> from (irb):9
> from /usr/bin/irb:11:in `<main>'
>
> I does not understand why '1582-10-12' is not considered a valid date.
> I'm testing it with Ruby 2.1.5p273, that comes with Debian Jessie.
>
> Regards,
> Daniel
>
>
>
>
>

Coincidentally (?), days 5..14 do not exist for October 1582.

The AS core extensions guide documents this tidbit:

http://guides.rubyonrails.org/active_support_core_extensions.html#extensions-to-date-calculations

There's some historical background here

    https://en.wikipedia.org/wiki/Gregorian_calendar

Xavier

Wow! Thus, date module is OK.

Regards,
Daniel

---- Activado lun, 15 jun 2015 18:07:26 -0400 Xavier Noria<fxn@hashref.com> escribió ----

···

Coincidentally (?), days 5..14 do not exist for October 1582.

>
>
> The AS core extensions guide documents this tidbit:
>
>
> Active Support Core Extensions — Ruby on Rails Guides
>
>
> There's some historical background here
>
>
> Gregorian calendar - Wikipedia
>
>
> Xavier
>
>
>
>