[pmwiki-users] get page modification time in English, how?

Petko Yotov 5ko at free.fr
Tue Oct 30 12:31:32 CDT 2007


On Tuesday 30 October 2007, SteP wrote:
> I suspect there's a design issue using ftime and PmWiki time variables
> together. $LastModified is formatted according to $TimeFmt, but ftime
> doesn't take $TimeFmt into consideration when parsing its <when> parameter.
> So it's very possible to set $TimeFmt to a format that ftime can't parse at
> all. One way (kludge?) to work around this issue is to extend ftime to
> 'normalize' PmWiki time variables before they are expanded. So, for
> instance, {(ftime "{$LastModified}" fmt="whatever")}, would be roughly
> equivalent to these steps


Hi. Sorry I didn't quite follow the thread, but in case all you need is to 
format the "last modified" times, it is easier to just do it from  the 
numeric timestamp and not from the human-readable formatted string:

in config.php:
   $FmtPV['$LastModifiedStamp'] = '$page["time"]';

in a page:
   {(ftime "@{$LastModifiedStamp}" fmt="whatever")}
   {(ftime "@{$LastModifiedStamp} +5hours" fmt="whatever UTC")}

This should also work with the extended recipe (lc="en_US") if your locales 
are compiled.

Petko

> $save=$TimeFmt
> $TimeFmt="%Y%M%D %I:%M" // a 'normalized', locale-independent format
> expand {$LastModified}  => "yyyymmdd hh:mm"
> $TimeFmt=$save
> parse "yyyymmdd hh:mm" and format it according to "whatever"
>
> sti at pooq.com wrote:
> > SteP wrote:
> >> I think your recipe is what I was looking for, but I'm getting
> >> strange results. I'm using it in a pagelist template, switching
> >> language from English to another language. Everything works as
> >> expected, when English is the language, but when the other language
> >> is used when="{=LastModified}" returns the current datetime for
> >> almost all pages. The only page for which the correct modification
> >> time is returned is an older page, as if PmWiki's lastmodified
> >> internal storage format had changed at some point in an incompatible
> >> way.  Here' the template, if you kindly could give it a shot
> >
> > I'm afraid I don't see anything wrong in that template that could
> > explain that strange behavior. It looks like sometimes the date being
> > passed in is somehow blank, and the code is using the the current date
> > instead. But for that to happen, then {=$LastModified} would have to
> > be returning nothing at all, and I can't think what would cause that.




More information about the pmwiki-users mailing list