[pmwiki-users] Manipulating dates with MarkupExpressions & ZAP

Knut Alboldt pmwiki at alboldt.de
Sat Jun 9 13:31:10 CDT 2007


I've got two aproaches to that kind of problem (used in a project plan 
managed by pmwiki), although I enter the date directly, not using ZAP:

1. you could set fields with that form input into your page like:

:start: DATEVALUE-ENTERED-BY-FORM

and reprocess this using rospatterns calling a date parsing routine 
(attached a drfat version of such a routine for german date formats). 
This way you could translate any entered date format (d.m. dd.mm. 
dd.mm.yyyy yyyy/mm/dd yy/d/d etc) into one valid date format you could 
use then by referencing the pagetextvar $:start. for parsing you could 
use a common routine (like e.g. already distrubuted within pmwiki, but 
dont know where you can find it and its name, have to search ...)

So the User would e.g enter:
d.m.
ZAP will enter this value into the line:
:start: d.m.
and saving the page will transform this via rospattern into:
:start:dd.mm.yyyy
rospattern could be:

  $ROSPatterns['/:start:(.*)'] = '(array)parsedate("$1")[1]'; (not quite 
sure, how to pass back only the first item of a returned array when 
calling a function, or you have to create a wrappper, which extracts the 
first item and apssed this to rospattern.

2. you can setup a markup to display any entered date-like format in one 
unique format. example:

markup will call function which uses the parsedate-routine

function UrlaubsplanWANN($pagename,$datetime)
{
   list($fromto,$from,$to) = ParseDate($datetime,'','','');
   $fromto = str_replace('bis','(:nl:)bis',$fromto);
   return PRR("(:cellnr class=taburlaubwann title='$datetime' :)".$fromto);
}


Knut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/pmwiki-users/attachments/20070609/faa371b9/attachment-0001.html 


More information about the pmwiki-users mailing list