©
serviceprofessionalgmbh
Unfortunately the conversion functions of DATE() are not available on all platforms.
This is why we include this example which will always work. If certain that the function will not be called outside OS/390,
the additional coding effort could not be justified.
/* REXX
Eingabe: tt.mm.jjjj,[-]n Ausgabe: tt.mm.jjjj
*/
arg datum,tage
parse var datum #tt "." #mm "." #jjjj
#tage_m="31 28 31 30 31 30 31 31 30 31 30 31"
#tage_j="365"
if schaltjahr(#jjjj) then do
#tage_m=overlay('9',#tage_m,5,1)
#tage_j="366"
end
#ttt=#tt
do idx=1 to #mm-1
#ttt=#ttt + word(#tage_m,idx)
end
#ttt=right(#ttt,3,'0')
#tt1=#ttt + tage
select
when #tt1 > #tage_j then do /** ins nächste Jahr *****/
do while #tt1 > #tage_j
if schaltjahr(#jjjj) then #tage_j=366
else #tage_j=365
#jjjj=#jjjj+1
#tt1=#tt1-#tage_j
end
end
when #tt1 < 1 then do /** ins letzte Jahr *****/
do while #tt1 < 1
#jjjj=#jjjj-1
if schaltjahr(#jjjj) then #tage_j=366
else #tage_j=365
#tt1=#tt1+#tage_j
end
end
otherwise nop
end
return dj2dn(#jjjj!!right(#tt1,3,0))
SCHALTJAHR: PROCEDURE
arg JAHR
RETURN (JAHR // 4 = 0) - (JAHR // 100 = 0) + (JAHR // 400 = 0)
DJ2DN: /* Date Julian to Date Normal */
parse value arg(1) with 1 JJJJ 5 TTT
MON="31 28 31 30 31 30 31 31 30 31 30 31"
if schaltjahr(JJJJ) then MON=overlay('9',MON,5,1)
do CNT=1 while TTT > word(MON,cnt)
TTT=TTT-word(MON,cnt)
end
return right(TTT,2,0)"."right(CNT,2,0)"."JJJJ
back to Date & Time