<?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 Re: Arcade vs Time for local feature class in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319832#M72209</link>
    <description>&lt;P&gt;Ya - that's the interesting part certainly.&amp;nbsp; I've been messing around with ChatGPT to write some Arcade / Python expressions/scripts for other workflows.&amp;nbsp; I haven't test this yet but this is the arcade expression that ChatGPT came up with:&lt;/P&gt;&lt;P&gt;var currentTime = $feature.TimeField; // Replace "TimeField" with your actual time field name&lt;BR /&gt;var currentDate = Date();&lt;BR /&gt;var timeZone = Timezone(currentDate, 'America/Denver'); // Mountain Time Zone&lt;/P&gt;&lt;P&gt;var dstStartDate = Date(Year(currentDate), 3, SecondSunday(3, 0, Year(currentDate)), 2, 0); // Second Sunday of March at 2:00 AM&lt;BR /&gt;var dstEndDate = Date(Year(currentDate), 11, FirstSunday(11, 0, Year(currentDate)), 2, 0); // First Sunday of November at 2:00 AM&lt;/P&gt;&lt;P&gt;if ((timeZone == -7 &amp;amp;&amp;amp; currentTime &amp;gt;= dstStartDate) || (timeZone == -6 &amp;amp;&amp;amp; currentTime &amp;lt; dstEndDate)) {&lt;BR /&gt;// Apply daylight saving time adjustment&lt;BR /&gt;return DateAdd(currentTime, 1, 'hours');&lt;BR /&gt;} else {&lt;BR /&gt;return currentTime;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Like I said, I've not tested this yet but it's a start on figuring out the catch/logic for the 2nd Sunday in March and the 1st Sunday in November.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2023 19:59:57 GMT</pubDate>
    <dc:creator>Robert_LeClair</dc:creator>
    <dc:date>2023-08-17T19:59:57Z</dc:date>
    <item>
      <title>Arcade vs Time for local feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319335#M72158</link>
      <description>&lt;P&gt;I'm simply trying to update a Date field with the current time. Ultimately I want to create an attribute rule that will automatically update the Date when a feature gets edited thus I have to use Arcade.&lt;/P&gt;&lt;P&gt;The following arcade functions all return a date value in UTC (six hours ahead of Mountain Time Zone):&lt;/P&gt;&lt;P&gt;- Now() --- returns date and time in UTC&lt;/P&gt;&lt;P&gt;- Date() --- returns date and time in UTC&lt;/P&gt;&lt;P&gt;- Timestamp() --- this is supposed to return a UTC value so....&lt;/P&gt;&lt;P&gt;- ToLocal(Timestamp()) --- returns date and time in UTC&lt;/P&gt;&lt;P&gt;- Today() --- Returns today's date but also sets the time to 6:00:00 AM - I'm not sure how this would get handled when the local time is past 6:00 pm and UTC time actually changes to the next day, I can only assume it would set the day to tomorrow's date and still set the time to 6:00:00 AM&lt;/P&gt;&lt;P&gt;Python's datetime.datetime.now() works just fine&lt;/P&gt;&lt;P&gt;Several of the function descriptions say, "Creates a date value in the local or system time of the client."&amp;nbsp; If the functions are actually working correctly what defines the client and how do I check its time setting?&lt;/P&gt;&lt;P&gt;It seems like it shouldn't be this difficult, am I missing something?&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;Edit: I've just tried this on my home computer with the same results.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 16:42:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319335#M72158</guid>
      <dc:creator>Markbe_utco</dc:creator>
      <dc:date>2023-08-17T16:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade vs Time for local feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319675#M72197</link>
      <description>&lt;P&gt;So I was playing around with an Arcade expression via the&amp;nbsp;&lt;A href="https://developers.arcgis.com/arcade/function-reference/date_functions/#dateadd" target="_blank"&gt;Date functions | ArcGIS Arcade | ArcGIS Developers&lt;/A&gt;&amp;nbsp;webpage and found these 3 lines of code will take the UTC time and subtract 6 hours for "local time."&lt;/P&gt;&lt;P&gt;var startDate = Date($feature.Date2);&lt;BR /&gt;var oneWeekLater = DateAdd(startDate, -6, 'hours');&lt;BR /&gt;return oneWeekLater;&lt;BR /&gt;&lt;BR /&gt;Date2 is my date/time attribute field.&amp;nbsp; Ignore the var name of oneWeekLater as I was just modifying the -6 and hours component.&amp;nbsp; It worked for me in subtracting 6 hours from UTC for my CO time zone.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 15:51:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319675#M72197</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2023-08-17T15:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade vs Time for local feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319714#M72199</link>
      <description>&lt;P&gt;Yeah, I saw the DateAdd function, but you'd have to change it back and forth from -6 and -7 to account for daylight savings.&amp;nbsp; Ultimately I'd like to add this attribute rule to several feature classes, and having to change each rule on each feature class twice a year is just a begging for something to go wrong.&amp;nbsp;&amp;nbsp; DateAdd may eventually be the workaround.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 16:40:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319714#M72199</guid>
      <dc:creator>Markbe_utco</dc:creator>
      <dc:date>2023-08-17T16:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade vs Time for local feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319720#M72200</link>
      <description>&lt;P&gt;I wonder if you could add an attribute rule based on the known dates of daylight savings?&amp;nbsp; Then based upon the date entered, it calculates the field using the Arcade function referenced above.&amp;nbsp; Related but perhaps not helpful is the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic6799.html" target="_self"&gt;RespectsDaylightSavingTime&lt;/A&gt; property in the ArcGIS Pro 3.1 API reference guide.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 16:48:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319720#M72200</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2023-08-17T16:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade vs Time for local feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319824#M72207</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2538"&gt;@Robert_LeClair&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I wonder if you could add an attribute rule based on the known dates of daylight savings?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;That's kind of what I'm working on at my workaround... the catch is trying to figure out the logic for t&lt;EM&gt;he second Sunday in March and the first Sunday in November&lt;/EM&gt; within the arcade script.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 19:51:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319824#M72207</guid>
      <dc:creator>Markbe_utco</dc:creator>
      <dc:date>2023-08-17T19:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade vs Time for local feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319832#M72209</link>
      <description>&lt;P&gt;Ya - that's the interesting part certainly.&amp;nbsp; I've been messing around with ChatGPT to write some Arcade / Python expressions/scripts for other workflows.&amp;nbsp; I haven't test this yet but this is the arcade expression that ChatGPT came up with:&lt;/P&gt;&lt;P&gt;var currentTime = $feature.TimeField; // Replace "TimeField" with your actual time field name&lt;BR /&gt;var currentDate = Date();&lt;BR /&gt;var timeZone = Timezone(currentDate, 'America/Denver'); // Mountain Time Zone&lt;/P&gt;&lt;P&gt;var dstStartDate = Date(Year(currentDate), 3, SecondSunday(3, 0, Year(currentDate)), 2, 0); // Second Sunday of March at 2:00 AM&lt;BR /&gt;var dstEndDate = Date(Year(currentDate), 11, FirstSunday(11, 0, Year(currentDate)), 2, 0); // First Sunday of November at 2:00 AM&lt;/P&gt;&lt;P&gt;if ((timeZone == -7 &amp;amp;&amp;amp; currentTime &amp;gt;= dstStartDate) || (timeZone == -6 &amp;amp;&amp;amp; currentTime &amp;lt; dstEndDate)) {&lt;BR /&gt;// Apply daylight saving time adjustment&lt;BR /&gt;return DateAdd(currentTime, 1, 'hours');&lt;BR /&gt;} else {&lt;BR /&gt;return currentTime;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Like I said, I've not tested this yet but it's a start on figuring out the catch/logic for the 2nd Sunday in March and the 1st Sunday in November.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 19:59:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319832#M72209</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2023-08-17T19:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade vs Time for local feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319963#M72226</link>
      <description>&lt;P&gt;First off, thanks for the idea of writing functions for finding SecondSunday and FirstSunday.&lt;/P&gt;&lt;P&gt;Well, this is a rabbit hole I didn't think was this deep. Things were looking up until I started to debug the function for FirstSunday.&amp;nbsp; Apparently using Arcade to find the day of the week (Monday = 1 ... Sunday = 7) doesn't identify the first Sunday in November as a Sunday.&amp;nbsp; I can only assume it has to something to do with the change in Daylight Savings &lt;span class="lia-unicode-emoji" title=":face_with_rolling_eyes:"&gt;🙄&lt;/span&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Showing here (bolded text are the first Sundays in November of three different years)&lt;/P&gt;&lt;P&gt;console("*******" )&lt;BR /&gt;console(text(Date(2021, 10, 6))+" WeekDay = "+ text(ISOWeekday(Date(2021, 10, 6) ))) // Nov 6 2021&lt;BR /&gt;&lt;STRONG&gt;console(text(Date(2021, 10, 7))+" WeekDay = "+ text(ISOWeekday(Date(2021, 10, 7) ))) // Nov 7 2021&lt;/STRONG&gt;&lt;BR /&gt;console(text(Date(2021, 10, 8))+" WeekDay = "+ text(ISOWeekday(Date(2021, 10, 8 ))) // Nov 8 2021&lt;BR /&gt;console("*******" )&lt;BR /&gt;console(text(Date(2022, 10, 5))+" WeekDay = "+ text(ISOWeekday(Date(2022, 10, 5) ))) // Nov 5 2022&lt;BR /&gt;&lt;STRONG&gt;console(text(Date(2022, 10, 6))+" WeekDay = "+ text(ISOWeekday(Date(2022, 10, 6) ))) // Nov 6 2022&lt;/STRONG&gt;&lt;BR /&gt;console(text(Date(2022, 10, 7))+" WeekDay = "+ text(ISOWeekday(Date(2022, 10, 7) ))) // Nov 7 2022&lt;BR /&gt;console("*******" )&lt;BR /&gt;console(text(Date(2023, 10, 4))+" WeekDay = "+ text(ISOWeekday(Date(2023, 10, 4) ))) // Nov 4 2023&lt;BR /&gt;&lt;STRONG&gt;console(text(Date(2023, 10, 5))+" WeekDay = "+ text(ISOWeekday(Date(2023, 10, 5) ))) // Nov 5 2023&lt;/STRONG&gt;&lt;BR /&gt;console(text(Date(2023, 10, 6))+" WeekDay = "+ text(ISOWeekday(Date(2023, 10, 6) ))) // Nov 6 2023&lt;BR /&gt;console("*******" )&lt;BR /&gt;console(text(Date(2023, 7, 4))+" WeekDay = "+ text(ISOWeekday(Date(2023, 7, 5) ))) // Aug 5 2021&lt;BR /&gt;console(text(Date(2023, 7, 5))+" WeekDay = "+ text(ISOWeekday(Date(2023, 7, 6) ))) // Aug 6 2021&lt;BR /&gt;console(text(Date(2023, 7, 6))+" WeekDay = "+ text(ISOWeekday(Date(2023, 7, 7) ))) // Aug 7 2021&lt;/P&gt;&lt;P&gt;Yields:&lt;/P&gt;&lt;P&gt;*******&lt;BR /&gt;2021-11-06T00:00:00-06:00 WeekDay = 6&lt;BR /&gt;&lt;STRONG&gt;2021-11-06T23:00:00-07:00 WeekDay = 6&lt;/STRONG&gt;&lt;BR /&gt;2021-11-08T00:00:00-07:00 WeekDay = 1&lt;BR /&gt;*******&lt;BR /&gt;2022-11-05T00:00:00-06:00 WeekDay = 6&lt;BR /&gt;&lt;STRONG&gt;2022-11-05T23:00:00-07:00 WeekDay = 6&lt;/STRONG&gt;&lt;BR /&gt;2022-11-07T00:00:00-07:00 WeekDay = 1&lt;BR /&gt;*******&lt;BR /&gt;2023-11-04T00:00:00-06:00 WeekDay = 6&lt;BR /&gt;&lt;STRONG&gt;2023-11-04T23:00:00-07:00 WeekDay = 6&lt;/STRONG&gt;&lt;BR /&gt;2023-11-06T00:00:00-07:00 WeekDay = 1&lt;BR /&gt;*******&lt;BR /&gt;2023-08-04T00:00:00-06:00 WeekDay = 6&lt;BR /&gt;2023-08-05T00:00:00-06:00 WeekDay = 7&lt;BR /&gt;2023-08-06T00:00:00-06:00 WeekDay = 1&lt;/P&gt;&lt;P&gt;So now my work around will have to have the work around of finding the first Saturday in November then adding 1 to make it the first Sunday... SHEESH!!!&lt;/P&gt;&lt;P&gt;Silver lining: I'm learning more about Arcade Scripting than I expected to this week.&amp;nbsp; This is my first real foray into Arcade Scripting.... I'm less impressed!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 15:38:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1319963#M72226</guid>
      <dc:creator>Markbe_utco</dc:creator>
      <dc:date>2023-08-18T15:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade vs Time for local feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1320183#M72244</link>
      <description>&lt;P&gt;Here is some new information&lt;/P&gt;&lt;P&gt;When trying to populate a field in the attribute table using the following script it provides two different answers:&lt;/P&gt;&lt;P&gt;Now()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;-- populates the field with the current date &amp;amp; time in UTC&lt;BR /&gt;console(Now())&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;-- populates the console window with the current date &amp;amp; time in local timetime&lt;/P&gt;&lt;P&gt;Timestamp()&amp;nbsp;&amp;nbsp; &amp;lt;-- populates the field with the current date &amp;amp; time in UTC, this is what it is supposed to do&lt;BR /&gt;console(Timestamp())&amp;nbsp;&amp;nbsp; &amp;lt;-- populates the console window with the current date &amp;amp; time in local timetime&lt;/P&gt;&lt;P&gt;ToLocal(Timestamp())&amp;nbsp; &amp;lt;-- populates the field with the current date &amp;amp; time in UTC, so what it is supposed to do&lt;BR /&gt;console(ToLocal(Timestamp()))&amp;nbsp; &amp;lt;-- populates the console window with the current date &amp;amp; time in local time, this is what it is supposed to do&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 16:38:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1320183#M72244</guid>
      <dc:creator>Markbe_utco</dc:creator>
      <dc:date>2023-08-18T16:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade vs Time for local feature class</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1320258#M72252</link>
      <description>&lt;P&gt;Well, here is my workaround to obtaining local date/time values with the workaround for not being able to identify the first Sunday in November as a Sunday (&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var currentDate = Timestamp() // current date &amp;amp; time in UTC
    
function MarchSecondSunday(inMonth, inYear){
    var sunday = 0 
    for(var x=0 ; x&amp;lt;=31 ; x++){
        if (ISOWeekday(Date(inYear, inMonth, x))==7){
            sunday = sunday + 1
            if(sunday == 2){
                return x
                break
            }
        }
    }
}


function NovemberFirstSaturday(inMonth, inYear){
    var saturday = 0 
    for (var y=0 ; y&amp;lt;=30 ; y++){
        if (ISOWeekday(Date(inYear, inMonth, y))==6){
            saturday = saturday + 1
            if(saturday == 1){
                console("saturday = " + saturday )
                return y+1
                break
            }
        }
    }
}


var dstStartDate = Date(Year(CurrentDate), 2, MarchSecondSunday(2, Year(currentDate))); // Second Sunday of March at 2:00 AM
var dstEndDate = Date(Year(CurrentDate), 10, NovemberFirstSaturday(10, Year(currentDate))); // First Sunday of November at 2:00 AM

if (currentDate &amp;lt; dstStartDate){
    console (dstStartDate + " ... Before DST Start ... " )
    return DateAdd(Timestamp(), -7, 'hours')
}
if ((currentDate &amp;gt;= dstStartDate) &amp;amp;&amp;amp; (currentDate &amp;lt; dstEndDate)){
    console (dstStartDate+ " ... During DST ... " + dstEndDate)
	return DateAdd(Timestamp(), -6, 'hours')
}
if (currentDate &amp;gt;= dstEndDate){
    console ("After DST End ... " + dstEndDate)
    return DateAdd(Timestamp(), -7, 'hours')
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 18:38:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-vs-time-for-local-feature-class/m-p/1320258#M72252</guid>
      <dc:creator>Markbe_utco</dc:creator>
      <dc:date>2023-08-18T18:38:27Z</dc:date>
    </item>
  </channel>
</rss>

