qtsmall1.nrx 29.11.2002 16:04:12
/*====================================================================*/
/* generated by the classic REXX to NetRexx converter */
/* (c) Thomas.Schneider@Donauland.at */
/*====================================================================*/
/* orig. REXX source: qtsmall1 */
/* generated at: 2002-11-29 10:46:55 */
/* with: rex_nrx.nrx vs. 4.00 pre 26 */
/* Rexx2Nrx options: */
/* Vars Localized: NO */
/* IO-method used : 3 ( RexxFile Object oriented ) */
/*====================================================================*/
import Rexx2Nrx.Rexx2RT.RexxTime
class qtsmall1
properties public static
/* ... Declare Global Numbers */
hour = int 0
min = int 0
sec = int 0
mod = int 0
/* ... Declare Global Strings */
parm = Rexx ''
testtime = Rexx ''
now = Rexx ''
out = Rexx ''
numbers = Rexx ''
/* ... Declare Global Stems / Arrays */
near = Rexx '' /*Stem!*/
method main(args=String[]) static
arg=Rexx(args) -- program arguments as single string
arg=arg -- avoid NetRexx warning
parse arg parm testtime .
select
when parm = '?' then do
tell()
end /*when*/
when parm = '' then do
end /*when*/
when parm = '-' then do
end /*when*/
otherwise do
say 'The only valid parameter to QT is "?". The argument'
say 'that you supplied ("'||parm||'") has been ignored.'
tell()
end /* otherwise */
end /* select */
if testtime = '' then do
now = RexxTime.time()
end
else do
now = testtime
end /*if*/
near[0] = ''
near[1] = ' just gone'
near[2] = ' just after'
near[3] = ' nearly'
near[4] = ' almost'
parse now hour ':' min ':' sec
if sec > 29 then do
min = min + 1
end /*if*/
mod = min // 5
out = "It's"||near[mod]
if min > 32 then do
hour = hour + 1
end /*if*/
min = min + 2
if ((hour // 12) = 0) & ((min // 60) <= 4) then do
if hour = 12 then do
say out 'Noon.'
end
else do
say out 'Midnight.'
end /*if*/
exit
end /*if*/
min = min - (min // 5)
if hour > 12 then do
hour = hour - 12
end
else do
if hour = 0 then do
hour = 12
end /*if*/
end /*if*/
select
when min = 0 then do
end /*when*/
when min = 60 then do
min = 0
end /*when*/
when min = 5 then do
out = out 'five past'
end /*when*/
when min = 10 then do
out = out 'ten past'
end /*when*/
when min = 15 then do
out = out 'a quarter past'
end /*when*/
when min = 20 then do
out = out 'twenty past'
end /*when*/
when min = 25 then do
out = out 'twenty-five past'
end /*when*/
when min = 30 then do
out = out 'half past'
end /*when*/
when min = 35 then do
out = out 'twenty-five to'
end /*when*/
when min = 40 then do
out = out 'twenty to'
end /*when*/
when min = 45 then do
out = out 'a quarter to'
end /*when*/
when min = 50 then do
out = out 'ten to'
end /*when*/
when min = 55 then do
out = out 'five to'
end
end /* select */
numbers = 'one two three four five six' 'seven eight nine ten'-
'eleven twelve'
out = out numbers.word(hour)
if min = 0 then do
out = out "o'clock"
end /*if*/
say out||'.'
exit
method Tell() static public ;
say 'QT will display the current time in real English.'
say 'Call without any arguments to display the time, or with'
say '"?" to display this information. A second argument (in'
say 'the format "HH:MM:SS") will be used as a test value.'
say 'British English idioms are used in this program.'
say
return