× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



//**********************************************************************
// GetTime - Calculate creation Date/Time from the Epoch
//***********************************************************************

D APIERR DS
D ERRSIZ 1 4B 0 INZ(256)
D ERRLEN 5 8B 0 INZ(0)
D ERRMIC 9 15
D ERRNBR 16 16
D ERRDTA 17 272

d Returned ds
d Numback 1 4b 0
d ArrTyp 5 8b 0
d Otherstff 9 248
d QOffset 249 253
d MoreStf 254 266
*
D DS
D OffSet 5
D Plus 1 Overlay(Offset : 1)
D HrsO 2 0 Overlay(Offset : *Next)
D MinO 2 0 Overlay(Offset : *Next)

D CmdLine S 512
D CmdLen S 15 5
D HHMMSS S 6 0
D Dot s 2a Inz('. ')
D DotDot s 3a Inz('.. ')
d Epoch s D Inz(D'1970-01-01')
d CreatDate s D Inz
d Cret s 10u 0 Inz
d Hrs s 2 0 Inz
d Mins s 2 0 Inz
d Secs s 2 0 Inz
d Creatime s T Inz
d LeftHrs s 10 0 Inz
d LeftMin s 10 0 Inz
d Days s 10 0 Inz
d NbrToRtv s 10i 0 Inz(1)
d RcvVarLen s 10i 0 Inz(256)
d Sysval s 10 Inz('QUTCOFFSET')
*
/FREE
Begsr GetDate;

// Cret = unix epoch time in seconds since 01-01-1970
Days = Cret / 86400; //Days since Epoch

LeftHrs = %Rem(Cret : 86400); //Hours
Hrs = LeftHrs / 3600;

LeftMin = %Rem(LeftHrs : 3600); //Minutes
Mins = LeftMin / 60;

LeftMin = %Rem(LeftMin : 3600); //Minutes
Secs = %Rem(LeftMin : 60); //Seconds

Clear CreaTime;
/END-FREE
c Adddur Hrs :*Hours CreaTime Calc Creation Time
c Adddur Mins:*Minutes CreaTime
c Adddur Secs:*Seconds CreaTime

c Call 'QWCRSVAL' Get System UTC
c Parm Returned
c Parm RcvVarLen
c Parm NbrToRtv
c Parm Sysval QUTCOFFSET
c Parm APIERR

If ERRMIC = *Blank; //No UTC Error
Offset = QOffset;

// Subtract/Add UTC Offset

If Plus = '+'; //Add
/END-FREE
c Adddur HrsO:*hours CreaTime
c Adddur MinO:*Minutes CreaTime
/FREE
Else; //Subtract
/END-FREE
c Subdur HrsO:*hours CreaTime
c Subdur MinO:*Minutes CreaTime
/FREE
Endif;
Endif;

/END-FREE
c Epoch Adddur Days : *Days CreatDate
Endsr;

This works for me. It's a little rough. I use this when reading from the IFS to cerate a directory list for a file selection process. It's old back when I didn't convert the adddur to free.

Good Luck
Bill
(All else fails READ THE INSTRUCTIONS)



----- Original Message ----
From: Mike Cunningham <mcunning@xxxxxxx>
To: RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
Sent: Monday, September 17, 2007 12:14:04 PM
Subject: Converting Unix Jan 01 1970 UTC epoch datetime stamp to iSeries EST datetime stamp


Has anyone already created a routine to convert a Unix datetime stamp which is in seconds from Jan 01 1970 and is in UTC time to an iSeries datetime stamp adjusted for local time zone (in my case just US Eastern). I have the conversion from Unix to iSeries datetime stamp working but I can't figure out how to do the time zone adjustment. The time zone adjustment needs to be made based on the datetime stamp I am receiving not the current datetime that it is being processed.

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.