Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###################################################################
- #
- # Return MMM d, YYYY, H:M:s
- #
- # Apply code from this source: https://forum.mikrotik.com/viewtopic.php?f=9&t=127050&p=625209#p625209
- #
- # You should be save with name "func_LINEdateTime" in you router, or anyone else but edit in main script also
- #
- # * * * * * WARNING * * * * *
- # 2023/06/16 : IF ROS verion >= 7.10 Please use : https://pastebin.com/4tZigvuh
- #
- ####
- :local date
- :local time
- :set date [/system clock get date]
- :set time [/system clock get time]
- :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)
- :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 }
- };
- :local res "$[:pick $monthr ($mm-1)]"
- :if ($dd<10) do={ :set res ($res."0") }
- :set $res "$res $dd, $yy - $time"
- :return $res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement