Community discussions

MikroTik App
 
Tal
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Wed Jun 17, 2015 2:17 am

Why does time value in /log return different formats?

Mon Jan 25, 2016 4:15 pm

Is there a reason running this:
/foreach i in=[/log find] do={ /global TIME; :set TIME [/log get "$i" time]; /put "$i: $TIME"}
on RouterOS 6.27, I get:
*0: jan/01/2002 01:00:02
*1: jan/01/2002 01:00:05
*2: jan/01/2002 01:00:07
*3: jan/01/2002 01:00:25
...
*7E: dec/31/2001 18:00:52
*7F: dec/31/2001 18:00:57
*80: dec/31/2001 18:01:02
*81: dec/31/2001 18:01:07
*82: 06:29:13
*83: 06:29:14
*84: 06:29:40
*85: 06:29:42
*86: 06:29:54
*87: 06:30:21
...
*D7: 06:49:07
*D8: 06:49:59
*D9: 06:50:06
*DA: 06:50:07
The format starts out being "Date Time" but gives up after a while and switches to just "Time".
Did it get tired and decide to use shorthand?

=====

Update: I just noticed that this happens right after the router fixes its clock from dec/31/2001 to the current date using NTP.
Last edited by Tal on Mon Jan 25, 2016 4:30 pm, edited 1 time in total.
 
User avatar
PaulsMT
MikroTik Support
MikroTik Support
Posts: 282
Joined: Tue Feb 10, 2015 3:21 pm

Re: Why does time value in /log return different formats?

Mon Jan 25, 2016 4:27 pm

There will be no Date if log is created in current day.
 
Tal
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Wed Jun 17, 2015 2:17 am

Re: Why does time value in /log return different formats?

Mon Jan 25, 2016 4:33 pm

Not a great system, as it breaks scripts that do not account for this, as it did for me, but I guess that makes sense.
As long as I know about this feature, I can work around it.
Thanks
 
Tal
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Wed Jun 17, 2015 2:17 am

Re: Why does time value in /log return different formats?

Mon Jan 25, 2016 5:39 pm

I just changed the my MikroTik's date to Jan 26th (one day ahead), and ran the same foreach loop again. I get:
> /system clock print     
                  time: 23:13:20
                  date: jan/26/2016
                  ...
                  
> /foreach i in=[/log find] do={ /global TIME; :set TIME [/log get "$i" time]; /put "$i: $TIME"}
 ...
*113: jan/26 00:00:49
*114: jan/26 00:00:50
*115: jan/26 00:01:15
*116: jan/26 23:01:45
...
If the device thinks today is Jan 26th, it should not display the dates, but it does.
It looks more and more like a bug.
 
Tal
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Wed Jun 17, 2015 2:17 am

Re: Why does time value in /log return different formats?

Mon Jan 25, 2016 9:03 pm

Further testing appears to show that if the current time is 16:59:59 or earlier in the day, all of today's logs only show the times - not the dates.
If the current time is 17:00:00 or later, all of today's logs show the date and the time.
Is this somehow expected behavior? Does anyone else see this behavior? I've only tested this on one device so far - a 493AH running RouterOS 6.27.
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: Why does time value in /log return different formats?

Mon Jan 25, 2016 9:30 pm

Further testing appears to show that if the current time is 16:59:59 or earlier in the day, all of today's logs only show the times - not the dates.
If the current time is 17:00:00 or later, all of today's logs show the date and the time.
Is this somehow expected behavior? Does anyone else see this behavior? I've only tested this on one device so far - a 493AH running RouterOS 6.27.
This sounds like UTC might be involved somewhere behind the curtain. What's your time zone's GMT offset?
 
Tal
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Wed Jun 17, 2015 2:17 am

Re: Why does time value in /log return different formats?

Mon Jan 25, 2016 10:56 pm

MST (-7).
17:00:00 + 7h = 24:00:00 (or 00:00:00)
Good catch.
Is this somehow expected behavior?
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: Why does time value in /log return different formats?

Mon Jan 25, 2016 11:06 pm

MST (-7).
17:00:00 + 7h = 24:00:00 (or 00:00:00)
Good catch.
Is this somehow expected behavior?
I wouldn't expect this behavior. It's probably a bug. It stood out to me because I'm a pilot and used to dealing with UTC a lot, and "tomorrow" starts at about 6pm (my time) as far as lots of reports and weather forecasts and such go. This sounded like that.

Also - a lot of software libraries convert times to UTC internally in order to make things easier (time is so tricky in programming) and if a "is it today" decision gets made somewhere in the middle of changing times around, it's possible that the question is asked relative to localtime and the value checked happens to be UTC..... well, that's what I bet is happening, anyway.
 
Tal
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Wed Jun 17, 2015 2:17 am

Re: Why does time value in /log return different formats?

Tue Jan 26, 2016 1:43 am

You're probably right. Thanks for the help.
It's always interesting to see how two seemingly unrelated things (your cool job, and programming) are related more than we would think.
Now I just gotta figure out how to work around this.