0

I cannot set the DateTime tag to type UTC, it always set the type to Local

I have tried setting the property "isdst" to true. That property is available if the DS is of type xsd_tm.

      Note that this code is autogenerated with wsdl2rpg
      * **************************************************************
      * RPG call : stub_op_RequestSeriesData
      *  parm in : This_t this
      *  parm in : xsdc__string Value0
      *  parm in : xsdc__string Value1
      *  parm in : xsdc__string Value2
      *  parm in : ArrayOfString Value3
      *  parm in : ArrayOfInt Value4
      *  parm in : ArrayOfString Value5
      *  parm in : ArrayOfString Value6
      *  parm in : ahs_date Value7
      *  parm in : ahs_date Value8
      *  parm in : xsdc__string Value9
      *  parm in : ahs_logical Value10
      *  parm in : ahs_date Value11
      *  parm out: ahshist_series out
      *  return  : *ON = success
      *          : *OFF = failure
      * **************************************************************
     D stub_op_RequestSeriesData...
     D                 PR             1N   extproc('stub_op_RequestSeriesData+
     D                                     _')
     D this                                likeds(This_t)
     D Value0                              likeds(xsd_string)
     D Value1                              likeds(xsd_string)
     D Value2                              likeds(xsd_string)
     D Value3                              likeds(ArrayOfString_t)
     D Value4                              likeds(ArrayOfInt_t)
     D Value5                              likeds(ArrayOfString_t)
     D Value6                              likeds(ArrayOfString_t)
     D Value7                              likeds(ahs_date_t)
     D Value8                              likeds(ahs_date_t)
     D Value9                              likeds(xsd_string)
     D Value10                             likeds(ahs_logical_t)
     D Value11                             likeds(ahs_date_t)
     D out                                 likeds(ahshist_series_t)   
        //Code for other stand-alone fields and data structures

        QuoteDateFirst.val.value.year = %int(%subdt(%date():*YEARS)) - 1900;
        QuoteDateFirst.val.value.mon = %int(%subdt(%date():*MONTHS)) - 1;
        QuoteDateFirst.val.value.mday = %int(%subdt(%date():*DAYS));
        QuoteDateFirst.val.value.hour = 0;
        QuoteDateFirst.val.value.min = 0;
        QuoteDateFirst.val.value.sec = 0;
        QuoteDateFirst.val.value.wday = 0;
        QuoteDateFirst.val.value.yday = 0;
        QuoteDateFirst.val.value.isdst = 1;   

        //Some code initialization of the stub

          If (stub_op_RequestSeriesData(WsStub:Version:Source:SystemName:SeriesItems:SecurityIds
                                       :SourceFields:FieldNames:QuoteDateFirst:QuoteDateLast
                                       :TimeStampFlg:OnlyValidData:ModifiedSince
                                       :SeriesResult) = *On); 

Some tags in the output are removed

The output in the SOAP BODY is expected to be:

<ns1:SystemName>NOMX</ns1:SystemName>
<ns1:Items><ns1:string>SE0000108656_SEK_XSTO</ns1:string>
</ns1:Items>
<ns1:SourceFields><ns1:string>ASKPRICE</ns1:string>
<ns1:string>BIDPRICE</ns1:string>
<ns1:string>LASTPRICE</ns1:string>
</ns1:SourceFields>
<ns1:QuoteDateFirst><ns1:val>2019-08-26T02:01:01</ns1:val>
</ns1:QuoteDateFirst>
<ns1:QuoteDateLast><ns1:val>2019-08-26T02:01:01</ns1:val>
</ns1:QuoteDateLast>
<ns1:TimeStampFlag>D</ns1:TimeStampFlag>
</ns1:RequestSeriesData>

Actual output in the SOAP BODY is:

<ns1:SystemName>NOMX</ns1:SystemName>
<ns1:Items><ns1:string>SE0000108656_SEK_XSTO</ns1:string>
</ns1:Items>
<ns1:SourceFields><ns1:string>ASKPRICE</ns1:string>
<ns1:string>BIDPRICE</ns1:string>
<ns1:string>LASTPRICE</ns1:string>
</ns1:SourceFields>
<ns1:QuoteDateFirst><ns1:val>2019-08-26T02:01:01+02:00</ns1:val>
</ns1:QuoteDateFirst>
<ns1:QuoteDateLast><ns1:val>2019-08-26T02:01:01+02:00</ns1:val>
</ns1:QuoteDateLast>
<ns1:TimeStampFlag>D</ns1:TimeStampFlag>
</ns1:RequestSeriesData>

With the following error message:

<detail><Message>QuoteDateFirst or QuoteDateLast is invalid</Message><ExceptionType>System.Exception</ExceptionType><ExceptionMessage>DateTime must not be of local kind, use UTC or Unspecified instead</ExceptionMessage></detail>

Edit 2019-08-26 I played around with C code that is generated without any results.

Edit 2019-09-06 According to IBM there is nothing to do, the time zone is set on a system level and it cannot be changed by a program.

  • can you please include the definition of the function RequestSeriesData? – Radinator Aug 25 '19 at 16:19
  • @Radinator I updated the question with the definition of RequestSeriesData – Nathan Berhe Aug 26 '19 at 06:05
  • maby I'm just too stupid to see, but why are you subtracting 1900 from the current dates year portion? and you should also include the entire (relevant) code, which is responsible for your output. otherwise no one can reproduce or see your error – Radinator Aug 26 '19 at 11:14
  • @Radinator the reason I am removing 1900 from the current year is because `%int(%subdt(%date():*YEARS))` returns the current year + 1900, so that would be 3919. – Nathan Berhe Aug 26 '19 at 11:43
  • when I just DSPLY %int(%subdt(%date():*YEARS)); the output is 2019 – Radinator Aug 26 '19 at 13:16

1 Answers1

0

just a quick web search

https://www.code400.com/forum/forum/iseries-programming-languages/rpg-rpgle/143993-convert-utc-time-to-date-time-in-rpg-free

I got it to work by taking the first 10 digits of the 13 digit UTC number and adding to 01/01/1970 and it worked. Not sure what the other 3 digits are used for. One way around it I guess

Add (or subtract) %hours and %minutes offset if you need to.

also

The solution is to:

1) Add the number of seconds to Jan 1 1970. RPG's built-in timestamp math works nicely for this. This gives you a timestamp, but it is in the UTC timezone.

2) If you want the result in the current frame of reference (i.e. current time zone and daylight savngs time) the CEEUTCO API can give you the number of seconds offset from UTC and you can simply add that to the timestamp as well.

3) If you prefer the date in the date's frame of reference (i.e. show the daylight savings time offset if the date was during daylight savings time) then take the UTC timestemp from step 1 and convert the timezone with the QWCCVTDT API.

VAI Jason
  • 534
  • 4
  • 14