home *** CD-ROM | disk | FTP | other *** search
/ Sams Cobol 24 Hours / Sams_Cobol_24_Hours.iso / source / ch21 / CHAPT21G.COB < prev    next >
Text File  |  1998-09-14  |  3KB  |  73 lines

  1. 000010 @OPTIONS MAIN,TEST
  2. 000020 Identification Division.
  3. 000030 Program-Id.  Chapt21g.
  4. 000040* Convert Local Time To Gmt
  5. 000041 Environment Division.
  6. 000050 Configuration Section.
  7. 000051 Source-Computer.  IBM-PC.
  8. 000056 Object-Computer.  IBM-PC.
  9. 000147 Data Division.
  10. 000148 Working-Storage Section.
  11. 000157 01  Current-Date-Group.
  12. 000167     03  Todays-Date.
  13. 000177         05  Today-YYYY       Pic 9(4).
  14. 000187         05  Today-MM         Pic 9(2).
  15. 000197         05  Today-DD         Pic 9(2).
  16. 000198     03  Todays-Date-N Redefines Todays-Date Pic 9(8).
  17. 000207     03  Time-Now.
  18. 000217         05  Time-Hour        Pic 99.
  19. 000227         05  Time-Minutes     Pic 99.
  20. 000237         05  Time-Seconds     Pic 99.
  21. 000247         05  Time-Hundredths  Pic 99.
  22. 000257     03  GMT-Offset.
  23. 000258         05  GMT-Direction    Pic X.
  24. 000259         05  GMT-Hours        Pic 99.
  25. 000260         05  GMT-Minutes      Pic 99.
  26. 000270 01  Display-Date.
  27. 000280     03  Today-MM             Pic 9(2).
  28. 000290     03  Filler               Pic X Value "/".
  29. 000300     03  Today-DD             Pic 9(2).
  30. 000310     03  Filler               Pic X Value "/".
  31. 000320     03  Today-YYYY           Pic 9(4).
  32. 000321 01  Display-Time.
  33. 000322     03  Time-Hour            Pic 99.
  34. 000323     03  Filler               Pic X Value ":".
  35. 000324     03  Time-Minutes         Pic 99.
  36. 000325     03  Filler               Pic X Value ":".
  37. 000326     03  Time-Seconds         Pic 99.
  38. 000330 01  Total-Seconds            Pic 9(15) Value Zeros.
  39. 000340 01  Work-Number              Pic 9(15) Value Zeros.
  40. 000350 01  Work-Remainder           Pic 9(15) Value Zeros.
  41. 000390 01  GMT-Offset               Pic 9(15) Value Zeros.
  42. 000391 Procedure Division.
  43. 000392 Chapt21g.
  44. 000401     Move Function Current-Date To Current-Date-Group
  45. 000411* Convert Today To Seconds
  46. 000421     Compute Work-Number =
  47. 000422             Function Integer-Of-Date (Todays-Date-N)
  48. 000431     Compute Total-Seconds = (Work-Number * 86400) +
  49. 000441                             (Time-Hour Of Time-Now * 3600) +
  50. 000451                             (Time-Minutes Of Time-Now * 60) +
  51. 000461                             Time-Seconds Of Time-Now
  52. 000471     Compute Work-Number = (GMT-Hours * 3600) +
  53. 000481                           (GMT-Minutes * 60)
  54. 000491* Remember We Need To Change By The Opposite Of The Direction From Gmt
  55. 000492     If GMT-Direction = "+"
  56. 000501        Subtract Work-Number From Total-Seconds
  57. 000511     Else
  58. 000521        Add Work-Number To Total-Seconds
  59. 000531     End-If
  60. 000541* Convert The Time In Seconds Back To A Date And Time
  61. 000551     Divide Total-Seconds By 86400 Giving Work-Number
  62. 000561                             Remainder Work-Remainder
  63. 000571     Compute Todays-Date-N =
  64. 000572             Function Date-Of-Integer (Work-Number)
  65. 000581     Divide Work-Remainder By 3600 Giving Time-Hour Of Time-Now
  66. 000591                              Remainder Work-Number
  67. 000601     Divide Work-Number By 60 Giving Time-Minutes Of Time-Now
  68. 000611                              Remainder Time-Seconds Of Time-Now
  69. 000621     Move Corresponding Todays-Date To Display-Date
  70. 000631     Move Corresponding Time-Now To Display-Time
  71. 000641     Display "Current GMT " Display-Date " " Display-Time
  72. 000651     Stop Run
  73. 000661     .