<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Parsing GeoJSONLayer Date Field for Time Slider in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/parsing-geojsonlayer-date-field-for-time-slider/m-p/1105549#M74903</link>
    <description>&lt;P&gt;Working to implement a time slider for a GeoJSONLayer using ArcGIS JS 4.21, but have run into an issue regarding the formatting of the field in the GeoJSON file.&lt;/P&gt;&lt;P&gt;According to &lt;A href="https://doc.arcgis.com/en/arcgis-online/manage-data/work-with-date-fields.htm" target="_blank"&gt;https://doc.arcgis.com/en/arcgis-online/manage-data/work-with-date-fields.htm&lt;/A&gt; the closest supported date format for an input file is YYYY-MM-DDThh:mm:ss.s, but the GeoJSON file I am working with has the format of YYYY-MM-DDThh:mm:ss (no fractional second included).&lt;/P&gt;&lt;P&gt;From the timeslider filter example, it looks like the timeslider is expecting unix timestamps.&lt;/P&gt;&lt;P&gt;To clarify my question- how can I get the timeslider to work with GeoJSON date fields that are currently formatted as YYYY-MM-DDThh:mm:ss ?&lt;/P&gt;&lt;P&gt;Example code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  const layer = new GeoJSONLayer({
    url: geojsonurl,
    geometryType: "point",
    title: "Observations",
    visible: true,
    fields: [
      { name: "ObservationId", type: "string" },
      { name: "MeasuredAt", type: "date" }
    ],
    outfields: ["*"],
    timeInfo: {
      startField: "MeasuredAt", // name of the date field stored as "2020-06-13T09:33:00"
      interval: {
        unit: "days",
        value: 1
      }
    }&lt;/LI-CODE&gt;&lt;P&gt;Example error:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//[object, object]
{
  "error":{
    "code": null,
    "description": "Value 2020-06-25T20:03:00 is not a valid value for the field type - 
    field: MeasuredAt,
    type: esriFieldTypeDate,
    nullable: true"
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any pointers.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Oct 2021 14:32:31 GMT</pubDate>
    <dc:creator>ADClark</dc:creator>
    <dc:date>2021-10-07T14:32:31Z</dc:date>
    <item>
      <title>Parsing GeoJSONLayer Date Field for Time Slider</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/parsing-geojsonlayer-date-field-for-time-slider/m-p/1105549#M74903</link>
      <description>&lt;P&gt;Working to implement a time slider for a GeoJSONLayer using ArcGIS JS 4.21, but have run into an issue regarding the formatting of the field in the GeoJSON file.&lt;/P&gt;&lt;P&gt;According to &lt;A href="https://doc.arcgis.com/en/arcgis-online/manage-data/work-with-date-fields.htm" target="_blank"&gt;https://doc.arcgis.com/en/arcgis-online/manage-data/work-with-date-fields.htm&lt;/A&gt; the closest supported date format for an input file is YYYY-MM-DDThh:mm:ss.s, but the GeoJSON file I am working with has the format of YYYY-MM-DDThh:mm:ss (no fractional second included).&lt;/P&gt;&lt;P&gt;From the timeslider filter example, it looks like the timeslider is expecting unix timestamps.&lt;/P&gt;&lt;P&gt;To clarify my question- how can I get the timeslider to work with GeoJSON date fields that are currently formatted as YYYY-MM-DDThh:mm:ss ?&lt;/P&gt;&lt;P&gt;Example code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  const layer = new GeoJSONLayer({
    url: geojsonurl,
    geometryType: "point",
    title: "Observations",
    visible: true,
    fields: [
      { name: "ObservationId", type: "string" },
      { name: "MeasuredAt", type: "date" }
    ],
    outfields: ["*"],
    timeInfo: {
      startField: "MeasuredAt", // name of the date field stored as "2020-06-13T09:33:00"
      interval: {
        unit: "days",
        value: 1
      }
    }&lt;/LI-CODE&gt;&lt;P&gt;Example error:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//[object, object]
{
  "error":{
    "code": null,
    "description": "Value 2020-06-25T20:03:00 is not a valid value for the field type - 
    field: MeasuredAt,
    type: esriFieldTypeDate,
    nullable: true"
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any pointers.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 14:32:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/parsing-geojsonlayer-date-field-for-time-slider/m-p/1105549#M74903</guid>
      <dc:creator>ADClark</dc:creator>
      <dc:date>2021-10-07T14:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing GeoJSONLayer Date Field for Time Slider</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/parsing-geojsonlayer-date-field-for-time-slider/m-p/1105625#M74907</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the GeoJSONLayer creates date fields if the GeoJSON feature properties contain unix/epoch timestamp. In your case, feature property contains ISO 8601 strings. So you will need to:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Intercept your data after it is fetched.&lt;/LI&gt;&lt;LI&gt;Loop through the GeoJSON features&lt;/LI&gt;&lt;LI&gt;Get the ISO value from the feature&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Parse a unix/epoch timestamp from the ISO value&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Create a new property of the feature and assign the new epoch timestamp&lt;/LI&gt;&lt;LI&gt;Then in your GeoJSONLayer constructor&lt;OL&gt;&lt;LI&gt;Set fields property. &amp;nbsp;Fields can only contain the property that has the unix timeStamp and set the field type to date.&lt;/LI&gt;&lt;LI&gt;Set timeInfo property as you shown above. But for the field use the field you created in the step above.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;A href="https://codepen.io/U_B_U/pen/qBjeeYx?editors=0010" target="_self"&gt;This test app&lt;/A&gt; shows everything I listed above. However, this app needs to be updated when you upgrade to 4.22 or above versions. At 4.21, when you intercept the geojson request, the geojson data is returned as array buffers, so you will have to decode those array buffers at 4.21.&lt;/P&gt;&lt;P data-unlink="true"&gt;At 4.22, we are changing this behavior. &amp;nbsp;We updated the request flow of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;workers&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;so that an&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#RequestInterceptor" target="_self"&gt;after interceptor&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;receives the expected data type. This means after interceptors that were expecting&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;array-buffers&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;for client-side layers such as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoJSONLayer.html" target="_self"&gt;GeoJSONLayer&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html" target="_self"&gt;CSVLayer&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;will receive the expected data types&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;json&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;text. At the very end of this test app, I added an after interceptor function that will work at 4.22.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lastly, we will update the doc for &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoJSONLayer.html#timeInfo" target="_self"&gt;GeoJSONLayer.timeInfo&lt;/A&gt; property to show the workflow we talked about in this discussion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Undral&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 17:34:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/parsing-geojsonlayer-date-field-for-time-slider/m-p/1105625#M74907</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-10-07T17:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing GeoJSONLayer Date Field for Time Slider</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/parsing-geojsonlayer-date-field-for-time-slider/m-p/1105631#M74908</link>
      <description>&lt;P&gt;Very thorough reply, thank you. Any timetable for 4.22 release?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 17:46:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/parsing-geojsonlayer-date-field-for-time-slider/m-p/1105631#M74908</guid>
      <dc:creator>ADClark</dc:creator>
      <dc:date>2021-10-07T17:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing GeoJSONLayer Date Field for Time Slider</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/parsing-geojsonlayer-date-field-for-time-slider/m-p/1105644#M74909</link>
      <description>&lt;P&gt;It will be released end of December 2021.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 18:35:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/parsing-geojsonlayer-date-field-for-time-slider/m-p/1105644#M74909</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-10-07T18:35:46Z</dc:date>
    </item>
  </channel>
</rss>

