Search

Saturday, November 3, 2012

COBOL Date Function to get correct offset from GMT

COBOL DATE FUNCTION

There was requirement were we had to send MT202 to Swift. Swift accepts time of GMT or either it accepts with correct offset and when we use current time option in COBOL it gives local time hence we were getting ET time.I had faced issue with time. The offset I was getting was not correct from GMT. 

For E.g.: ET time is 4 hrs offset from GMT when day-light saving is on and it is 5 hrs offset from GMT when day light saving is off.  

I used following function and by using this function we get the offset from GMT of where your application is running, then we can easily just use native COBOL.


See the CURRENT-DATE intrinsic function at:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR31/7.1.15

Positions 17-21 will give you the exact offset from GMT.

Unless your application is running in one of the time zones with 15 or 30 minute offsets from GMT, then "converting" from/to GMT becomes trivial without resorting to an LE call-able service (much less a C or Assembler subroutine).

Character 17 is sign value '-'or '+'. This sign is '-' if GMT is ahead of local time and '+' if the GMT is behind of local time.  

No comments:

Post a Comment