This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--
[ Picked text/plain from multipart/alternative ]
Scott,

Thanks very much for the code.

But I have to add a warning to it,... without the Omissible Feedback
Parameter (*Nopass) defined in the prototypes, and a couple of changes to PR
field definitions, (10U 0 -> 10I 0), other defined fields in the
program/memory became corrupted, or at least they did for me, (imagine me
reading a manual).  Thus resulting in the following code:

 ** Get local time API
d CEELOCT         PR                  opdesc
d   output_lil                        Like(discard1)
d   output_secs                       Like(cur_time)
d   output_greg                       Like(discard2)
d   output_fc                         Like(Fc) Options(*Nopass)
 ** Convert to arbitrary timestamp API
d CEEDATM         PR                  opdesc
d   input_secs                        Like(cur_time)
d   picture_str                       Like(Pictureds) const
d   output_ts                         Like(Pictureds)
d   output_fc                         Like(Fc) Options(*Nopass)
 * Get offset from UTC API
d CEEUTCO         PR
d  hours                              Like(hrs2utc)
d  minutes                            Like(mins2utc)
d  seconds                            Like(cur_time)
d  output_fc                          Like(Fc) Options(*Nopass)

d discard1        S             10I 0
d cur_time        S              8F
d discard2        S             23A
d hrs2utc         s             10I 0
d mins2utc        s                   Like(hrs2utc)
d hh              s              2A
d mm              s              2A
d discard3        s                   Like(cur_time)
d WDate           s                   Like(Pictureds)

d Fc              ds
d  sev                           5U 0
d  msgno                         5U 0
d  flags                         1A
d  facid                         3A
d  isi                          10U 0
d Pictureds       ds
d  Piclen1                1      2I 0
d  Picture                3     34A
d  Piclen2                1      4I 0
d  Picture2               5     36A

 * Get current local time from clock:
c                   Callp     CEELOCT(discard1 : cur_time : discard2)
 * Convert to e-mail format:
c                   Callp     CEEDATM(cur_time :
c                                     'Www, DD Mmm YYYY HH:MI:SS' :
c                                     WDate)
 * Retrieve offset from UTC
c                   Callp     CEEUTCO(hrs2utc : mins2utc : discard3)
 * Format the UTC offset nicely
 *   and tack it onto the string...
c                   If        hrs2utc < *Zero
c                   Eval      WDate = %trimr(WDate) + ' -'
c                   Eval      hrs2utc = 0 - hrs2utc

c                   Else
c                   Eval      WDate = %trimr(WDate) + ' +'
c                   EndIf
c                   Move      hrs2utc       hh
c                   Move      mins2utc      mm
c                   Eval      WDate = %TrimR(WDate) + hh + mm


With these slight enhancements, I was able to avoid decimal data errors.

Kindest Regards,
Jon A. Erickson
Sr. Programmer Analyst
800.COM Inc.
1516 NW Thurman St
Portland, OR  97209-2517

Direct: 503.944.3613
Fax: 503.943.9313
Web: http://www.800.com



-----Original Message-----
From: Scott Klement [mailto:klemscot@klements.com]
Sent: Wednesday, December 12, 2001 1:58 PM
To: 'midrange-l@midrange.com'
Subject: Re: Retrieving and formatting current time in RPGLE



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

_______________________________________________
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/midrange-l
or email: MIDRANGE-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.