Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Any algorithm in COBOL for Day Light Savings time?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
rchandran_19

New User


Joined: 08 Mar 2005
Posts: 34

PostPosted: Wed Nov 05, 2008 2:50 am    Post subject: Any algorithm in COBOL for Day Light Savings time?
Reply with quote

Hi,

We have a program (cobol subroutine) that does the date/time conversion from GMT to LOCAL or Julian. We are having problem when it comes to DST start or end date.

Is there any algorithm to make get the right date foe each year of DST...for US it is the fist Sunday of Nov when DST ends...and second Sunday of March when DST starts.

Thanks,
RC
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Wed Nov 05, 2008 3:29 am    Post subject: Reply to: Any algorithm in COBOL for Day Light Savings time?
Reply with quote

IIRC ( if I remember correctly )

the result of the cobol builtin function INTEGER_OF_DATE modulo 7 should give the day of the week...

Just run a few tests to see wether the week starts on monday or sunday

start with integer_of_date for november 1st
check the modulus
keep incrementing by 1 until the modulus is 0/6 depending on the week start day
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Wed Nov 05, 2008 4:12 am    Post subject:
Reply with quote

Why not use FUNCTION CURRENT-DATE positions 17-21?
Quote:
7.1.9 CURRENT-DATE


The CURRENT-DATE function returns a 21-character alphanumeric value that represents the calendar date, time of day, and time differential from Greenwich Mean Time provided by the system on which the function is evaluated.

The function type is alphanumeric.


___ Format _____________________________________________________________
| |
| >>__FUNCTION CURRENT-DATE___________________________________________>< |
| |
|________________________________________________________________________|

Reading from left to right, the 21 character positions in the value returned can be interpreted as follows:

Character Positions Contents

1-4
Four numeric digits of the year in the Gregorian calendar.

5-6
Two numeric digits of the month of the year, in the range 01 through 12.

7-8
Two numeric digits of the day of the month, in the range 01 through 31.

9-10
Two numeric digits of the hours past midnight, in the range 00 through 23.

11-12
Two numeric digits of the minutes past the hour, in the range 00 through 59.

13-14
Two numeric digits of the seconds past the minute, in the range 00 through 59.

15-16
Two numeric digits of the hundredths of a second past the second, in the range 00 through 99. The value 00 is returned if the system on which the function is evaluated does not have the facility to provide the fractional part of a second.

17
Either the character '-' or the character '+'. The character '-' is returned if the local time indicated in the previous character positions is behind Greenwich Mean Time. The character '+' is returned if the local time indicated is the same as or ahead of Greenwich Mean Time. The character '0' is returned if the system on which this function is evaluated does not have the facility to provide the local time differential factor.

18-19
If character position 17 is '-', two numeric digits are returned in the range 00 through 12 indicating the number of hours that the reported time is behind Greenwich Mean Time. If character position 17 is '+', two numeric digits are returned in the range 00 through 13 indicating the number of hours that the reported time is ahead of Greenwich Mean Time. If character position 17 is '0', the value 00 is returned.

20-21
Two numeric digits are returned in the range 00 through 59 indicating the number of additional minutes that the reported time is ahead of or behind Greenwich Mean Time, depending on whether character position 17 is '+' or '-', respectively. If character position 17 is '0', the value 00 is returned
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Nov 05, 2008 4:21 am    Post subject: Re: Any algorithm in COBOL for Day Light Savings time?
Reply with quote

Are you calculating the local gregorian/julian after the fact? In other words, you log it as GMT and then convert it later?

As Robert suggests, FUNCTION CURRENT-DATE 17-21 will give you your GMT to Local Offset +/-HHMM or, you can call the LE Callable Service routine "CEEGMTO".

If you're logging the values as GMT, then you need to save the current GMT to Local offset so you can convert it later....

Regards,

Bill
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts DSNACCOX (can it be run on 1 db/ts, t... SRICOBSAS DB2 3 Sat May 06, 2017 12:59 am
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us