I've figured it out, I had to learn to use Tasker a bit, the solution is a little awkward but it probably should be done this way in Tasker.
The most important variable for such datetime manipulations in Tasker is a global variable %TIMES
which contains current time in seconds - so it is a big long integer number.
Adding e.g. 30 days to it means you need to Set variable (with Math on) like this:
%TIMES + (30 * 86400)
Tommorow is:
%TIMES + (1 * 86400)
The main problem is, that you have to convert the value to a formatted datetime string. As I understood it there is no built in command for that in Tasker.
You need to create JavaScriptlet task step for that and paste there the code from this page:
<TaskerData sr="" dvi="1" tv="4.1b1m">
<Task sr="task54">
<cdate>1340586441681</cdate>
<edate>1369445351826</edate>
<id>54</id>
<nme>getFormattedDate</nme>
<pri>10</pri>
<rty>2</rty>
<Action sr="act0" ve="3">
<code>129</code>
<Str sr="arg0" ve="3">var gsMonthNames = new Array(
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
);
var gsDayNames = new Array(
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
);
var d = new Date(par[0] * 1000);
var f = par[1];
var formatteddate = f.replace(/(yyyy|yy|mmmm|mmm|mm|dddd|ddd|dd|hh|nn|ss|a\/p)/gi,
function($1)
{
switch ($1)
{
case 'yyyy': return d.getFullYear();
case 'yy':
return ('0' + d.getFullYear()).slice(-2);
case 'mmmm': return gsMonthNames[d.getMonth()];
case 'mmm': return gsMonthNames[d.getMonth()].slice(0,3);
case 'mm':
return ('0' + (d.getMonth() + 1)).slice(-2);
case 'dddd': return gsDayNames[d.getDay()];
case 'ddd': return gsDayNames[d.getDay()].slice(0,3);
case 'dd':
return ('0' + d.getDate()).slice(-2);
case 'hh':
return ('0' + ((h = d.getHours() % 12) ? h : 12)).slice(-2);
case 'HH':
return ('0' + d.getHours()).slice(-2);
case 'nn':
return ('0' + d.getMinutes()).slice(-2);
case 'ss':
return ('0' + d.getSeconds()).slice(-2);
case 'a/p': return d.getHours() < 12 ? 'a' : 'p';
}
}
);
</Str>
<Str sr="arg1" ve="3">45</Str>
<Int sr="arg2" val="1"/>
<Int sr="arg3" val="45"/>
</Action>
<Action sr="act1" ve="3">
<code>126</code>
<Str sr="arg0" ve="3">%formatteddate</Str>
<Int sr="arg1" val="1"/>
</Action>
</Task>
</TaskerData>
before that Javascriptlet step you insert 2 steps where you set two input variables %par1
(contains datetime in seconds form previous step) and %par2
(contains yyyymmdd
- date format).
The formatted date string is available then in %formatteddate
variable.
As for getting the next week:
- Run Shell
date -d +"%Y"
to %year
- Run Shell
date -d +"%V"
to %week
- Set variable
%week
to %week + 1
(Do Maths On)
- Set variable
%year
to %year + 1
(Do Maths On) (If %week > 52
)
- Set variable
%week
to 1
(If %week > 52
)
- The
yyyyww.htm
of the next week can then be written as %year%week.htm