Select to view content in your preferred language

ArcGIS Velocity Feed Time Zone Not UTC

403
4
03-05-2024 04:21 PM
Teresa_Blader
Occasional Contributor III

Hello! I've got a feed that is polling a local server including timestamps in CST central time and Velocity is assuming they are UTC and and then map viewer is displaying them -6 hours trying to correct for CST. The time zone is not included in the time stamp from the source in the API. 

"yyyy-MM-dd'T'HH:mm:ss.SS"

What is the best way around this? I'm currently pushing a feed to a ArcGIS Velocity layer watching the TRACK_ID to keep only new features each push.

Thanks!!

Teresa Blader
Olmsted County GIS Specialist
0 Kudos
4 Replies
JeffSilberberg
Occasional Contributor III

Teresa, 

    I fight date issues all the time.  A couple of things might help.  I  do a Fiedl Mapper as one of the first steps in my Analytic and use arcade to calc_newDateValue, calculate (change) the incoming Time stamp as necessary.  II will still be doing this, but now the arcade may be easier to work with as we have new support in AGOL and I am hopeful we will have new support in Velocity 5.1 (my notices say Wednesday Night / Thursday Morning for my instances) later this week as well.  

https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/time-is-on-your-side-with-new-field-...

https://developers.arcgis.com/arcade/function-reference/date_functions/

Specifically changeTimeZone()
Changes the time zone used to display the given Date value. If the input dateValue has an unknown time zone, then the output Date value will display with the same date and time as the input dateValue, but will be assigned the newTimeZone.. This does not work in 4.3

ToLocal()
Creates a new Date value matching the epoch of the input date and sets the time zone to the local or system time zone of the client.

and ToUTC()
Creates a new Date value matching the epoch of the input data and sets the time zone to UTC (Coordinated Universal Time).

https://developers.arcgis.com/arcade/function-reference/math_functions/#number

Also number() 
Converts the input value to a number. Date values will be converted to the number of milliseconds since Jan. 1, 1970 (i.e. the Unix epoch).

As an example to get Mountain Time from UTC - 

  • Calc Fix Time Local

    • Field: calc_fixTimeMountain

    • Expression: calc_fixTimeUTC + currentOffsetUTC()

    • Expression: Number(DateAdd($feature.eventTimeUnix, -2, 'hours'))

      • Calc Fix Time Local

        • Field: calc_fixTimeMountain

        • Expression: calc_fixTimeUTC + currentOffsetUTC()

        • Expression: Number(DateAdd($feature.eventTimeUnix, -2, 'hours'))

 

I Hope this makes sense and helps you. 

 

 

    

PeterNasuti
Esri Contributor

@Teresa_Blader Thanks for posting, I agree with @JeffSilberberg that the methods to utilize would be either ChangeTimeZone() https://developers.arcgis.com/arcade/function-reference/date_functions/#changetimezone or DateAdd() https://developers.arcgis.com/arcade/function-reference/date_functions/#dateadd 

Velocity is assuming UTC on ingestion by design but that is something we could consider for a future release to add user timezone parameter specification for string date parsing to adjust to UTC under-the-hood which is what is primarily utilized for IoT/real-time monitoring.

Teresa_Blader
Occasional Contributor III

Thanks for the response @PeterNasuti and @JeffSilberberg 

I may be incorrectly assuming the API is pushing CST, so I'll verify - but I'm going to keep those in mind and give those a try! 

Teresa Blader
Olmsted County GIS Specialist
0 Kudos
JeffSilberberg
Occasional Contributor III

@Teresa_Blader 

   Best tools I have found are the Console() function in Arcade when you are in the Arcade Editor and the Sample Data in the Analytic itself.