1

The Question already exists in stackoverflow, but it didn't solve my problem. The function getDate calculate number of days based on 3 parameters.

But I always get this error: value too great for base (error token is "09") line 7 val= ..

function getDate (){
    d=$1
    m=$2
    y=$3
    m=$(((m+9) % 12))
    y=$((y - m/10))
    val=$((365*y + y/4 - y/100 + y/400 + (m*306 + 5)/10 + ( d - 1 )))
    return $val
}
Community
  • 1
  • 1
Ale_
  • 85
  • 7

1 Answers1

2

It is because because of leading 0 shell treats 09 as an octal value and obviously 09 is an invalid octal value.

anubhava
  • 761,203
  • 64
  • 569
  • 643