Local time in scheduled event shows UTC

1
I have a licensed cloud app running in northern VA (Eastern Time). In my project settings I have the scheduled event time zone as Eastern Time. I have a scheduled event that has to run at 6am EST (technically it’s 10am right now because it kicks off at UTC time … minus 4 hour offset is 6am). I CANT have the event shift because of Daylight Savings Time (DST). it *has* to be 6am I set a scheduled event to call a microflow. In this microflow I simply create two datetime variables: One to get the local time and the other to get UTC. The purpose is to determine if the difference is 4 orf 5 hours so I can determine if we’re in DST or not. I can then do my DST handling as needed (scheduling two tasks to run an hour apart : 10am UTC and 11am UTC…  At 10am if the difference is 4 it runs, so it runs during DST. At 11am the difference is 5 then it runs, because that’s 6am EST),. However, when the scheduled task executes and runs the Microflow this is what I get: [%BeginOfCurrentHourUTC%] returns the beginning of the hour @ UTC time, as expceted [%BeginOfCurrentHour%] returns the beginning of the hour… ALSO AT UTC time instead of returning the beginning of the current EST hour.  In the scheduled event settings I’ve tried changing the “Start date/time” to use both UTC *and* server and *both* give me the exact same results. I am running this from my acceptance environment and debugging remotely just to make sure I’m working with server time 9and not my local computer time).  What gives? It’s madenning enough that I have to schedule two different events and check the time zone to determine which microflow to execute just to handle DST. But now I can’t even calculate the local time to determine *IF* there is a DST offset or not. I like Mendix    EDIT: I even created a new user to act as a service account and set the default time zone of the user to EST. Then the scheduled task calls a microflow that I edited to call the original microflow but I used the Java action to execute the MF as this partiocular user… SAME THING. Both time variables are returning UTC.Again, this is running on the acceptance server and I’m checking values by remote debugging.  Someone please tell me there is a way to determine if the Microflow inside a scheduled event is operating inside DST or not. Changing the schedules and redeploying every 6 months isn’t an option. 
asked
3 answers
2

Use the formatDateTime() function to get your offset. Add 'Z' in the string parameter as in the example in the docs.

https://docs.mendix.com/refguide/parse-and-format-date-function-calls

answered
0

Just a few screenshots to clarify

Project settings including “Scheduled event time zone”

 

Scheduled Event setting

 

 

Microflow called by scheduled event uses this java action:

 

My UTC check Microflow where ALLL these variable return time based on UTC

First variable is the %CurrenDateTime% built in variable. Second is [%BeginOfCurrentHour%]  and third is [%BeginOfCurrentHourUTC%] . They all return times that are in UTC (first one is exact UC time, second two return the beginning of the current UTC hour)

answered
-1

I’m not sure if it’s quite what you are after, but you could create a Java Action to see if the time in a DateTime variable is in daylight savings for a timezone or not. 

Assuming you have a string called TimeZone with the timezone in (e.g. Europe/London), and the date in a DateTime called Date, you can use the following line of Java to return a boolean that is true or false, depending on if it’s daylight saving or not.
 

// BEGIN USER CODE
return java.time.ZoneId.of(this.Timezone).getRules().isDaylightSavings(this.Date.toInstant());
// END USER CODE

 
You can get the time zone name from the TimeZone system entity attribute Code if you needed it programatically.

Hope this helps.

answered