home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d6xx / d634 / apig.lha / APIG / apig33.lzh / util5.rexx < prev    next >
OS/2 REXX Batch file  |  1992-02-20  |  2KB  |  80 lines

  1.  
  2. /* Example of using Utility Library functions 
  3.  
  4.     Date Functions
  5.     
  6. */
  7.  
  8.  x = addlib("apig.library",0,-30,0)
  9.  
  10.  call set_apig_globals()
  11.  
  12.  clockdata = allocmem(14,MEMF_CLEAR)
  13.  
  14. /*  ClockData Looks Like This
  15.  
  16.     offset 0  UWORD sec
  17.            2  UWORD min
  18.            4  UWORD hour
  19.            6  UWORD mday
  20.            8  UWORD month
  21.           10  UWORD year
  22.           12  UWORD wday
  23.  
  24.      size = 14bytes
  25.  */
  26.  
  27.  secsperday  = 86000
  28.  daysperyear = 365  
  29.  years       = 14
  30.  
  31.  /* plus 120 days */
  32.  
  33.  daterelativeto1978 = (secsperday * daysperyear) * years + (secsperday * 120) 
  34.  
  35.  /* convert amiga date to something understandable */
  36.  
  37.  call Amiga2Date(daterelativeto1978,clockdata)  /* fills in clockdata */
  38.  
  39.       sec   = getvalue(clockdata,0,2,'n')
  40.       min   = getvalue(clockdata,2,2,'n')
  41.       hour  = getvalue(clockdata,4,2,'n')
  42.       mday  = getvalue(clockdata,6,2,'n')
  43.       month = getvalue(clockdata,8,2,'n')
  44.       year  = getvalue(clockdata,10,2,'n')
  45.       wday  = getvalue(clockdata,12,2,'n')
  46.  
  47.       say " sec   =" sec
  48.       say " min   =" min
  49.       say " hour  =" hour
  50.       say " mday  =" mday
  51.       say " month =" month
  52.       say " year  =" year
  53.       say " wday  =" wday  
  54.       say " Date is Legal "
  55.       say " "
  56.  
  57.  
  58.       call setvalue(clockdata,6,2,'n',76)   /* day of month set to 76 */
  59.  
  60.       ill = CheckDate(clockdata)  /* should return 0 for illegal date */
  61.  
  62.       if ill = 0 then 
  63.          say " Date is Illegal "
  64.       else
  65.          say " Date is Legal "
  66.  
  67.  
  68.       mday = setvalue(clockdata,6,2,'n',mday)   /* set it back */
  69.  
  70.       amigatime = Date2Amiga( clockdata ) /* convert clock to relative1978 */
  71.  
  72.       say " "
  73.       say "Original Time = " daterelativeto1978 " got back " amigatime
  74.  
  75.  
  76. call freemem(clockdata,14)
  77.  
  78. exit
  79.  
  80.