forked from kodamail/gscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dayofyear.gsf
28 lines (26 loc) · 864 Bytes
/
dayofyear.gsf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function dayofyear( time )
length = math_strlen( time )
year = substr( time, length-3, 4 )
cmonth = substr( time, length-6, 3 )
cmonth = chcase( cmonth, 'upper' )
day = substr( time, length-8, 2 )
if( cmonth = 'JAN' ) ; month = 1 ; endif
if( cmonth = 'FEB' ) ; month = 2 ; endif
if( cmonth = 'MAR' ) ; month = 3 ; endif
if( cmonth = 'APR' ) ; month = 4 ; endif
if( cmonth = 'MAY' ) ; month = 5 ; endif
if( cmonth = 'JUN' ) ; month = 6 ; endif
if( cmonth = 'JUL' ) ; month = 7 ; endif
if( cmonth = 'AUG' ) ; month = 8 ; endif
if( cmonth = 'SEP' ) ; month = 9 ; endif
if( cmonth = 'OCT' ) ; month = 10 ; endif
if( cmonth = 'NOV' ) ; month = 11 ; endif
if( cmonth = 'DEC' ) ; month = 12 ; endif
doy = 0
m = 1
while( m < month )
doy = doy + days( year, m )
m = m + 1
endwhile
doy = doy + day
return doy