I noticed the new :timestamp function in v7.1
Have requested MT for a full epoch time system.
I stumbled across :timestamp myself. Found this posting. Since there is no "date" type, guess "2711w6d17:53:35.252065073" is result if you only have time (and some hidden "time range" type like 00:00:00-1d in /ip/kid-control).
Imagine, Mikrotik ain't reinventing the wheel, or time
... So UNIX epoch does seem to be Jan 1, 1970. But @Jotne is right, clarity be good here – issue of "leap seconds" and "leap years" to consider. But seems there are using 86400 seconds per day, include leap days – but just a guess since the 22 minutes off from /system/clock is what I'm showing using @deadcat's function.
Assuming it really just converting /system/clock to a UNIX-based time int (and then display as humanized 1000w10d... string to display in CLI)... if so, what effect does changing TZ have,
or should have? e.g.
good to know if it's possible the [:timestamp] value could move backwards with the /system/clock/time-zone changes (or NTP/etc time changes) etc. since an "atomic time" is actually what you may want with something called ":timestamp" (although if atomic time counter is what you want, /system/resource/uptime does same non-adjusted/linear time.
But using @deadkat function, with /system/ssh to Mac with `date -r <seconds>`, it seems it ignores leap seconds from the 1970 epoch, but respect leap years. This makes since since it's original definition of time_t.
/system/ssh address=192.168.x.y user=usr command="date +%s"
# 1640195280
:put [$unixT2S]
# 1640192640
/system/ssh address=192.168.x.y user=usr command="date -r $([$unixT2S])"
# Wed Dec 22 09:02:46 PST 2021
:put [/system/clock/get date]
# dec/22/2021
:put [/system/clock/get time]
# 09:24:52
Note: the time is off by 22 minutes. If right, hard to now. Pretty sure the Mac doing the "data -r" via ssh IS applying leap seconds etc. per man page.
On top at least some reference to the command...what's seeming missing is :tonum doing what @deadkat function does:
:put [:tonum [:timestamp]]
or, :timestamp just returning a num (like Date.now() in JavaScript), then
get you the "week 1970 epoch" it does now: 2711w6d17:53:35.252065073
Obviously this isn't a critical issue... just the CLI/ROS script is more like a crossword puzzle of types oddities. Since I was curious, wrote up what I found.