[pmwiki-users] calendar date title converter

Dominique Faure dominique.faure.1 at free.fr
Thu Sep 8 17:39:24 CDT 2005


At Friday, September 09, 2005 12:00 AM [GMT+1=CET], Patrick R. Michaud 
wrote:

> On Thu, Sep 08, 2005 at 10:52:01PM +0100, Hans wrote:
>> cool! thanks!
>>
>> Unexpected results with  {$DName:%e %B %Y}
>>
>> see http://www.pmwiki.org/wiki/Test/20050908
>
> Unfortunately the "%e" generates a leading space -- this is built
> into the PHP strftime() and there's not much I can do about it.
> However, using something like
>
>    [==]{$DName:%e %B %Y}
>
> should fix the problem.
>
>> And on my machine the 8 does not appear at all, just September 2005
>> %d works.
>
> I wonder if your machine's implementation of strftime doesn't support %e.
> I know that not all strftimes are the same, and %e sounds like one of
> those "odd" conversions to me.
>

A possible fix:

    function DName($pagename, $fmt) {
      if (!preg_match('/\\.(\d\d\d\d)(\d\d)(\d\d)$/', $pagename, $match))
        return $pagename;
      if (!$fmt) $fmt = '%b %e %Y';
      $gmt = mktime(0, 0, 0, $match[2], $match[3], $match[1]);
      if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
      $fmt = preg_replace(array('/%e/', '/%D/'),
                          array(date('n', $gmt), '%m/%d/%y'),
                          $fmt);
      return strftime($fmt, $gmt);
    }





More information about the pmwiki-users mailing list