[EMAIL PROTECTED] wrote: > Is it correct that > {(ftime "%Y" "-")} > should produce > 2007 > > I'm actually looking for a way to extract the year from a page text > variable that could look like this: > > :Deceased: 2003-12-01 Stockholm > > where the person died in 2003. Or like this > > :Deceased: - > > where the person is still alive, or possibly like this > > :Deceased: ? > > where it's unknown when the person died. > > Ideas? > ftime uses defaults whenever it doesn't recognize a parameter. For unrecognized dates it always uses the current time. One way to get the effect you want is to nest ftime within another markup expression. A quick look through the possibilities doesn't show any existing ones that quite do the job, so you may have to roll your own. What you want is something like this (note that I'm using the MarkupExprPlus recipe):
{(if (test isdate {$:Deceased}) (ftime "%Y" {$:Deceased}) {$:Deceased}))} This would require you to define a new conditional called 'isdate' which would look something like this (note that I haven't tested it): $Conditions['isdate'] = 'preg_match("/\d\d\d\d-\d\d-\d\d/",$condparm)'; This assumes, of course, that all valid dates are strict ISO. If you have other date formats, then isdate gets a lot more complex. _______________________________________________ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users