× 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.



Thanks Scott. Won't this convert the Unix time to a timestamp based on the current date not the date in the unix timestamp? I need to convert a unix timestamp from 6 months ago to a timestamp effective 6 months ago. CEEUTCO will use the current offset not what it was as of the unix date. I think I need to do this in two steps. Convert the unix date to a datetime stamp then send that datetime stamp into QWCCVTDT to convert it from UTC to EST

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Monday, September 17, 2007 3:52 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: Converting Unix Jan 01 1970 UTC epoch datetime stamp to iSeries EST datetime stamp

Errr...

Scott Klement wrote:
I recently posted an example of doing exactly what you're trying to do.
Here's a link:
http://www.systeminetwork.com/isnetforums/showthread.php?t=49068

Actually that thread is the OPPOSITE of what you wnated to do. Here's
code that does what you want to do:

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Convert Unix timestamp to RPG timestamp
*
* Call this with the data returned by stat() or Qp0lGetAttr
* convert to an RPG timestamp field.
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P Unix2Rpg B
D Unix2Rpg PI Z
D UnixTime 10U 0 value

D CEEUTCO PR
D Hours 10I 0
D Mins 10I 0
D Secs 8F
D fc 12A options(*omit)

D Epoch c z'1970-01-01-00.00.00'
D TimeZone s 10I 0 static inz(-1)
D Hours s 10I 0
D Mins s 10I 0
D Secs s 8F
D retval s Z

/free

if (TimeZone = -1);
CEEUTCO(Hours: Mins: Secs: *omit);
TimeZone = secs;
endif;

retval = Epoch;
retval = retval + %seconds(UnixTime) + %seconds(TimeZone);
return retval;

/end-free
P E

--
This is the RPG programming on the AS400 / 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 thread ...

Follow-Ups:
Replies:

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.