Having problems create a function to convert julian date to a date format of YYYYMMDD. Not sure If im doing this right.
I getting an error code
./j2g[3]: 0403-057 Syntax error at line 6 : `jd=$1' is not expected.
#!/bin/ksh
+2
+3 function juliandate_to_gregdate{
+4
+5 jd=${1}
+6
+7 typeset -i l= ${jd} + 68569
+8 echo ${l}
+9 typeset -i n=(( 4 * ${l} ) / 146097)
+10 echo ${n}
+11 ${l} = ${l} - (( 146097 * ${n} + 3 ) / 4)
+12 echo ${l}
+13 typeset -i i=(( 4000 * ( ${l} + 1 ) ) / 1461001)
+14 echo ${i}
+15 ${l} = ${l} - ((( 1461 * ${i} ) / 4) + 31)
+16 echo ${l}
+17 typeset -i j=( 80 * ${l} ) / 2447
+18 echo ${j}
+19 typest -i d=${l} - (( 2447 * ${j} ) / 80)
+20 echo ${d}
+21 ${l} = (${j} / 11)
+22 echo ${l}
+23 typeset -i m=${j} + 2 - ( 12 * ${l} )
+24 echo ${m}
+25 typeset -i y=100 * ( ${n} - 49 ) + ${i} + ${l}
+26 echo ${y}
+27 typeset -i gregdate=${ y}${m}${d}
+28 echo $gredate
+29 }
I getting an error code
./j2g[3]: 0403-057 Syntax error at line 6 : `jd=$1' is not expected.
#!/bin/ksh
+2
+3 function juliandate_to_gregdate{
+4
+5 jd=${1}
+6
+7 typeset -i l= ${jd} + 68569
+8 echo ${l}
+9 typeset -i n=(( 4 * ${l} ) / 146097)
+10 echo ${n}
+11 ${l} = ${l} - (( 146097 * ${n} + 3 ) / 4)
+12 echo ${l}
+13 typeset -i i=(( 4000 * ( ${l} + 1 ) ) / 1461001)
+14 echo ${i}
+15 ${l} = ${l} - ((( 1461 * ${i} ) / 4) + 31)
+16 echo ${l}
+17 typeset -i j=( 80 * ${l} ) / 2447
+18 echo ${j}
+19 typest -i d=${l} - (( 2447 * ${j} ) / 80)
+20 echo ${d}
+21 ${l} = (${j} / 11)
+22 echo ${l}
+23 typeset -i m=${j} + 2 - ( 12 * ${l} )
+24 echo ${m}
+25 typeset -i y=100 * ( ${n} - 49 ) + ${i} + ${l}
+26 echo ${y}
+27 typeset -i gregdate=${ y}${m}${d}
+28 echo $gredate
+29 }