in the result of discussion in viewtopic.php?f=9&t=127050 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:
Code: Select all
/system script run test_dates
To use these functions you need:
A) copy script to your router and import it:
Code: Select all
/import dates-v1.1.rsc
C) just call it.
For example to count Developer's Day:
Code: Select all
: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"