Advertisement
phukao_itm

func_LINEdateTime (for ROS v7.0 to 7.9.2)

Apr 27th, 2023 (edited)
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. ###################################################################
  2. #
  3. # Return MMM d, YYYY, H:M:s
  4. #
  5. # Apply code from this source: https://forum.mikrotik.com/viewtopic.php?f=9&t=127050&p=625209#p625209
  6. #
  7. # You should be save with name "func_LINEdateTime" in you router, or anyone else but edit in main script also
  8. #
  9. # * * * * * WARNING * * * * *
  10. # 2023/06/16 : IF ROS verion >= 7.10 Please use : https://pastebin.com/4tZigvuh
  11. #
  12. ####
  13.  
  14. :local date
  15. :local time
  16. :set date [/system clock get date]
  17. :set time [/system clock get time]
  18.  
  19. :local mdays {31;28;31;30;31;30;31;31;30;31;30;31}
  20. :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}
  21. :local monthr {"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"}
  22.  
  23. :local dd [:tonum [:pick $date 4 6]]
  24. :local yy [:tonum [:pick $date 7 11]]
  25. :local month [:pick $date 0 3]
  26.  
  27. :local mm (:$months->$month)
  28.  
  29. :local dm [:pick $mdays ($mm-1)]
  30. :if ($mm=2 && (($yy&3=0 && ($yy/100*100 != $yy)) || $yy/400*400=$yy) ) do={ :set dm 29 }
  31.  
  32. :while ($dd>$dm) do={
  33. :set dd ($dd-$dm)
  34. :set mm ($mm+1)
  35. :if ($mm>12) do={
  36. :set mm 1
  37. :set yy ($yy+1)
  38. }
  39. :set dm [:pick $mdays ($mm-1)]
  40. :if ($mm=2 && (($yy&3=0 && ($yy/100*100 != $yy)) || $yy/400*400=$yy) ) do={ :set dm 29 }
  41. };
  42. :local res "$[:pick $monthr ($mm-1)]"
  43. :if ($dd<10) do={ :set res ($res."0") }
  44. :set $res "$res $dd, $yy - $time"
  45. :return $res
Tags: mikrotik
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement