Community discussions

MikroTik App
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 2:12 pm

⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

The new RouterOS v7.10+ changes the date reported by [/system clock get date] from may/10/2023 to the correct ISO 2023-05-10 format.
(and probably all other points where can be retrieved one date, like on /log, /certificate, /system scheduler, address-list entry creation-time, etc.)

THIS IS NECESSARY AND HAD TO BE DONE BEFORE,
hopefully it's a right step in the direction of standardizing all dates in ISO format even within LOG and other places where the date is misspelled.

BUT... this means that:
⚠️⚠️⚠️ All old scripts containing [/system clock get date] will stop working properly from v7.10+ ⚠️⚠️⚠️

⚠️⚠️⚠️ Not only on [/system clock get date], but on every other places where date is used⚠️⚠️⚠️

A small price to pay for doing things right.

In the next few days I am editing all my scripts posted here:
viewtopic.php?t=177551
so that they are compatible with this change.

EDITED:
exception found till now:
/system resource build-time = May/09/2023 10:38:53
from @pe1chl: system,info ntp change time May/10/2023 14:27:56 => May/10/2023 14:27:56
Last edited by rextended on Wed May 10, 2023 9:08 pm, edited 14 times in total.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 18697
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 2:17 pm

You need one script to modify all your scripts. ;-)
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26267
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 2:19 pm

LONG LIVE ISO 8601 https://xkcd.com/1179/
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 2:21 pm

LONG LIVE ISO 8601 https://xkcd.com/1179/
I've been asking (and not only me) for this change for years, finally...
 
msatter
Forum Guru
Forum Guru
Posts: 2892
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 2:24 pm

If Mikrotik was only a just a bit smarter then they had introduced with new format a new variable containing the new date format.

Someting like: [/system clock get isodate]

Just my two cents....
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 2:31 pm

corrrect, but see this:

viewtopic.php?p=1001170#p1001193
Last edited by rextended on Wed May 10, 2023 3:09 pm, edited 2 times in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 2:33 pm

Also LOG date is reported by ISO format, but is still reported on SHITTY 4-modes:

1) only time is just happened,
2) only day if is the same month
3) only month-day if is the same year
4) full date (year-month-day) only if the log is of another year....

LOG MUST HAVE EVERYTIME FULL DATE...
 
holvoetn
Forum Guru
Forum Guru
Posts: 5105
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 2:40 pm

If Mikrotik was only a just a bit smarter then they had introduced with new format a new variable containing the new date format.

Someting like: [/system clock get isodate]
For backward compatibility, this approach with new variable is the only way forward.
Old stuff will still work.
New stuff can use the new format.

It's not too late since 7.10 is still in beta.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 18697
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 2:43 pm

Msatter gets the best post of the day award. One free script from rextended.
Brilliant idea though!! Is Normis listening???
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 18697
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 2:44 pm

LONG LIVE ISO 8601 https://xkcd.com/1179/
I've been asking (and not only me) for this change for years, finally...
So how long do I have to ask for Zerotrust Cloudflare Tunnel in an options package (for all devices).............. ?? :-)
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 2:47 pm



I've been asking (and not only me) for this change for years, finally...
So how long do I have to ask for Zerotrust Cloudflare Tunnel in an options package (for all devices).............. ?? :-)
Some years... :P
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 2:54 pm

Someting like: [/system clock get isodate]
Since the date format is changed also on LOGs, certificates, etc. and WebFig (and on future I hope Winbox)

Better add something like this, that influence all the places where a date can be retrieved [clock / log / certificate, etc.].
/system clock set format=<VALUE>
format can be yyyy-MM-dd or mmm/dd/yyyy, the default is yyyy-MM-dd
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3040
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 5:21 pm

LONG LIVE ISO 8601 https://xkcd.com/1179/
Except it should have been a type from the real unixsecs...see
https://xkcd.com/1537/
:todate [:timestamp] 
 
User avatar
Larsa
Forum Veteran
Forum Veteran
Posts: 982
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 5:26 pm

Nice that the date format issue is finally being addressed even if the initial implementation creates compatibility issues completely unnecessarily IMO. Seriously Mikrotik, please consider a different implementation.

IMO, a much better and general solution would be to let the "date" function work as before but expanded it with arguments using Linux date-format strings something like
[/system clock get date "%h %m %s"]


The other suggestions like "isodate" would also work but I like my solution better (obviously) because of its additional benefits. Ammo's ":timestamp" is also great and ":todate" could also be extended to take date format arguments.

In addition, it is my strong belief that "/system clock set format=<VALUE>" should be implemented regardless and should affect the entire system such as the log, console, etc.
Last edited by Larsa on Wed May 10, 2023 6:01 pm, edited 2 times in total.
 
User avatar
BrianHiggins
Forum Veteran
Forum Veteran
Posts: 702
Joined: Mon Jan 16, 2006 6:07 am
Location: Norwalk, CT
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date]

Wed May 10, 2023 5:34 pm

/system clock set format=<VALUE>
format can be yyyy-MM-dd or mmm/dd/yyyy, the default is yyyy-MM-dd
absolutely fully and wholeheartedly agree 100% with this idea. this is the only way it should be done, and then ALL date/time fields in ROS, terminal winbox and webfig, should be displayed using this format. Once this is implemented and rolled out & tested, then you can change the default date/time format in a future ROS release to be the ISO standard without breaking much of anything for anyone.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10146
Joined: Mon Jun 08, 2015 12:09 pm

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 5:36 pm

What I don't understand is why the new date format is implemented only for console, and only in very limited cases.
The first log message I see already breaks the new system: 14:27:56 system,info ntp change time May/10/2023 14:27:56 => May/10/2023 14:27:56
I mean, was it really that difficult to make the change EVERYWHERE at the same time? I presume RouterOS uses functions for things like this...

And indeed: the "shortened" version of date/time should go. A log message should not have only a timestamp, as above, but always a full date/time.
 
User avatar
Larsa
Forum Veteran
Forum Veteran
Posts: 982
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 5:43 pm

Yeah, that's why something like "/system clock set format=<VALUE>" should have a system-wide effect.

>
> @Amm0: Except it should have been a type from the real unixsecs...see https://xkcd.com/1537/
>
Touché 🤣🤣🤣
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 7:13 pm

The first log message I see already breaks the new system: 14:27:56 system,info ntp change time May/10/2023 14:27:56 => May/10/2023 14:27:56
Added, thanks
 
User avatar
Larsa
Forum Veteran
Forum Veteran
Posts: 982
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 7:39 pm

Sorry, my proposal is closer to RouterOS language and is easy manageable instead to add parameters to all points where date can be retrieved. viewtopic.php?t=196061#p1001195

Absolutely not! ;-)

IMO, it should never ever be mandatory to make a system-wide change just because someone want decent and flexible date values for scripting.

You might have missed it, but as I've already mentioned in my previously post: the best solution would be a combination where you can both use a flexible date management for scripting as well as a system-wide setting. Note, both optional and not one or the other!

1) For scripting (or whatever similar command using linux date format):
[/system clock get date format="%h %m %s"]

AND/OR:

2) set a system-wide format like your suggestion:
/system clock set format="%YYYY-%MM-%DD-%hh:%mm:%ss"
Last edited by Larsa on Wed May 10, 2023 8:03 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 8:03 pm

@Larsa,
you don't understand the meaning:
It takes MikroTik programmers decades to do something,
so currently they have two methods, the new one, and the old one.
Do you think they start making one that includes "%x" variables? (I made one like that, if you need...)

The best thing you can do, to make him want to do it, is a very trivial parameter that decides which format to use,
so you are perfectly in control of how date is handled in that RouterBOARD globally.

Do you understand now, or will you ignore it???

For me the only valid format should be Unix Epoc everywhere, and if you want to read the date in plain text, convert it.
 
User avatar
Larsa
Forum Veteran
Forum Veteran
Posts: 982
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 8:16 pm

Yes my friend, I actually do understand. As for the Linux date format, it's really nothing new and has been used for decades in the Linux/RoS standard libraries. And the same goes for linux timestamp that probably would be quite easy to implenent as a global var or function call.

However to be honest, a system wide date format is probably a much bigger change than just adding a flexible date format for scipting. But I still hope they will implement it some day.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3040
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 8:22 pm

I don't think anyone disagrees with:
For me the only valid format should be Unix Epoc everywhere, and if you want to read the date in plain text, convert it.
But quibbling about %'s vs DD seems a bit premature.

At this point, we're taking about the output of "clock get" to avoid the need to parse English month names... Nothing more is included AFAIK (yet?). While tend to agree with @rextended YYYYMMDD style seems more intuitive/modern – but be long wait for either %D or DD formatters I'm sure ;)

The ISO fix for /system clock is for sure a step in right direction...but doesn't really solve the TWO use cases:
1. for scripting, format operators existing "unixmilliseconds from epoch", [:timestamp] e.g. :typeof == "time" – e.g. ":todate" (":dateformat", ":toisodate", whatever)
2. for system output/logging/etc, the idea of a "date/time locale" that controls it (expressed however) — e.g. "/system clock set format="

And for sure they should same formatters, but I'm really not whether the % is the most important part here...
Last edited by Amm0 on Wed May 10, 2023 8:25 pm, edited 2 times in total.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 18697
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 8:22 pm

Larsa you have the greatest potential to sway MT folks to do the right thing.
Threaten them that Santa will not send any toys to their children if they do not fix right away.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10146
Joined: Mon Jun 08, 2015 12:09 pm

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 8:52 pm

At this point, we're taking about the output of "clock get" to avoid the need to parse English month names... Nothing more is included AFAIK (yet?).
The change notes said:
*) console - changed time format according to ISO standard;

So I expected any date/time output visible on the console to have changed to ISO standard. Not limited (or maybe not even including) "clock get".
And indeed, when I print /ip/firewall/address-list I do get the new format. But not in the message logged by NTP.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 9:03 pm

From first post, I update it over time:
[…]
(and probably all other points where can be retrieved one date, like on /log, /certificate, /system scheduler, etc.)
[…]
EDITED:
exception found till now:
/system resource build-time = May/09/2023 10:38:53
from @pe1chl: system,info ntp change time May/10/2023 14:27:56 => May/10/2023 14:27:56
[…]
 
User avatar
Larsa
Forum Veteran
Forum Veteran
Posts: 982
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 9:25 pm

Regardless of which solution one might prefer, I'm pretty sure most people agree that the current solution in v7.10b should be redone to restore script compatibility.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 9:32 pm

NO, it's better to "fix" the scripts (very easy) than revert to the previous shitty format
 
holvoetn
Forum Guru
Forum Guru
Posts: 5105
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 10:02 pm

NO, it's better to "fix" the scripts (very easy) than revert to the previous shitty format
You're not alone on this planet :D

Reverting to old format and provide parallel new format is easier for everyone.
Anyone wanting to use the new format, has to do something anyhow.
Who wants to keep using the old format ... not so much.
In your suggestion, EVERYONE needs to do something.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 10:18 pm

In your suggestion, EVERYONE needs to do something.

And these "Everyone" should still install 7.10(beta 5), so something they should do anyway... :lol: :lol: :lol:

The same is also true in reverse: not everyone installs custom scripts, and of those who install custom scripts, only a small part involves dates....

Professional users (unless forced due to lack of downgrade) continue to use v6 as much as possible.
Updating a script takes a moment, and until you install v7.10+ you're not stuck.

Very easy to make a self-adapting script...

Non-professional users rarely have scripts installed separately.
How many do you want there to be?
And of these scripts, apart from @ElDoncito, very few are about dates…
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 10:44 pm

Last edited by rextended on Thu May 11, 2023 1:39 am, edited 1 time in total.
 
User avatar
Larsa
Forum Veteran
Forum Veteran
Posts: 982
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed May 10, 2023 11:29 pm

NO, it's better to "fix" the scripts (very easy) than revert to the previous shitty format

Breaking script compatibility in the middle of a major revision is not a trivial task and should be taken very seriously.

It may not be a significant concern for a garage-based company full of hacker heros, but for a serious corporation with a large installation base, it might have a profound impact. IMO, the current implementation is ill-conceived, particularly considering that there are much smoother ways to resolve it while still preserving strict compatibility.

Bottom line; Mikrotik must really make every effort to prevent compatibility issues in future releases. Otherwise, Mikrotik runs the risk of introducing yet another showstopper that makes it even harder upgrading to v7.

Mikrotik, this is a matter of utmost importance!
 
User avatar
BrianHiggins
Forum Veteran
Forum Veteran
Posts: 702
Joined: Mon Jan 16, 2006 6:07 am
Location: Norwalk, CT
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Thu May 11, 2023 12:14 am

NO, it's better to "fix" the scripts (very easy) than revert to the previous shitty format

Breaking script compatibility in the middle of a major revision is not a trivial task and should be taken very seriously.

It may not be a significant concern for a garage-based company full of hacker heros, but for a serious corporation with a large installation base, it might have a profound impact. IMO, the current implementation is ill-conceived, particularly considering that there are much smoother ways to resolve it while still preserving strict compatibility.

Bottom line; Mikrotik must really make every effort to prevent compatibility issues in future releases. Otherwise, Mikrotik runs the risk of introducing yet another showstopper that makes it even harder upgrading to v7.

Mikrotik, this is a matter of utmost importance!
Agreed, breaking functionality is a huge no-no. It is always acceptable to add something new, but changing existing functionality that can break established processes is a horrible idea. I fully support standardizing the timestamps, but they should only be changed when /system clock set format= is set to a new value (and it can be defaulted to a ISO standard for new devices too), but it should also have /system clock set format=legacy which keeps every single date and time format the way they were pre v7.10 and any upgrade should always retain the setting of legacy, only new devices or reset devices should default to a new format.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Thu May 11, 2023 12:28 am

@BrianHiggins you are right,
a worse change than this [:execute], with a bigger impact, had been stopped by complaints in a past beta version of RouterOS,
and had been agreed to insert a parameter, much as I suggested.


@Larsa
It may not be a significant concern for a garage-based company full of hacker heros
what are you referring to?
it's not clear whether you're making any allusions or not, so
but for a serious corporation with a large installation base, it might have a profound impact
It's incredible that a "garage-based company full of hacker heros" is able to control everything that is written inside every single device, every single CPE
and "a serious corporation with a large installation base" not...
Hmm....
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Thu May 11, 2023 4:46 pm

Just updated some scripts with the autodetect:
Also adopted the change for my scripts already... This now works with old and new format. I am fine to keep it that way. 👍😁

BTW, another place to adopt:
[admin@MikroTik] > :put [ /system/resource/get build-time ]
May/09/2023 10:38:53
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Thu May 11, 2023 5:02 pm

(unfixed places are listed on top pages)

using the same style, as I would:

original code

  :if ([ :pick $Date 4 5 ] != "-") do={
    :local Months { "jan"=1; "feb"=2; "mar"=3; "apr"=4; "may"=5; "jun"=6;
                    "jul"=7; "aug"=8; "sep"=9; "oct"=10; "nov"=11; "dec"=12 };

    :return ({ "year"=[ :tonum [ :pick $Date 7 11 ] ];
              "month"=($Months->[ :pick $Date 0 3 ]);
                "day"=[ :tonum [ :pick $Date 4 6 ] ] });
  }

rextended code

# or on alternative, :if ([:len $date] = 11) do={
  :if ($Date ~ ".../../..") do={
    :local Months { "an"=1; "eb"=2; "ar"=3; "pr"=4; "ay"=5; un"=6; "ul"=7; "ug"=8; "ep"=9; "ct"=10; "ov"=11; "ec"=12 };

    :return ({ "year"=[ :tonum  [ :pick $Date 7 11 ] ];
              "month"=($Months->[ :pick $Date 1  3 ]);
                "day"=[ :tonum  [ :pick $Date 4  6 ] ] });
  }
 
pe1chl
Forum Guru
Forum Guru
Posts: 10146
Joined: Mon Jun 08, 2015 12:09 pm

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Thu May 11, 2023 5:35 pm

BTW, another place to adopt:
[admin@MikroTik] > :put [ /system/resource/get build-time ]
May/09/2023 10:38:53
That is probably just as string as distributed in the package, not the result of a function that is running on the device itself...
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3040
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Thu May 11, 2023 7:14 pm

a worse change than this [:execute], with a bigger impact, had been stopped by complaints in a past beta version of RouterOS,
and had been agreed to insert a parameter, much as I suggested.
Well... the synchronous :execute uses "as-string" parameter...same logic could apply to date outputs (e.g. an "as-time" to get the unixsec-since-epoch/"time type" from the date things)
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Thu May 11, 2023 10:30 pm

BTW, another place to adopt:
[admin@MikroTik] > :put [ /system/resource/get build-time ]
May/09/2023 10:38:53
That is probably just as string as distributed in the package, not the result of a function that is running on the device itself...
Sure. But I think it should change nevertheless.
I guess the date reported in network neighborhood (/ip/neighbor/) is the same?
 
pe1chl
Forum Guru
Forum Guru
Posts: 10146
Joined: Mon Jun 08, 2015 12:09 pm

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Thu May 11, 2023 10:46 pm

Yes, it is just the name of the version, which happens to include a date/time (only for v7, in v6 this wasn't done).
Of course it can be changed when they change their build scripts. Still, that will show the new format date only for new versions, not for neighbors that run older versions.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Thu May 11, 2023 10:51 pm

I think it's trifles that don't count.
I don't think anyone has made scripts that read that date to do anything with it...
 
pe1chl
Forum Guru
Forum Guru
Posts: 10146
Joined: Mon Jun 08, 2015 12:09 pm

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Thu May 11, 2023 10:52 pm

Back in 2018 it "was considered" to add a function library for scripting, and input was requested for what functions would be useful to have: viewtopic.php?p=951855
One of the first proposed category was manipulation of date/time values.

Unfortunately we never got that function library. If it had been implemented, the autodetection and handling of the new date format could just be added there, and all user scripts would automatically adapt to the new situation....
(or their programmer would be kicked for not using standard functions from the library)
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Thu May 11, 2023 10:55 pm

Come on, it took me a moment to modify all my scripts on the forum and in production to be ready
for the 9 September for the long-term v7.23.5 where finally we can have the ISO time for Zero Trust on BFG (:P)...
viewtopic.php?t=189259#p957418
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 18697
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Fri May 12, 2023 4:14 am

Come on, it took me a moment to modify all my scripts on the forum and in production to be ready
I have a cat biscuit for you! :-) (showoff)
 
pe1chl
Forum Guru
Forum Guru
Posts: 10146
Joined: Mon Jun 08, 2015 12:09 pm

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Fri May 12, 2023 10:54 am

Come on, it took me a moment to modify all my scripts on the forum and in production to be ready
I think the issue is not how much work it is for a capable programmer to modify the code, but more the vast number of copy/paste programmers that have tinkered a script that works and suddenly it breaks when upgrading. It may even take quite some time before that is noticed at all, e.g. when the script has some monitoring/alerting purpose.
In case some company has deployed hundreds of routers with some script, and did not think about an automated way for maintenance, it may be a big headache to fix.

But in general I agree that the number of scripts that parses a date field (rather than simply reading it and using it in some message) is probably quite small.
I have done some scripting but I never parsed the field, only copied it to a variable for later compare.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Fri May 12, 2023 11:47 am

[…] but more the vast number of copy/paste programmers that have tinkered a script that works and suddenly it breaks when upgrading. […]
You always manage to give me that point of view that I miss,
Thank you.
 
User avatar
BrianHiggins
Forum Veteran
Forum Veteran
Posts: 702
Joined: Mon Jan 16, 2006 6:07 am
Location: Norwalk, CT
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Mon May 15, 2023 6:54 pm

[…] but more the vast number of copy/paste programmers that have tinkered a script that works and suddenly it breaks when upgrading. […]
You always manage to give me that point of view that I miss,
Thank you.
it's also easy to update one or two devices, when you've got scripts baked into default setup scripts installed on thousands of devices spread all over the country, it's a little more challenging to update. Thankfully this particular change does not affect any of our deployed scripts, only how we parse some data server side that gets retrieved from the API, so it's an easy fix for us, but just because it's an easy fix for us doesn't mean MikroTik should get a free pass and break functionality for anyone who does have deployed scripts that might be affected by this. They absolutely should handle this change such that it does not become a new default setting when upgrading existing devices, and retain the old format as an option.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Mon May 15, 2023 7:17 pm

I hope the update process is not automatic (and neither is installing beta in production).
It is extremely easy, when you update the software, also update the scripts onboard of the machine...
And then, if years ago you had foreseen the self-updating of the onboard scripts... there's nothing to worry about...
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Mon May 22, 2023 4:28 pm

 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Mon May 22, 2023 5:40 pm

Looks like the situation is unchanged in 7.10beta7... Or I did not find the switch.
 
User avatar
Larsa
Forum Veteran
Forum Veteran
Posts: 982
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Mon May 22, 2023 5:44 pm

They absolutely should handle this change such that it does not become a new default setting when upgrading existing devices, and retain the old format as an option.

Concur and as I wrote in another post:

I want to emphasize that we welcome the new date format. HOWEVER, implementing it in a way that breaks compatibility, and in addition absolutely unnecessarily, is just plain stupidity.

And of course, you can "fix" the problem with various modifications, but the level of effort required varies depending on its occurrence. These type of changes is bound to have serious ramifications but the magnitude remains to be seen. People who don't understand the implications of this issue shouldn't comment on the matter IMO.
 
User avatar
own3r1138
Long time Member
Long time Member
Posts: 678
Joined: Sun Feb 14, 2021 12:33 am
Location: Pleiades
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Fri Jun 16, 2023 8:48 pm

@rextended

Would you revive this for me, please? It doesn't work correctly anymore.
:local 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 today [/system clock get date]
:local dateinside "$[:pick $today 7 11]-$($arrMonths->[:pick $today 1 3])-$[:pick $today 4 6]"
:local backupfile "$[/system identity get name]_$dateinside_$[/system clock get time]_$[/system resource get uptime].backup"
2023-06-16_21-14-57.jpg
You do not have the required permissions to view the files attached to this post.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Fri Jun 16, 2023 10:32 pm

@rextended

Would you revive this for me, please? It doesn't work correctly anymore.

This work regardless the RouterOS date format

J.F.Y. code

:local isodateonly do={
    /system clock
    :local vdate [get date]
    :local vdoff [:toarray "0,4,5,7,8,10"]
    :local MM    [:pick $vdate ($vdoff->2) ($vdoff->3)]
    :local M     [:tonum $MM]
    :if ($vdate ~ ".../../....") do={
        :set vdoff [:toarray "7,11,1,3,4,6"]
        :set M     ([:find "xxanebarprayunulugepctovecANEBARPRAYUNULUGEPCTOVEC" [:pick $vdate ($vdoff->2) ($vdoff->3)] -1] / 2)
        :if ($M>12) do={:set M ($M - 12)}
        :set MM    [:pick (100 + $M) 1 3]
    }
    :local yyyy [:pick $vdate ($vdoff->0) ($vdoff->1)]
    :local dd   [:pick $vdate ($vdoff->4) ($vdoff->5)]
    :return "$yyyy-$MM-$dd"
}

:local backupfile "$[/system identity get name]_$[$isodateonly]_$[/system clock get time]_$[/system resource get uptime].backup"
>>> ***********_2023-06-16_21:34:39_1w6d12:05:54.backup
 
User avatar
own3r1138
Long time Member
Long time Member
Posts: 678
Joined: Sun Feb 14, 2021 12:33 am
Location: Pleiades
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Fri Jun 16, 2023 10:48 pm

This work regardless the RouterOS date format
Thank you very much.
 
AUsquirrel
newbie
Posts: 38
Joined: Fri Feb 21, 2014 10:28 pm

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Sat Jun 17, 2023 3:16 am

@rextended

Would you revive this for me, please? It doesn't work correctly anymore.
:local 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 today [/system clock get date]
:local dateinside "$[:pick $today 7 11]-$($arrMonths->[:pick $today 1 3])-$[:pick $today 4 6]"
:local backupfile "$[/system identity get name]_$dateinside_$[/system clock get time]_$[/system resource get uptime].backup"
2023-06-16_21-14-57.jpg
I have a similar problem. You load the returned date into a var then it appears I could only pick from position 0. After a bit of testing the pick function seems to have changed from the documentation. The syntax now appears to be :pick <var> <start> [<finish>]. To get my scripts to work I have changed the values in the pick function.

:global fetchdate [/system clock get date]
[root@main-router] > :put $fetchdate
2023-06-17
[root@main-router] > :put [:pick [/system clock get date] 0 4]
2023
[root@main-router] > :put [:pick [/system clock get date] 5 7]
06
[root@main-router] > :put [:pick [/system clock get date] 8 10]
17
 
User avatar
own3r1138
Long time Member
Long time Member
Posts: 678
Joined: Sun Feb 14, 2021 12:33 am
Location: Pleiades
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Sat Jun 17, 2023 2:04 pm

@AUsquirrel, Thank you.
 
MLR
just joined
Posts: 7
Joined: Tue Oct 17, 2023 10:11 am

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Sat Oct 28, 2023 6:14 pm

i was able to get yesterday date using following script.but recent updates killed it. Can anyone fix this for me

func_date
################################################################### func_shiftDate - add days to date
#  Input: date, days
#    date - "jan/1/2017"
#    days - number, +/-
################################################################### uncomment for testing
#:local date "jan/01/2100"
#:local days 2560
########################################
#:put "$date + $days"
#use external functions
:local mdays  {31;28;31;30;31;30;31;31;30;31;30;31}
:local months {"jan"=1;"feb"=2;"mar"=3;"apr"=4;"may"=5;"jun"=6;"jul"=7;"aug"=8;"sep"=9;"oct"=10;"nov"=11;"dec"=12}
:local monthr  {"jan";"feb";"mar";"apr";"may";"jun";"jul";"aug";"sep";"oct";"nov";"dec"}

:local dd  [:tonum [:pick $date 4 6]]
:local yy [:tonum [:pick $date 7 11]]
:local month [:pick $date 0 3]

:local mm ($months->$month)
:set dd ($dd+$days)
#:put $dd

:local dm [:pick $mdays ($mm-1)]
:if ($mm=2 && (($yy&3=0 && $yy/100*100 != $yy) || $yy/400*400=$yy) ) do={ :set dm 29 }

:while ($dd>$dm) do={
  :set dd ($dd-$dm)
  :set mm ($mm+1)
  :if ($mm>12) do={
    :set mm 1
    :set yy ($yy+1)
  }
 :set dm [:pick $mdays ($mm-1)]
 :if ($mm=2 &&  (($yy&3=0 && $yy/100*100 != $yy) || $yy/400*400=$yy) ) do={ :set dm 29 }
};

:while ($dd<=0) do={
 :set mm ($mm-1)
  :if ($mm=0) do={
    :set mm 12
    :set yy ($yy-1)
  }
 :set dm [:pick $mdays ($mm-1)]
 :if ($mm=2 &&  (($yy&3=0 && $yy/100*100 != $yy) || $yy/400*400=$yy) ) do={ :set dm 29 }
 :set dd ($dd+$dm)
};

:local res "$[:pick $monthr ($mm-1)]/"
:if ($dd<10) do={ :set res ($res."0") }
:set $res "$res$dd/$yy"
:return $res

#############################################################################
# Get Yesterday
#######################################################################





:local shiftDate [:parse [/system script get func_date source]]
:local DT ([/system clock get date])
:local LASTDAY [$shiftDate date=$DT days=-1]
:put "TODAY Date = $DT"
:put "YESTERDAY date = $LASTDAY"


###################### Month /  Year #################



:local arrMonths {jan="January";feb="February";mar="March";apr="April";may="May";jun="June";jul="July";aug="August";sep="September";oct="October";nov="November";dec="December"}
:local strYear [:pick $LASTDAY 7 11]
:local strMonth ($arrMonths->[ :pick $LASTDAY 0 3 ])
:local strDay [:pick $LASTDAY 4 6]


source - https://aacable.wordpress.com/tag/mikrotik-datetime/
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Sun Oct 29, 2023 3:24 am

as @pe1chl wrote...
[…] but more the vast number of copy/paste programmers that have tinkered a script that works and suddenly it breaks when upgrading. […]
You always manage to give me that point of view that I miss,
Thank you.
 
MLR
just joined
Posts: 7
Joined: Tue Oct 17, 2023 10:11 am

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Sun Oct 29, 2023 6:04 am

if you don't mind, can you review above code & fix it for me. please @rextended
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Sun Oct 29, 2023 9:57 am

if you don't mind, can you review above code & fix it for me. please @rextended
viewtopic.php?t=127050#p1032727
 
MLR
just joined
Posts: 7
Joined: Tue Oct 17, 2023 10:11 am

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Sun Oct 29, 2023 3:35 pm

if you don't mind, can you review above code & fix it for me. please @rextended
viewtopic.php?t=127050#p1032727
Thanks i removed all previous code & moved to your one. works very well. Thank you again
 
FlowerShopGuy
just joined
Posts: 6
Joined: Thu Sep 14, 2023 10:21 am

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Sat Dec 02, 2023 12:08 am

Hey, maybe some can help to the noob with it? I need run script at specifield day of the month.

For old ROS versions just worked something like this:
:local date [/system clock get date]
:local day [:pick $date 4 6]

:if ($day = "02") do={
MY SCRIPT
}
Can someone fix this to RO OS 7.12?
 
brg3466
Member Candidate
Member Candidate
Posts: 177
Joined: Sat Aug 01, 2015 7:29 am

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Sat Dec 02, 2023 3:55 am

Instead of :pick $date 4 6, the new date format you do :pick $date 8 10
 
FlowerShopGuy
just joined
Posts: 6
Joined: Thu Sep 14, 2023 10:21 am

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Sat Dec 02, 2023 11:17 am

Instead of :pick $date 4 6, the new date format you do :pick $date 8 10
Thank you so much! It works now.
 
User avatar
rextended
Forum Guru
Forum Guru
Topic Author
Posts: 11937
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ⚠️WARNING: RouterOS v7.10+ will break all scripts based on [/system clock get date] or other date(s)

Wed Jan 24, 2024 4:32 pm

Instead of :pick $date 4 6, the new date format you do :pick $date 8 10
Thank you so much! It works now.
Instead of blindly copying and pasting, try to understand what that command is for and why it was used that way.

Who is online

Users browsing this forum: AshuGite, Google [Bot], llag, lvpersa and 50 guests