On Wed, 12 Dec 2001, Walden H. Leverich wrote: > > I have a need to retrieve the current time (seconds, not milliseconds) and > format it thus: > > Wed, 12 Dev 2001 13:21:01 -0500 There's an API which will do MOST (but not all) of the work for you. Specifically, it does not know how to format an offset from UTC (the "-0500" part) The API that does all of the formatting is the "CEEDATM" API which can be found in the "ILE CEE APIs" manual. Here's an example of what you're trying to do: ** Get local time API D CEELOCT PR opdesc D output_lil 10U 0 D output_secs 8F D output_greg 17A ** Convert to arbitrary timestamp API D CEEDATM PR opdesc D input_secs 8F D picture 32A const D output 32A * Get offset from UTC API D CEEUTCO PR D hours 10I 0 D minutes 10I 0 D seconds 8F D discard1 S 10U 0 D cur_time S 8F D discard2 S 17A D mail_date S 32A D hrs2utc s 10I 0 D mins2utc s 10I 0 D discard3 s 8F D hh s 2A D mm s 2A C* Get current local time from clock: c callp CEELOCT(discard1: cur_time: discard2) C* Convert to e-mail format: c callp CEEDATM(cur_time: c 'Www, DD Mmm YYYY HH:MI:SS': c mail_date) C* Retrieve offset from UTC c callp CEEUTCO(hrs2utc: mins2utc: discard3) C* Format the UTC offset nicely C* and tack it onto the string... c if hrs2utc < 0 c eval mail_date = %trimr(mail_date) + ' -' c eval hrs2utc = 0 - hrs2utc c else c eval mail_date = %trimr(mail_date) + ' +' c endif c move hrs2utc hh c move mins2utc mm c eval mail_date = %trimr(mail_date) + hh + mm C* Let's see if that worked :) c dsply mail_date c eval *inlr = *on
As an Amazon Associate we earn from qualifying purchases.
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.