please help me to make it work i cant make a script so can you modifi this for me to make it work in v7.10 i cant get [/system clock get date]
:local dateint do={
:local montharray { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" };
:local days [ :pick $d 4 6 ];
:local month [ :pick $d 0 3 ];
:local year [ :pick $d 7 11 ];
:local monthint ([ :find $montharray $month ]);
:local month ($monthint + 1);
:if ( [len $month] = 1) do={
:local zero "0";
:return [:tonum ("$year$zero$month$days")];
} else={
:return [:tonum ("$year$month$days")];
}
};
:local timeint do={
:local hours [ :pick $t 0 2 ];
:local minutes [ :pick $t 3 5 ];
:return ($hours * 60 + $minutes);
};
:local date [ /system clock get date ];
:local time [ /system clock get time ];
:local today [$dateint d=$date] ;
:local curtime [$timeint t=$time] ;
:foreach i in [ /ppp secret find where profile="1m" ] do={
:local comment [ /ppp secret get $i comment];
:local name1 [ /ppp secret get $i name];
:local gettime [:pick $comment 12 20];
:if ([:pick $comment 3] = "/" and [:pick $comment 6] = "/") do={
:local expd [$dateint d=$comment] ;
:local expt [$timeint t=$gettime] ;
:if (($expd < $today and $expt < $curtime) or ($expd < $today and $expt > $curtime) or ($expd = $today and $expt < $curtime)) do={
/ppp secret set profile=Expired $i ;
/ppp active remove [find where name=$name1];
}
}
}
http://forum.mikrotik.com/t/warning-routeros-v7-10-will-break-all-scripts-based-on-system-clock-get-date-or-other-date-s/166576/1
stop spam on forum
the script is really shitty, this is what you want, but still shitty.
:local dateint do={
:local days [ :pick $d 8 10 ];
:local month [ :pick $d 5 7 ];
:local year [ :pick $d 0 4 ];
:return [:tonum ("$year$month$days")];
};
im so sorry for spam but im noob can you put this with the script and thanks (i dont know anything about scripting)
Amm0
April 26, 2024, 5:04pm
4
It’s just hard to help when it bit unclear what the script is trying to do…
There is also [:timestamp] which will give you an int of the time (in nanoseconds since 1970). Also time types can be compared without converting to an int.
It’s just hard to help when it bit unclear what the script is trying to do…
There is also [:timestamp] which will give you an int of the time (in nanoseconds since 1970). Also time types can be compared without converting to an int.
can i get the time online from https://worldtimeapi.org/api/timezone/Asia/Baghdad
and what is the script for it ?
Amm0
April 26, 2024, 5:19pm
6
Not easily in v7.10, but in latest stable this work:
{
:local bgwtime [:deserialize from=json ([/tool/fetch url=https://worldtimeapi.org/api/timezone/Asia/Baghdad as-value output=user]->"data")]
# debug to show output
:put $bgwtime
# print one value from the worldtimeapi.org data
:put ($bgwtime->"day_of_week")
# get it's unixtime as a int
:local bgwunix [:tonum ($bgwtime->"unixtime")]
:put $bgwunix
}
abbreviation=3;client_ip=x.x.x.x;datetime=2024-04-26T20:18:47.951963+03
:00;day_of_week=5;day_of_year=117;dst=false;dst_from=;dst_offset=0;dst_until=;
raw_offset=10800;timezone=Asia/Baghdad;unixtime=1714151927;utc_datetime=2024-0
4-26T17:18:47.951963+00:00;utc_offset=03:00:00;week_number=17
5
1714151927