· Dec 14, 2023

Trying to use %Library.PosixTime to convert a date/time and add/subtract seconds to the PosixTime but then when it goes back to a timestamp doesn't seem to have worked.


  • I take a time stamp and convert it to a PosixTime
  • Then for an Timezone offset (for example America/New_York would be -05:00) convert it to seconds  -18000
  • I add the -18000 to the PosixTime
  • I convert the PosixTime to time stamp - shouldn't the time stamp show a lot more of a difference?  
  • I am guessing that adding -18000 is not really a difference of 5 hours?   What am I missing?




Product version: IRIS 2023.1
$ZV: IRIS for Windows (x86-64) 2023.1 (Build 229U) Fri Apr 14 2023 17:17:41 EDT
Discussion (2)2
Log in or sign up to continue

Please note that "%PosixTime values have a 1 microsecond resolution", see %Library.PosixTime class reference documentation.

USER>set ts="2023-12-12 19:46:19.000"
USER>set Posix=##class(%Library.PosixTime).TimeStampToLogical(ts)
USER>write ##class(%Library.PosixTime).LogicalToTimeStamp(Posix-18000000000)
2023-12-12 14:46:19