How do you have an event go every hour in roblox? - roblox

I want to create an hourly event in roblox, but I don't know how to script the wait for 1 hour.

If you simply want a wait statement and know how you want to do this with your loop already programmed, a wait statement lasting an hour is wait(3600). Otherwise, here are some loop solutions that run code every hour according to the game or according to a time zone.
To run the script when the game starts, then do something every hour since then:
while true do
-- this should be the code that runs every hour
wait(3600)
end
To run according to UST (every time the minutes hit 0 in universal standard time):
while true do
local timeTable = os.date("!*t", tick())
if timeTable["min"] == "00" then
-- this should be the code that runs every hour
end
wait(1)
end
To run according to the local time zone (this only works in LocalScripts to my knowledge):
while true do
if os.date("%M", os.time()) == "00" then
-- this should be the code that runs every hour
end
wait(1)
end

Related

utcNow in Power Automate is using incorrect day (`dd`)

I'm running into a timezone issue when running my Flows on a schedule - and I can't seem to find a solution for it.
My timezone is currently +10:00 from UTC - Sydney, Australia.
For simplicities sake, I have a reoccurrence trigger running at 06:00 (6am local time) and 12:00 (12pm local time).
When I run my Actions - anything that needs a StartTime and an EndTime - I pass in the following parameters:
StartTime
Endtime
formatDateTime(utcNow(), 'yyyy-MM-dd"T"22:00:00.0000000Z')
formatDateTime( addDays(utcNow(), 1), 'yyyy-MM-dd"T"08:00:00.0000000Z')
The 22:00:00.0000000Z and 08:00:00.0000000Z above translate directly to 8am and 6pm respectively - essentially the entire work day hours.
Issue
When the trigger runs on the first occurrence, the StartTime and the EndTime are outputted to these values:
Tigger time - local
UTC date time
Start time UTC parameter
End time UTC parameter
2022-09-27 06:00
2022-09-26 20:00
2022-09-26T22:00:00.000000Z
2022-09-27T08:00:00.000000Z
When the trigger runs on the second occurrence, the StartTime and the EndTime are outputted to these values:
Tigger time - local
UTC date time
Start time UTC parameter
End time UTC parameter
2022-09-27 12:00
2022-09-27 02:00
2022-09-27T22:00:00.000000Z
2022-09-28T08:00:00.000000Z
Because the UTC date time has ticked over past midnight, the date value (dd) is now the next day due to the addDays(utcNow(), 1) expression.
This causes issues on the scripting of the Flow as when limiting the StartTime and EndTime of other actions, depending on when the Trigger runs is either looking at the local time's "Today" events or "Tomorrow" events.
For example, if I schedule an Out of Office / Automatic reply - and I schedule it to run on the 06:00 trigger, it will set my Automatic Reply to today - local time - 8am to 6pm. However, when it runs at the second trigger, 12:00 it will set my Automatic Reply to tomorrow - local time - 8am to 6pm.
Though this is not how I am using it, you can see it affects what actions do and perform.
Is there a way to ensure that it is always working of the current local date (dd) regardless if the UTC time has ticked over?
Have you tried using the addHours function instead of hard coding the hours in the formatdatetime function?
For the 6 am run I would try for the start time
formatDateTime(addHours(utcNow(), 2), 'yyyy-MM-ddTHH:mm:ss.0000000Z')
And for the end time
formatDateTime(addHours(utcNow(), 12), 'yyyy-MM-ddTHH:mm:ss.0000000Z')
You could also use a check to see which occurence run it is an combine that with the addhours approach.
equals(utcNow('HH'), '20')
It looks like, you want to do your Start time and End time calculations based on your LOCAL date, but you are doing the calculation based on the UTC date and thus get the wrong day, if UTC ticked over.
I guess the solution would be, to do your Start and End time calculations based on the LOCAL time instead of utcNow() and then transform the resulting LOCAL Start and End times into UTC times to be used as Start Time and End Time parameters.
Something to the effect of:
convertFromUtc(utcNow(),'+10:00','yyyy-MM-dd"T"06:00:00.000000')
to get the local start time of the current day and then from there
convertToUtc(localStartTime,'+10:00')
to get the UTC start time with the proper day.
And the same again for the End Time.
Though the other solutions seem logical in their workings, they dont account for daylight savings and other date time issues.
For the solution I ended up hard coding some of the data and calculations:
Action: "Convert time zone"
Base time: trigger time
Format string: Universal sortable date/time pattern [u]
Source: +10:00
Destination: UTC
Action: "Compose"
Expression: formatDateTime( body('Convert_time_zone'), 'dd')
Then for the start time UTC:
Action: Initialise variable
Name: Output Start Date Time
Type: String
Value: yyyy-MM-[Output from Compose*]"T"22:00:00.0000000Z')
* in that [Output from Compose] I made it an expression so I could subtract 1 day, using: sub( int(outputs('Compose')), 1)
This way I could always get my local date (dd) then manually shift the date, and set it as well as the time for start time.
Then I would use that local date for the End date time, and manually set the time.
Not the cleanest solution, but it works 100% of the time regardless of daylight savings or any time conversions. It is however not transferrable to other users without them editing the info.

Calculate sum overlapping minutes in tableau

I have two excel extracts, one containing the schedules of employees and the other containing the actual times the employees worked. There are multiple schedule blocks in a day and employees can have multiple activity start and stop times in or out of scheduled time.
Schedule:
Actvtivity:
I need to use this data to calculate the sum of actual minutes worked only during the scheduled time with Tableau. In the above images the first schedule event would have 115 minutes worked and the second line would have 92 totaling in 207.
I tried to start easy by only calculating activity entries that fall within both the start and stop of a scheduled block, but tableau either return nothing or the "Many to 1" *
attempt 1:
case attr([#Fields:Date]) when ATTR([ScheduleStopStart].[#fields:excDate])
then
if attr([Start]) >= Min([ScheduleStopStart].[Start])
and attr([Stop]) <= max([ScheduleStopStart].[Stop])
then datediff("minute", attr([Start]), attr([Stop]))
END
END
Attempt 2:
IF ATTR([#Fields:Date]) = ATTR([ScheduleStopStart].[#fields:excDate]) then (
if attr([Start]) >= attr([ScheduleStopStart].[Start])
and attr([Stop]) <= attr([ScheduleStopStart].[Stop])
then DATEDIFF("minute", attr([Start]),attr([Stop]))
else 0
end
)
else
0
END

Use External Window Time Stamp to Debug Siddhi Stream Query

I am planning to use the historical event traces (stored in JSON with my own event time stamp recorded for each event) to debug the Siddhi stream queries that I have just created. My stream starts with:
from MyInputEventStream#window.externalTime(my_own_timestamp, 10 min)
select some_fields
insert into MyOutpuStream;
and I will input my events from traces, one by one.
Supposed event 1 arrives at the specified my_own_timestamp = 1528905600000, which is 9 am PST time, June 13. and event 2 arrives at 11 minutes later, my_own_timestamp = 1528906260000. I believe that I will get the output at MyOutpuStream at 9:10 am, as time_stamp(e2) - time_stamp(e1) > 10 min, and e2 will trigger the system after the windows passes.
Now supposed event 1 arrives at my_own_timestamp = 1528905600000, that is, 9:00 am. But no events will arrive in the next 2 hours. Do I still get the output at 9:10 am, as in reality, the window time should expire at 9:10 am, independent of when the next event should arrive? But it seems that in this case, the internal timing system of Siddhi will have to incorporate my event input's time stamp, and then set the expiration time of the events based on the clock system of the process on which the Siddhi is running. Is this correct? could you help clarify it.
You won't get an output at 9:10 am. Because if you use externalTime, the event expiration logic will entirely base on the timestamp that you defined. And it will wait for a timestamp that satisfies the time difference which is greater than or equal to expire the previous event.
What internally happens is;
def array previousEvents;
foreach currentEvent in currentEvents (events that are coming in):
def currentTime = currentEvent.timestamp;
foreach previousEvent in previousEvents:
def previousTime = previousEvent.timestamp;
def timeDiff = previousTime - currentTime + windowLength;
if (timeDiff <= 0) {
remove previousEvent from previousEvents;
set expired timestamp of previousEvent to currentTime;
expire previousEvent;
}
previousEvents.add(currentEvent);

Set trigger time of periods in Zabbix

I have a host that I monitor in 08:00-20:00 and trigger which acts when no ping.
Sometimes a host can be switched off in period of 20:00-08:00. I want in this situation dont't to trigger that act till 10:00 next day. Is it possible?
You can use the time() trigger function. Appending this to the existing function should work (replace ... with the reference to the same item as already in the expression):
and time(...) > 080000 and time(...) < 200000
Note that this will make the trigger ignore the time period outside of the bounds, so it will fire at 08:00 only if the problem condition still persists. Not sure how 10:00 fits in your original description.
On newer versions of Zabbix you can set Working hours for items, so the collect just will happens in a specific range..
https://www.zabbix.com/documentation/2.0/manual/appendix/time_period

How to set workflow condition that runs 2AM everyday?

I am to create email alert which works together with workflow rule.
My goal is to set the workflow that runs 2am everyday &&
my custom object field 'startDate' is tomorrow.
Basically every 2am workflow checks my custom object and see if startDate is tomorrow.
I'm at workflow page looking at Date predefined variable,
I see:
DATE
DATEVALUE
DAY
MONTH
NOW
TODAY
YEAR
For the startDate, I can set condition startDate = today() + 1
For second condition which is 2am everyday I can't think of a way. I don't see HOUR variable etc..
Has anyone done this before?
UPDATE
This might work I have to test though..
Change NOW() datetime output to String (done by TEXT)
Start from index 12 and grab 2 chars to the right (done by MID)
This means I obtained hour part of current time and if the value equals to '02' which means
2am at night.
MID(TEXT(NOW()), 12, 2) = '02'
Wait a sec.. but WHEN does salesforce check this workflow???
If they check workflow once a day, what time it would be? If check is done past 2am, this workflow would never get looked at??? I'm a bit confused.
Work flow only triggers on some event (object update, create, etc.). So having it run at 2am without a some sort of trigger is impossible.
The trick is to use schedulable apex to insert an object (or update a field) every day at 2am and set your workflow to trigger on that insert/update. Then your workflow would fire off on that object at whatever time your scheduled apex ran.