[pmwiki-users] Adding/subtracting days to ftime Page Text Variable
Stef
stefct4 at gmail.com
Thu Sep 4 04:10:04 CDT 2014
> On 4 September 2014 17:14, kirpi at kirpi.it <kirpi at kirpi.it> wrote:
>
>> > http://www.pmwiki.org/wiki/PmWiki/MarkupExpressions#ftime
>> > provides the information you need.
>> > In particular see the information. and importantly the link, about the
>> > "when" parameter.
>>
>> Thank you Simon.
>> I am not sure I understand what you mean :-)
>> There is a link pointing to a strange name (strtotime) in a php
>> website. You mean I should use php instead of javascript, perhaps? Ok,
>> I will try...
To some of my CopyPasteCalendars I've added "Last Month/Next Month" buttons.
To that end, I've added the following lines of PHP to my config.php:
$MarkupExpr['nextmonth'] = 'nextmonth ($args[0])';
$MarkupExpr['lastmonth'] = 'lastmonth ($args[0])';
function nextmonth ($argdate)
{
$arg0 = substr ($argdate,0,4);
$arg1 = substr ($argdate,4,2);
$arg1 = $arg1 +1;
if ($arg1>12)
{
$arg0 = $arg0 + 1;
$arg1 = 1;
}
$arg1 = sprintf('%02d', $arg1);
return $arg0.$arg1;
}
function lastmonth ($argdate)
{
$arg0 = substr ($argdate,0,4);
$arg1 = substr ($argdate,4,2);
$arg1 = $arg1 -1;
if ($arg1<1)
{
$arg0 = $arg0 - 1;
$arg1 = 12;
}
$arg1 = sprintf('%02d', $arg1);
return $arg0.$arg1;
}
PmWiki Markup:
'''[+[[{*$FullName}?ListDate={(lastmonth
"{$$ListDate}")}?action=browse|«««]] {(ftime fmt="%B %Y" when=(substr
{$$ListDate} 0 6)01)} [[{*$FullName}?ListDate={(nextmonth
"{$$ListDate}")}?action=browse|»»»]]+]'''
instead of:
'''[+{(ftime fmt="%B %Y" when=(substr {$$ListDate} 0 6)01)}+]'''
Maybe you could modify this to suit your needs...
--StefCT
More information about the pmwiki-users
mailing list