UTC time can be used when queuing data. In a project where you have data sent external from the IBM i to AWS (Amazon Cloud Services).
This data is sent via webservice on the IBM i using HTTPS post and Apache server. If this were a customer record, it may have been changed multiple times. You are not guaranteed 1st in 1st out. By using UTC time you can check the time of the record and disregard any records with timestamps prior. (supersede)

ddsDateStruc ds Qualified
d Date 8S 0
d Time 6S 0
d MilliSec 6S 0
dInputStruc DS LikeDS(dsDateStruc) Inz
dOutputStruc DS LikeDS(dsDateStruc) Inz

ddsTimeZone DS Qualified
d BytesReturned 10I 0
d BytesAvailable 10I 0
d TimeZoneName 10
d Reserved1 1
d DaylightSaving 1
d CurOffset 10I 0
d CurFullName 50
d CurAbbrName 50
d MsgFile 10
d MsgFileLib 10

ddsErrCode ds Qualified
d BytesProvided 10I 0 Inz(%Size(dsErrCode.MsgData))
d BytesAvail 10I 0
d ExceptionID 7
d Reserved 1
d MsgData 128

//
dCvtDateTimeFmt pr ExtPgm('QWCCVTDT')
d InputFormat 10 Const
d InputTS Const LikeDS(dsDateStruc)
d OutputFormat 10 Const
d OutputTS LikeDS(dsDateStruc)
d dsErrCode LikeDS(dsErrCode)
d InputTZ 10 Const
d OutputTZ 10 Const
d TimeZoneInfo LikeDs(dsTimeZone)
d TimeZoneInfoL 10I 0 Const
d PrecisionInd 1 Const

// 2002-05-30T09:30:10.5
// 2014-10-03-15.07.10.646000 jamie UTC
// Q0000UTC 0:00 Coordinated Universal Time (UTC) --or-- *UTC
// Q0000GMT 0:00 Greenwich Mean Time (GMT)
// QN0400AST -4:00 Atlantic Standard Time (AST)
// QN0500EST -5:00 Eastern Standard Time (EST)
// QN0500EST2 -5:00 Eastern Standard Time (EST)
// QN0600CST -6:00 Central Standard Time (CST)
// QN0700MST -7:00 Mountain Standard Time (MST)
// QN0700MST2 -7:00 Mountain Standard Time (MST)
// QN0700T -7:00 Mountain Standard Time (T)
// QN0800PST -8:00 Pacific Standard Time (PST)
// QN0800U -8:00 Pacific Standard Time (U)
// QN0900AST -9:00 Alaska Standard Time (AST)
//
exec sql Set :MytimeStamp = current_timestamp;

parmInputTS = %timestamp(MyTimeStamp);
InputStruc.Date=%Int(%Char(%Date(parmInputTS):*ISO0));
InputStruc.Time=%Int(%Char(%Time(parmInputTS):*ISO0));
InputStruc.MilliSec=%SubDt(parmInputTS:*MS);

CvtDateTimeFmt('*YYMD':
InputStruc:
'*YYMD':
OutputStruc:
dsErrCode:
'QN0600CST':
'*UTC' :
dsTimeZone:
%Size(dsTimeZone):
(InputStruc.MilliSec>0));

//EVAL OutputStruc
//OUTPUTSTRUC.DATE = 20141217.
//OUTPUTSTRUC.TIME = 194032.
//OUTPUTSTRUC.MILLISEC = 002403.
// CCYY-MM-DD-HH.NN.00.000000
worktimestamp = %subst(%char(OUTPUTSTRUC.DATE):1:4) + '-' +
%subst(%char(OUTPUTSTRUC.DATE):5:2) + '-' +
%subst(%char(OUTPUTSTRUC.DATE):7:2) + '-' +
%subst(%char(OUTPUTSTRUC.TIME):1:2) + '.' +
%subst(%char(OUTPUTSTRUC.TIME):3:2) + '.' +
%subst(%char(OUTPUTSTRUC.TIME):5:2) + '.' +
%char(OUTPUTSTRUC.MILLISEC);

test(ze) worktimestamp;
if not %error;
isotimestamp = %timestamp(worktimestamp);
mytimestamp = %char(isotimestamp);
endif;

[wordpress_file_upload multiple=”false” fitmode=”responsive” captcha=”true” captchatype=”RecaptchaV2 (no account)” postlink=”true”]

using QWCCVTDT to get UTC time
Tagged on:             

Leave a Reply

Your email address will not be published.