|
Hi Eric,
Hopefully this will help.
http://www.think400.dk/adhoc_4.htm#eks0007
Or if you want a (mostly) freeform version, I have pasted ours below. Please excuse the mod-marks.
// Purpose: Determine number of seconds to add or subtract to the
// standard epoch time.
// The paramater definitions can be found in the IBM redbooks at
// http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/
// apis/CEEUTCO.htm
32169D GetUTCOffset pr ExtProc( 'CEEUTCO' )
32169D offSetHours 10i 0
32169D offSetMinutes 10i 0
32169D offSetSeconds 8f
32169D Feedback 12a options( *nopass )
32169 //======================================================================*
32169 // Procedure: convertUnixTime *
32169 // Description: Convert Unix Time into a formatted timestamp. *
32169 // *
32169 // Notes: Code for this procedure based on Loyd Goodbar: *
32169 // http://www.think400.dk/adhoc_4.htm *
32169 // *
32169 // Parameters: *
32169 // Input - Unix Time *
32169 // Input - (optional) Adjust for UTC Offset *
32169 // *
32169 // Return Value: Timestamp *
32169 // *
32169 //----------------------------------------------------------------------*
32169 dcl-proc convertUnixTime;
32169 // Parameter List
32169 dcl-pi *n timestamp;
32169 epUnixTime char(60) Const;
32169 epAdjustUTC Ind Const Options( *omit: *nopass );
32169 end-pi;
32169 // Local Constants.
32169 dcl-c UNIX_START_TIME z'1970-01-01-00.00.00.000000';
32169 // Local Variables
32169 dcl-s rtnTimeStamp timestamp;
32169 dcl-s utcOffHours int(10);
32169 dcl-s utcOffMins int(10);
32169 dcl-s utcOffSecs float(8);
32169 dcl-s utcOffSet int(10);
32169 //--------------------------------------------------------------------*
32169 rtnTimeStamp = UNIX_START_TIME + %seconds( %int( epUnixTime ) );
32169 // Adjust for UTC offset if passed and true.
32169 If %parms >= %parmNum( epAdjustUTC ) and %addr( epAdjustUTC ) <> *null
32169 and epAdjustUTC;
32169 GetUTCOffset( utcOffHours: utcOffMins: utcOffSecs );
32169 utcOffset = utcOffSecs;
32169 rtnTimeStamp += %seconds( utcOffSet );
32169 EndIf;
32169 Return rtnTimeStamp;
32169 end-proc convertUnixTime;
Kurt Anderson
Sr. Programmer/Analyst - Application Development, Service Delivery Platform
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Eric Hill
Sent: Monday, August 03, 2015 11:25 AM
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxx>
Subject: RE: ***SPAM*** Re: Converting Data
Jan,
Thanks for the link but every time I go there I just get redirected to iProdeveloper's main page. Even when I click on the "Forums" link I cannot get to the forum.
Eric Hill
Integrated Corporate Solutions
ehill@xxxxxxxxxxxxx
256-760-8239
NOTICE:
This message may contain privileged or otherwise confidential information. If you are not the intended recipient, please immediately advise the sender by reply e-mail and delete the message and any attachments without using, copying or disclosing the contents.
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jan Grove Vejlstrup
Sent: Monday, August 03, 2015 9:44 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: ***SPAM*** Re: Converting Data
Importance: Low
Hello Eric
The timestamp that you receive is in unix-format. Scott Klement has a routine that converts the unix-timestamp to a RPG-timestamp in this thread:
http://forums.iprodeveloper.com/forums/aft/147649
Best regards
Jan
Am 03.08.2015 um 16:25 schrieb Eric Hill:
Rob,
Thanks for the quick reply. Here are the debug results:
ST_MTIME INT(10) 1437659037 '55B0EF9D'X
DATEBIN INT(10) 1437659037 '55B0EF9D'X
DATEDTS CHAR(8) 'í^Õ¸ ' '55B0EF9D40404040'X
Eric Hill
Integrated Corporate Solutions
ehill@xxxxxxxxxxxxx
256-760-8239
NOTICE:
This message may contain privileged or otherwise confidential information.
If you are not the intended recipient, please immediately advise the
sender by reply e-mail and delete the message and any attachments
without using, copying or disclosing the contents.
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of
rob@xxxxxxxxx
Sent: Monday, August 03, 2015 9:10 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: Converting Data
If you run this in debug (or DSPLY DATEBIN) what is it's value? If that looks good then your data structure is bad.
You could specify:
ctl-opt debug(*yes);
and then add
dump;
right after the
DateBin = st_mtime;
You should see something for DATEDTS similar to this line:
MYCHAR CHAR(5) 'HI ' 'C8C9404040'X
Show us that whole line, including the hex value.
Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1 Group Dekko Dept 1600 Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com
From: Eric Hill <ehill@xxxxxxxxxxxxx>
To: "rpg400-l@xxxxxxxxxxxx" <rpg400-l@xxxxxxxxxxxx>
Date: 08/03/2015 09:57 AM
Subject: Converting Data
Sent by: "RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxx>
I am reading in a file from the IFS and I am wanting to get the
modification date and time. I am using Scott Klement's copybooks and
I know the field to use is st_mtime. I understand this field is in
*DTS format so I am going to convert it using the QWCCVTDT API. This
API expects the input date to be in an 8 alpha field. The st_mtime
field is defined as 10i 0. I have a data structure in my program like this:
D DS
D DateDts 8a
D DateBin 10i 0 overlay(DateDts)
I then do this:
DateBin = st_mtime;
I get returned nothing close to the actual modification date and time
I see on the properties of the file in the IFS. It is showing
07/15/2015 whereas the returned date is 04/23/1976.
Trouble with my data structure?
Thanks in advance?
Eric Hill
Integrated Corporate Solutions
NOTICE:
This message may contain privileged or otherwise confidential information.
If you are not the intended recipient, please immediately advise the
sender by reply e-mail and delete the message and any attachments
without using, copying or disclosing the contents.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-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.