[ic] date_convert zerofix fails unless surrounded by space
Paul Jordan
paul at gishnetwork.com
Tue Aug 9 22:16:47 UTC 2011
> I've notice that the zerofix parameter doesn't work if the format specifier is butted up to another specifier. Here is some test code that can be pasted onto any page.
>
> This will work as expected:<br />
> [convert_date zerofix=1 fmt="%I %P"][/convert_date]
>
> <br /><br />
>
> This will not:<br />
> [convert_date zerofix=1 fmt="%I%P"][/convert_date]
>
> BTW - that is a captial eye, not lowercase L.
>
> I think it is a bug, or...?
>
> Paul Jordan
> >
> >
> > It looks like zerofix operates on the formatted value, which in turn is implemented via:
> >> > $out =~ s/\b0(\d)\b/$1/g if $opt->{zerofix};> >
> > So this will only remove leading zeros if the final output value matches that regex, > > which is dependent on word breaks. %P I assume in this case is alpha-numeric, not > > digits. (My system strftime() has %p but not %P). Definitely unintuitive behavior, but > > not sure what the best fix would be in general; maybe remove the trailing \b from > > the regex?> >> > David
Hmmm, on the formatted value? That means it could potentially affect the minutes space, which wouldn't be good in most cases. I'm just going to have a new convert_date tag made that would allow one to tell it exactly what to zerofix (if applicable) ala zerofix="%H %I %e". It seems even the specifiers that remove leading zeros like %e tend to add a space - which is presumptuous. Mine would apply the zerofix to any named specifiers individually. There's some enhancements I need done anyway that probably aren't generally useful. Thank you Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.icdevgroup.org/pipermail/interchange-users/attachments/20110809/c0b6d67b/attachment.html>
More information about the interchange-users
mailing list