home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / ONLINE / SREFPRC1 / GMTTIME.SRF < prev    next >
Text File  |  1997-05-01  |  1KB  |  59 lines

  1. /*  ----------------------------------------------------------*/
  2. /* Compute new GMT time in Sat, 12 Aug 1996 21:18:20 format 
  3.  (or 123421 hh:mm:ss if dobase=1)  */
  4. /* if no args, use current date time, with no offset */
  5. /* Otherwise:
  6.    first arg: add an offset (in fractions of a day)
  7.    date: base date in date('b') format
  8.    seconds: current seconds (i.e.; time('s')
  9.    dobase = if 1, return julian hh:mm:ss (don't do conversion of day)
  10.   If date or seconds is "", then use current date or seconds.
  11. */
  12. /*  ----------------------------------------------------------*/
  13.  
  14. sref_new_gmt: 
  15. parse arg fracadd,adate,asec,dobase
  16.  
  17. if fracadd=""  then fracadd=0
  18. if adate="" then adate=date('b')
  19. if asec="" then asec=time('s')
  20.  
  21. wasd=digits() ; 
  22. numeric digits 12
  23.  
  24. sechr=60*60 ; secday=sechr*24
  25. gmtadd=gmtoffset()
  26. if datatype(gmtadd)<>"NUM" then 
  27.    gmtadd=0
  28. else
  29.   gmtadd=-gmtadd
  30.  
  31. gmttime=adate + ( (asec+gmtadd)/secday)
  32. newtime=gmttime+fracadd
  33.  
  34. newdate=trunc(newtime)
  35. newsec=newtime-newdate
  36.  
  37. if dobase=1 then
  38.   aday=newdate
  39. else do
  40.    d2=dateconv(newdate,'b','n')
  41.    aday=LEFT(dateconv(newdate,'b','w'),3)
  42. end
  43.  
  44. newsec=newsec*secday
  45. nhr=trunc(newsec/sechr)
  46. tmin=newsec-(nhr*sechr)
  47. nmin=trunc(tmin/60)
  48. nsec=trunc(tmin-(nmin*60))
  49. issec=nhr':'nmin':'nsec
  50.  
  51.  
  52. numeric digits wasd
  53. if dobase=1 then
  54.   return aday ' ' issec
  55. else
  56.   return aday ',' d2 ' ' issec
  57.  
  58.  
  59.