Community discussions

User avatar
Member Candidate
Member Candidate
Topic Author
Posts: 171
Joined: Mon Feb 04, 2013 7:00 pm

Dates manipulation module

Wed Nov 01, 2017 10:10 am

Hi All,
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:
/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"
You do not have the required permissions to view the files attached to this post.
just joined
Posts: 7
Joined: Sun Apr 21, 2013 3:40 am
Location: Canada

Re: Dates manipulation module

Tue Feb 27, 2018 7:45 am

"The selected attachment does not exist anymore."
just joined
Posts: 1
Joined: Fri Aug 10, 2018 11:07 am

Re: Dates manipulation module

Fri Aug 10, 2018 11:24 am

can you upload the script again,
"file doesnt exist anymore"
User avatar
just joined
Posts: 7
Joined: Sun Jan 17, 2016 11:46 pm
Location: syria-idleb

Re: Dates manipulation module

Thu Sep 27, 2018 8:54 pm

that file
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: No registered users and 6 guests