ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

bending time ....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • bending time ....

    PHP Code:

          
    *--------------------------------------------------------
          *
          *--------------------------------------------------------
          *
          * 
    Variable Definition
          
    *
         
    d count           s              3  0  inz
         d DecTime         s              6  0  inz
         d OQITTIME        s              5  2  inz
         d TheTime         s               T
         d TheStamp        s               Z
         d Time1           s               T    inz
    (T'15.30.00')
         
    d Time2           s               T    inz(T'09.30.15')
         
    d TimeUSA         s               T    timfmt(*USA)
         
    d displaytime     s              8
         d reply           s              1
         d seconds         s              5  0  inz
         d minutes         s              5  0  inz
         d hours           s              5  0  inz
         d mseconds        s              6  0  inz
         d outtext         s             25
         d TheDate         s               d
         d TotalTime       s              8  2

         d                 ds
         d PGMSTAMP                      20  0 inz
         d  PGMDATE                1      8  0
         d  PGMTIME                9     14  0
         d                 ds
         d  TimeBreak                     8  2
         d  TBHours                       6  0   overlay
    (TimeBreak:1)
         
    d  TBMinutes                     2  2   overlay(TimeBreak:*next)

          /
    Free

            
    //--------------------------------------------------------
            //  M A I N    P R O G R A M
            //--------------------------------------------------------
                 
    TheTime = %time();
                 
    dsply Thetime reply;

                 
    TheTime = %time(092138:*HMS);
                 
    dsply Thetime reply;

              
    // add time to our base time

                 
    TheTime += %hours(4);
                 
    outtext = %char(Thetime) + ' +4h';
                 
    dsply outtext reply;

                 
    TheTime += %minutes(65);
                 
    outtext = %char(Thetime) + ' +65m';
                 
    dsply outtext reply;

                 
    seconds = %subdt(TheTime:*seconds);
                 
    dsply %editc(seconds:'X')  reply;

                 
    minutes = %subdt(TheTime:*minutes);
                 
    dsply %editc(minutes:'X')  reply;

                 
    hours = %subdt(TheTime:*hours);
                 
    dsply %editc(hours:'X')  reply;


                 
    TheStamp = %timestamp();
                 
    mseconds =  %subdt(TheStamp:*mseconds);
                 
    dsply %editc(mseconds:'X')  reply;

                 
    seconds = %diff(Time1:Time2:*seconds);
                 
    dsply %editc(seconds:'X')  reply;

                 
    minutes = %diff(Time1:Time2:*minutes);
                 
    dsply %editc(minutes:'X')  reply;

                 
    hours = %diff(Time1:Time2:*hours);
                 
    dsply %editc(hours:'X')  reply;

                 
    TimeUSA = %time();
                 
    dsply TimeUSA reply;

               
    // break up a timestamp

                 
    TheStamp = %timeStamp();
                 
    Thedate  = %date(TheStamp);
                 
    Thetime  = %time(TheStamp);

               
    // break up a timestamp with datastructure

                 
    PGMStamp =
                 %
    dec(%char(TheStamp : *iso0) : 26 0);


               
    // using time to count do loop


                 
    for count 1 to %subdt(%TimeStamp():*s);
                 
    dsply %char(count)  reply;
                 endfor;

               
    //  OQITTIME    P       5    2

                 
    OQITTIME 24.00;
                 
    TimeBreak  OQITTIME;
                 
    TotalTime TBHours + (TBMinutes 60);



                 *
    inlr = *on;

            
    //--------------------------------------------------------
            // Hskpg - one time run subroutine
            //--------------------------------------------------------
                 
    begsr Hskpg;


                 
    endsr;
          /
    End-Free 
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com
Working...
X