On Feb 2, 6:58 pm, Peter Bailey <pbai... / bna.com> wrote:
> I need to check some file dates against the budgetary periods of our
> company, to determine where those files get placed. I'm playing with the
> Time.local object. I've proven that I can denote which budget period I'm
> in by using the .between? method. But, I get this weird "octal digit"
> error with some of my date entries.
>
> irb(main):001:0> t = Time.local(2007,09,09,00,00)
> SyntaxError: compile error
> (irb):1: Illegal octal digit
> t = Time.local(2007,09,09,00,00)
>                       ^
> (irb):1: Illegal octal digit
> t = Time.local(2007,09,09,00,00)
>                          ^

The problem is the leading zero. Time.local(2007, 9, 9, 0, 0) works
fine.

Number literals with a zero at the beginning are interpreted as octal
numbers. Since octal numbers only use digits 0..7, 9 is rejected (as
would be 8).

HTH,
AdSR

>
> I don't get the error when I specify the following date. It doesn't seem
> to like the month of September. (-;
>
> irb(main):005:0> t = Time.local(2007,01,01,00,00)
> => Mon Jan 01 00:00:00 -0500 2007
>
> Thanks,
> Peter
>
> --
> Posted viahttp://www.ruby-forum.com/.