Dates manipulation module

Hi All,
in the result of discussion in http://forum.mikrotik.com/t/script-to-calculate-next-date/113437/1 module for dates manipulations was born (see attach).
Dates manipulations are done in format “jan/01/1970”

Module contains next functions:
func_datetime2str – generates string from date and time
func_cmp2dates – compare two dates
func_daysInMonth – get days in the month
func_daysInYear – get days in the year
func_shiftDate – add/sub days to given date
func_subDates – count days between two given days
func_date2days – count days from base (01/01/1970 by default) to given date
test_dates – script to test all dates manipulation functions. Can be used as example for importing functions to your code.
To test functions just run next code:

/system script run test_dates

At the end of output you should see “*** END ***”

To use these functions you need:
A) copy script to your router and import it:

/import dates-v1.1.rsc

B) import needed external function in your code.
C) just call it.
For example to count Developer’s Day:

:local shiftDate [:parse [/system script get func_shiftDate source]]
:local year 2016
:local date "jan/01/$year"
:local res [$shiftDate date=$date days=255]
:put "Developers day in $year is $res"

“The selected attachment does not exist anymore.”

can you upload the script again,
“file doesnt exist anymore”

that file
dates-v1.1.rsc (12.5 KB)

hi,

i have problem. script returned blank value

Works perfect for me, many thanks even in 2021! :smiley:

This
http://forum.mikrotik.com/t/time-parsing-in-7-1/154185/1
may simplify everything.