Time Bugs in Webcore

I've been struggling to figure out why some actions in pistons no longer work when previously they did. I think I narrowed it down to problems with the various time variables. Here is what I found.

  1. The value of $utc is wrong and it equal to $localNow and not to the actual utc time. Since I am in Colorado and Webcore knows this, this is a problem for pistons that relied on the $utc value and not the $localNow value. I do not know if this extends to the $now variable.
  2. Sometimes but not always, an IF statement that looks at time being between 8am and 8pm fails. It happened yesterday. The piston executed at 11:30am, but when I looked at it a short time later, the $time variable showed 5am-ish, which explained why the IF did not go. The problem is I use that IF construct in a number of pistons. I do not know if it fails in other pistons but now I'm suspicious.

I do not know if it is related, but I recently updated to this version of Webcore. I did not have problem 2 previously. I do not know if the utc problem was present previously.

Webcore Version

IIRC webCoRE on HE maps the UTC time to the local timezone try using

{datetime({{$now}-{$tzOffset}})}

a simple piston to display the variable values yields:

7/21/2023, 10:41:21 AM +322ms
+48ms ║Local Now: Fri, Jul 21 2023 @ 10:41:21 AM EDT
+48ms ║Now: Fri, Jul 21 2023 @ 10:41:21 AM EDT
+48ms ║Time 24: 10:41
+49ms ║UTC: Fri, Jul 21 2023 @ 10:41:21 AM EDT
+49ms ║TZ Offset: -14400000
+49ms ║Now-TZ Offset: Fri, Jul 21 2023 @ 2:41:21 PM EDT

1 Like

I understand that is the way it should be, but that is not the way it always is.

2023-07-22 09 32 22 utc

I just loaded the latest Webcore using Repair, and I see that the UTC bug is still there.

not a bug....

$now, $utc are an instant of time. it is the same instance of time.

How you print it out, depends on your location.

By default it prints out in the hub's timezone, but you can print out a time in another timezone by using the function formatDateTime(datetime, format, tzid)

so add formatDateTime, with the timezone you want and you will see the string output you request.

If you want to know dst offset (if any) use $tzOffset

Ian is looking into the long display vs. a string display in the IDE, but this is a display change, not a change in the value.

Sorry, I do not get it. $now should be my local time. $utc should be the GMT time. They should only be equal if your location is in the Greenwich time zone. My hub is in Colorado, so there should be a 6 or 7 hr time difference between $now and $utc. but there is not. They are approx equal, which I think is the bug.

Everything in webCoRE has been Unix epoch time.

' webCoRE only has datetime variables that are epoch

The strangeness in this was that another datetime was introduced that was not unix epoch time, yet no new variable type was introduced. So you could not tell if a datetime was unix epoch or something else....

  • the only benefit I can find in this hack was to allow you to determine your tzoffset, but that is now a system variable so you can just ask what it is if you need it.

Time is an instant. when you print it, you say your timezone (which defaults to the hub's timezone), and that same time instant may be printed differently.

If you want to have a piston operate in another timezone, you now can set the timezone for the piston.

  • so you can have a piston set a different timezone, and say do something at 10:00 am) and it will do it at 10:00 of the set timezone vs. the hub's default.