Community discussions

MikroTik App
 
eldoncito2019
Member
Member
Topic Author
Posts: 333
Joined: Fri Jun 14, 2019 1:07 pm

Thanks to Rextended

Sun Apr 10, 2022 4:22 pm

I made the following script thanks to the help of REXTENDED:
:delay 600
:global arrMonths {jan="01";feb="02";mar="03";apr="04";may="05";jun="06";jul="07";aug="08";sep="09";oct="10";nov="11";dec="12"}
{
    :local file "startup.txt"
    :local ndate [/system clock get date]; :local ntime [/system clock get time]
    :local itime  [/system clock get time]
    :local hours  [:pick $itime 0 2]
    :local minsec [:pick $itime 2 8]
    :local mhours [:tonum $hours]
    :local msymbl "AM"
    :if ($mhours > 11) do={:set msymbl "PM"}
    :set mhours ($mhours % 12)
    :if ($mhours = 0) do={:set mhours 12}
    :if ($mhours < 10) do={:set mhours "0$mhours"}
    :local mtime "$mhours$minsec $msymbl"
    :global new "TIME:$mtime   DATE: $[:pick $ndate 4 6]/$($arrMonths->[:pick $ndate 0 3])/$[:pick $ndate 7 11]"
    
    /file print file="$file"
    /file set $file contents=$new

}
As you can see, it is to know at what time my routerBoard does the first STARTUP, but it has a 10-minute delay, is there any way to subtract those 10 minutes here in this script, for example 11:13:00 if we subtract 10 minutes, it would remain 11:03:00, which would be the exact time the routerboard starts up.
Or do this subtraction:
{
:local time [/system clock get time];
:put ($time-00:10:00)
}


Thanks for your help.



EL DONCITO.
Last edited by eldoncito2019 on Mon Apr 11, 2022 12:05 am, edited 1 time in total.
 
gotsprings
Forum Guru
Forum Guru
Posts: 2102
Joined: Mon May 14, 2012 9:30 pm

Re: Thanks to Rextended

Sun Apr 10, 2022 11:56 pm

I used something similar to add 2 minutes.

Then that was the start time for my dyn updater scheduler.
 
eldoncito2019
Member
Member
Topic Author
Posts: 333
Joined: Fri Jun 14, 2019 1:07 pm

Re: Thanks to Rextended

Mon Apr 11, 2022 12:07 am

I used something similar to add 2 minutes.

Then that was the start time for my dyn updater scheduler.
How is your script friend?



EL DONCITO.
 
eldoncito2019
Member
Member
Topic Author
Posts: 333
Joined: Fri Jun 14, 2019 1:07 pm

Re: Thanks to Rextended

Thu Apr 14, 2022 4:37 pm

Solved.




EL DONCITO.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Thanks to Rextended

Fri Apr 15, 2022 12:03 pm

remember, if the time is 00:02:00 you get negative time after subtract 10 min, and you can not directly subtract 1 day to the date

Example

jan/01/2022 00:02:00 - 10 min = jan/01/2022 -23:52:00
but if you use absolute value for time and subtract 1 day:
= jan/00/2022 23:52:00
you also must set it to 31 instead of 00 and "subtract" 1 to the month replacing jan with dec, and decrease the year by 1...
also the AM / PM function do not work as expected with negative time values...
For circumvent this without too much effort, simply do not subtract 10 min if the time < 00:10:00
wiht this, the time is approximative +/- 10 min from 00:00 to 00:10 (from 12:00 AM to 12:10 AM)

Who is online

Users browsing this forum: Ahrefs [Bot] and 14 guests