REXX Convert SMF Time to/from
readable goto
homepage
SMF Time in “lesbares” Format umstellen oder umgekehrt – der Aufruf kann
sowohl per Programm (REXX) als auch als Line-Command erfolgen
/*
REXX YSMFT Copyright YCOS Yves
Colliard Software 2009-09 V1.0 */
/*--------------------------------------------------------------------*/
/* YSMFT - Convert hhmmss to SMF
Binary time format and back */
/*--------------------------------------------------------------------*/
/* REXX Tool
*/
/**********************************************************************/
/* V1.0 - 01.07.2009 - first
release
*/
/*--------------------------------------------------------------------*/
/* Syntax:
*/
/* YSMFT toSMF/toHHMMSS hhmmss<.mm>/smf_time <INT>> */
/* parms
*/
/* toSMF hhmmss<.mm> z.B. 080000 */
/* toHHMMSS smf_time z.B. 002BF200 */
/* Int = blank -> say the result */
/* Int = "INT" -> return
result */
/*
rc"/"date or msg */
/*====================================================================*/
/* */
/* TRACE ?R */
/* einschalten des interaktiven Trace
Modus */
/* */
arg Form Zeit Int
select
when Form="TOSMF" then do
/* */
if
DataType(Zeit) <> "NUM" then do
call retour "8/Time Format
Error - not Num"
end
if
Length(Zeit) < 6 then
do
call retour "8/Time Format
Error - not 6 Chars"
end
if
Length(Zeit) > 9 then
do
call retour "8/Time Format
Error - more than 9 Chars"
end
parse
var Zeit ZeitH +2 ZeitM +2 ZeitS + 2 Deci
select
when Deci="" then do
Deci = 0
end
when left(Deci,1)<>"."
then do
call retour "8/Time Format Error
- Decimal point" Deci
end
when
datatype(substr(Deci,2))<>"NUM" then do
call retour "8/Time Format Error
- Decimal not NUM" Deci
end
otherwise
Deci =
left(substr(Deci,2)"00",2)
end
if
ZeitH > 23 then do
call retour "8/Time Format
Error - HH > 23 -" ZeitH
end
if
ZeitM > 59 then do
call retour "8/Time Format
Error - MM > 59 -" ZeitM
end
if
ZeitS > 59 then do
call retour "8/Time Format
Error - SS > 59 -" ZeitS
end
Numeric
Digits 64
M
= (ZeitH * 60) + ZeitM
S
= (M * 60) + ZeitS
TS
= S * 100
TS
= TS + Deci
call retour
"0/"right("000000000"D2X(TS),8)
end
when Form="TOHHMMSS" then do
/* */
Numeric Digits 20 /* increase significant digits to 20
*/
signal
on Syntax Name Return12
hsec
= X2D(Zeit)
/* 100s seconds */
times
= hsec%100
hsec
= hsec//100
sec
= times//60 /* seconds */
timem
= times%60
min
= timem//60
/* minutes */
timeh
= timem%60
hrs
= timeh//24
/* hours */
call retour
"0/"y(Hrs,2)":"y(Min,2)":"y(sec,2)"."y(hsec,3)
end
otherwise
call retour "8/Parameter Error:
toSMF / toHHMMSS"
end
exit
/* */
Return12:
select
when Form="TOSMF" then do
call retour "12/Syntax Error in
toSTCK - Parms:" form zeit
end
when Form="TOHHMMSS" then do
call retour "12/Syntax Error in
toHHMMSS - Parms:" form zeit
end
otherwise
call retour "12/Syntax
Error"
end
/* */
retour:
if Int="INT" then do
exit arg(1)
end
else do
parse value arg(1) with retc
"/" txt
say txt
exit retc
end
/* */
y: procedure
return right(copies("0",arg(2))""arg(1),arg(2))