1. you could set fields with that form input into your page like:
:start: DATEVALUE-ENTERED-BY-FORMand 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
$[unknown date format] ![-[[Cookbook/ParseDate#formats|=>$[help]]]-]%%//",0,0); if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.((19|20){1}\d{1,2})\s*(\d{1,2}):(\d{2})\s*(bis|-)\s*(\d{1,2})\.(\d{1,2})\.((19|20{1})\d{2})\s*(\d{1,2}):(\d{2})/i',$datestring,$m)) { $D = '[d]d.[m]m.yyyy [h]h:mm -/bis dd.mm.yyyy [h]h:mm'; $from = mktime($m[4],$m[5],0,$m[2],$m[1],$m[3]); $to = mktime($m[10],$m[11],0,$m[8],$m[7],$m[9]);; #DEBUG($datestring,1); DEBUG($m,1); DEBUG($D,1); } else if (preg_match('/^\s*(\d\d?)\.(\d\d?)\.((19|20){1}\d{2})\s*(bis|-)\s*(\d\d?)\.(\d\d?)\.((19|20){1}\d{2})/i',$datestring,$m)) { $D = '[d]d.[m]m.yyyy -/bis [d]d.[m]m.yyyy'; $from = mktime(0,0,0,$m[2],$m[1],$m[3]); $to = mktime(0,0,0,$m[7],$m[6],$m[8]); # DEBUG($datestring,1); DEBUG($m,1); DEBUG($D,1); } else if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.(\d{2})\s*(bis|-)\s*(\d{1,2})\.(\d{1,2})\.(\d{2})/i',$datestring,$m)) { $D = '[d]d.[m]m.yy -/bis [d]d.[m]m.yy'; $from = mktime(0,0,0,$m[2],$m[1],$m[3]); $to = mktime(0,0,0,$m[6],$m[5],$m[7]); #DEBUG($datestring,1); DEBUG($m,1); DEBUG($D,1); } else if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.\s*(bis|-)\s*(\d{1,2})\.(\d{1,2})\.((19|20)\d{2})/i',$datestring,$m)) { $D = '[d]d.[m]m. -/bis [d]d.[m]m.yyyy'; $from = mktime(0,0,0,$m[2],$m[1],$m[6]); $to = mktime(0,0,0,$m[5],$m[4],$m[6]); #DEBUG($datestring,1); DEBUG($m,1); DEBUG($D,1); } else if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.\s*(bis|-)\s*(\d{1,2})\.(\d{1,2})\.(\d{2})/i',$datestring,$m)) { $D = '[d]d.[m]m. -/bis [d]d.[m]m.yy'; $from = mktime(0,0,0,$m[2],$m[1],$m[6]); $to = mktime(0,0,0,$m[5],$m[4],$m[6]); #DEBUG($datestring,1); DEBUG($m,1); DEBUG($D,1); } else if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.\s*(bis|-)\s*(\d{1,2})\.(\d{1,2})\./i',$datestring,$m)) { $D = '[d]d.[m]m. -/bis [d]d.[m]m.'; $from = mktime(0,0,0,$m[2],$m[1],date('Y')); $to = mktime(0,0,0,$m[5],$m[4],date('Y')); #DEBUG($datestring,1); DEBUG($m,1); DEBUG($D,1); } else if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.((19|20){1}\d{2})\s*(\d{1,2}):(\d{2})/',$datestring,$m)) { $D = '[d]d.[m]m.yyyy [h]h:mm'; $from = mktime($m[5],$m[6],0,$m[2],$m[1],$m[3]); $to = 0; #DEBUG($datestring,1); DEBUG($m,1); DEBUG($D,1); } else if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.((19|20){1}\d{2})\s*(\d{1,2}):(\d{1})/',$datestring,$m)) { return $err; } else if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.((19|20)\d{1,2})/',$datestring,$m)) { $D = '[d]d.[m]m.yyyy'; $from = mktime(0,0,0,$m[2],$m[1],$m[3]); $to = 0; # DEBUG($datestring,1); DEBUG($m,1); DEBUG($D,1); } else if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.(\d{2})/',$datestring,$m)) { $D = '[d]d.[m]m.yy'; $from = mktime(0,0,0,$m[2],$m[1],2000+$m[3]); $to = 0; # DEBUG($datestring,1); DEBUG($m,1); DEBUG($D,1); } else if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.\s*(\d{1,2}):(\d{2})/',$datestring,$m)) { $D = '[d]d.[m]m. [h]:mm'; $from = mktime($m[3],$m[4],0,$m[2],$m[1],date('Y')); $to = 0; #DEBUG($datestring,1); DEBUG($m,1); DEBUG($D,1); } else if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\.\s*(\d{1,2}):(\d{1})/',$datestring,$m)) { return $err; } else if (preg_match('/^\s*(\d{1,2})\.(\d{1,2})\./',$datestring,$m)) { $D = '[d]d.[m]m.'; $from = mktime(0,0,0,$m[2],$m[1],date('Y')); $to = 0; # DEBUG($datestring,1); DEBUG($m,1); DEBUG($D,1); } /* else if ($from = strtotime($datestring)) { $D = 'strtotime'; $to = 0; }*/ else { return $err; } if ($GLOBALS['TestParseDate']) { $datetimestring = "%blue%FMT$D: %%"; } else { $datetimestring = ''; } #DEBUG($m,1); #DEBUG(mktime(2,1,2003),1); #DEBUG($from,1); if (date('His',$from) === "000000") { $fmt = $fmtdate; } else { $fmt = $fmtdate.' '.$fmttime; } $datetimestring .= strftime($fmt,$from); if ($to !== 0) { if (date('His',$from) === "000000") { $fmt = $fmtdate; } else { $fmt = $fmtdate.' '.$fmttime; } $datetimestring .= $sep.strftime($fmt,$to); } # TODO: if german, other translations ... if ($to > 0 and $from > $to) { $datetimestring .= "
%red%$[start]>$[end] !%%"; } return array($datetimestring,$from,$to,$kw); } ?>
_______________________________________________ pmwiki-users mailing list [email protected] http://www.pmichaud.com/mailman/listinfo/pmwiki-users
