home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / telecomm / bbs / wwbbs26.lha / WWBBSDoors / cybmods.lha / time.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1993-12-17  |  2.5 KB  |  131 lines

  1. /* Time.rexx         by Greg Cunningham 1990    stolen from Unix TODAY.C */
  2. options results
  3.  
  4. temp=date(o)
  5. parse var temp year'/'mon'/'day .
  6. print ' '
  7. print 'Today is' date(w)', the' nbrtxt(day%1,1)' day of' date(m)',' nbrtxt(19,0) nbrtxt(year,0)'.'
  8.  
  9. ctime=time()
  10. parse var ctime hour':'min':'sec
  11. hr=hour//12
  12. if(hr=0) then hr=12
  13. str='The big hand is on the' nbrtxt((((min+2+sec%30)%5+11)//12)+1,0)
  14. print str 'and the little hand is on the' nbrtxt(hr,0)'.'
  15.  
  16. exit
  17.  
  18.  
  19. /*
  20.  * Integer to Readable ASCII Conversion Routine.
  21.  *
  22.  * Synopsis:
  23.  *
  24.  * string=nbrtxt(value,ordinal)
  25.  *    value    -- The number to output
  26.  *    ordinal -- Non-zero for ordinal number
  27.  *
  28.  *
  29.  *     say nbrtxt(0,0) ==> "zero"
  30.  *     say nbrtxt(0,1) ==> "zeroth"
  31.  *
  32.  * Largest number:
  33.  *    nine hundred ninety-nine thousand, nine hundred ninety-nine
  34.  *
  35.  */
  36.  
  37. nbrtxt: procedure
  38.  
  39.     arg val,ordflag
  40.  
  41.     cardinal.0='zero'
  42.     cardinal.1='one'
  43.     cardinal.2='two'
  44.     cardinal.3='three'
  45.     cardinal.4='four'
  46.     cardinal.5='five'
  47.     cardinal.6='six'
  48.     cardinal.7='seven'
  49.     cardinal.8='eight'
  50.     cardinal.9='nine'
  51.     cardinal.10='ten'
  52.     cardinal.11='eleven'
  53.     cardinal.12='twelve'
  54.     cardinal.13='thirteen'
  55.     cardinal.14='fourteen'
  56.     cardinal.15='fifteen'
  57.     cardinal.16='sixteen'
  58.     cardinal.17='seventeen'
  59.     cardinal.18='eighteen'
  60.     cardinal.19='nineteen'
  61.  
  62.     ordinal.0='zeroth'
  63.     ordinal.1='first'
  64.     ordinal.2='second'
  65.     ordinal.3='third'
  66.     ordinal.4='fourth'
  67.     ordinal.5='fifth'
  68.     ordinal.6='sixth'
  69.     ordinal.7='seventh'
  70.     ordinal.8='eighth'
  71.     ordinal.9='ninth'
  72.     ordinal.10='tenth'
  73.     ordinal.11='eleventh'
  74.     ordinal.12='twelfth'
  75.  
  76.     twenties.2='twen'
  77.     twenties.3='thir'
  78.     twenties.4='for'
  79.     twenties.5='fif'
  80.     twenties.6='six'
  81.     twenties.7='seven'
  82.     twenties.8='eigh'
  83.     twenties.9='nine'
  84.  
  85.     op=''
  86.     if(val<0) then do
  87.         op = 'minus '
  88.         val=(-val);
  89.     end
  90.     if(val>=1000) then do
  91.         op=op||nbrtxt(val%1000,0);
  92.         op=op 'thousand'
  93.         val=val//1000
  94.         if(val=0) then do
  95.             if(ordflag=1) then op=op'th'
  96.             return op
  97.         end
  98.         if(val>=100) then op=op', '
  99.         else op=op 'and '
  100.     end
  101.     if(val>=100) then do
  102.         num=val%100
  103.         op=op||cardinal.num 'hundred'
  104.         val=val//100
  105.         if(val=0) then do
  106.             if(ordflag=1) then op=op'th'
  107.             return op
  108.         end
  109.         op=op' '
  110.     end
  111.     if(val>=20) then do
  112.         if(val=90 & ordflag=1) then return op'nintieth' /* ninetieth? */
  113.         num=val%10
  114.         op=op||twenties.num
  115.         val=val//10
  116.         if(val=0) then do
  117.             if(ordflag=1) then op=op'tieth'
  118.             else op=op'ty'
  119.             return op
  120.         end
  121.         op=op'ty-'
  122.     end
  123.     if(val<=12) then do
  124.         if(ordflag=1) then op=op||ordinal.val
  125.         else op=op||cardinal.val
  126.         return op
  127.     end
  128.     op=op||cardinal.val
  129.     if(ordflag=1) then op=op'th'
  130.     return op
  131.