/*--------------------------------------------------------------------*/ /* Analog of Enterprise PL/I 'secs()' builtin. */ /* This procedure returns a FLOAT BINARY(53) value which is the */ /* number of seconds (based on Lilian format) corresponding to */ /* the current date. It is the equivalent of the IBM Enterprise */ /* PL/I builtin SECS() with no arguments. */ /* It uses the date returned by the DATETIME() builtin with no */ /* provision to adjust for timezone. If necessary the result can */ /* be adjusted by 3600 seconds for each hour of timezone difference. */ /* */ /* This code is based on the Rexx functions 'CONVERT1' and */ /* 'CONVERT3' by Harold Zbiegien from the Rexx archives at the */ /* University of Georgia (USA): */ /*http://www.listserv.uga.edu/cgi-bin/wa?A2=ind9704&L=rexxlist&P=14979*/ /* */ /*------------------------------------------------------------------- */ secs: proc returns( float bin(53) ); dcl 1 date_time, 5 year pic '9999', 5 month pic '99', 5 day pic '99', 5 hours pic '99', 5 minutes pic '99', 5 seconds pic '99', 5 useconds pic '999'; dcl (n,ly,yr) fixed bin(31); dcl r float bin(53); string(date_time) = datetime(); /* Leap year determination */ yr = date_time.year; if mod(yr,4)=0 then ly=1; else ly=0; if mod(yr,100)=0 then ly=0; if mod(yr,400)=0 then ly=1; /* Convert date to Julian */ n = floor( (date_time.month+2)*3055/100 ) + date_time.day-91; if n>(ly+59) then n=n-2+ly; /* Convert Julian date to Lilian */ yr = yr-1201; ly = floor( (yr*36525)/100 ) - 139444 + n - floor( yr/100 ) + floor( yr/400 ); /* Lilian date in seconds */ r = float(ly)*86400; /* Plus time in seconds */ n = date_time.hours; r = r + float(n) * 3600 + date_time.minutes*60 + date_time.seconds; return(r); end secs;