Community discussions

MikroTik App
 
User avatar
BlackVS
Member Candidate
Member Candidate
Topic Author
Posts: 172
Joined: Mon Feb 04, 2013 7:00 pm
Contact:

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.
 
randomwalk
just joined
Posts: 10
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."
 
yoyoykun
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
mohmadtnnari
just joined
Posts: 9
Joined: Sun Jan 17, 2016 11:46 pm
Location: syria-idleb
Contact:

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.
 
jhoner
just joined
Posts: 2
Joined: Fri Oct 26, 2018 5:05 pm

Re: Dates manipulation module

Tue Oct 29, 2019 10:48 am

hi,

i have problem. script returned blank value
 
IntLDaniel
Frequent Visitor
Frequent Visitor
Posts: 56
Joined: Thu Apr 04, 2019 7:21 pm

Re: Dates manipulation module

Thu Dec 16, 2021 11:35 am

Works perfect for me, many thanks even in 2021! :D
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Dates manipulation module

Thu Dec 16, 2021 2:37 pm

This
viewtopic.php?t=181327
may simplify everything.

Who is online

Users browsing this forum: maxslug and 28 guests