|
Here is a little subproc I wrote to convert the UNIX epoch to an RPG timestamp. Can adjust for UTC if needed. I "copied" some of Scott's code for the UTC part. :::code start::: // ----------------------------------------------------------------------- // CvtEpochTS // ---------- // Helper routine to convert UNIX-type epoch values (typically the number // of seconds from midnight, Jan 1, 1970) to an OS/400 timestamp value. // The UNIX-type epoch value is considered the "timestamp" value to the // UNIX world. // // INPUTS // inEpochSecs int // The UNIX timestamp, in UNIX epoch format (numbe of seconds since // midnight, Jan 1, 1970. // inAdjustUTC bool // Determine whether the time should be adjusted by the UTC offset. // true - adjust for UTC offset // false - do not adjust for UTC offset // // OUTPUTS // OS400Timestamp char[26] // Equivalent OS/400 timestamp value. p CvtEpochTS b d CvtEpochTS pi z d inEpochSecs 10i 0 const d inAdjustUTC n const // Constants. d EPOCHSTART s z inz(z'1970-01-01-00.00.00.000000') // Variables. d returnts s z inz(z'0001-01-01-00.00.00.000000') d utcoffhours s 10i 0 inz d utcoffmins s 10i 0 inz d utcoffsecs s 8f inz d utcoffset s 10i 0 inz d GetUTCOffset pr extproc('CEEUTCO') d offsethours 10i 0 d offsetminutes 10i 0 d offsetseconds 8f d feedback 12a options(*nopass) /free returnts = EPOCHSTART + %seconds(inEpochSecs); if inAdjustUTC; callp(e) GetUTCOffset(utcoffhours:utcoffmins:utcoffsecs); utcoffset = utcoffsecs; returnts = returnts + %seconds(utcoffset); endif; return returnts; /end-free p CvtEpochTS e :::code end::: Loyd -----Original Message----- From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement Sent: Friday, December 03, 2004 1:35 PM To: Midrange Systems Technical Discussion Subject: Re: IFS file timestamp On Fri, 3 Dec 2004 SRamanujan@xxxxxxxxxxxxxxxxxx wrote: > > Is there a way to pickup the timestamp of the IFS Files? Something like > QUSROBJD API but one that works on IFS. > Yes. The stat() API has fields for "last access", "last modified" and "last changed". (Modified date is only updated when the file data is changed, whereas the Changed Date is modified when attributes such as authority or filename is changed) Also, the Qp0lGetAttr() API can be used to get the the timestamp for when the file was created. These timestamps are recorded in Unix-fashion, which means that they contain a number which represents the number of seconds between Jan 1, 1970 UTC. All times are in the UTC timezone so you need to adjust them for your current timezone. If you search the archives, you should be able to find samples of this stuff. -- This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/midrange-l or email: MIDRANGE-L-request@xxxxxxxxxxxx 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 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.