Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Interchange: users

date_convert zerofix fails unless surrounded by space

 

 

Interchange users RSS feed   Index | Next | Previous | View Threaded


paul at gishnetwork

Aug 9, 2011, 2:17 PM

Post #1 of 4 (221 views)
Permalink
date_convert zerofix fails unless surrounded by space

Hi

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


_______________________________________________
interchange-users mailing list
interchange-users [at] icdevgroup
http://www.icdevgroup.org/mailman/listinfo/interchange-users


david at endpoint

Aug 9, 2011, 2:50 PM

Post #2 of 4 (220 views)
Permalink
Re: date_convert zerofix fails unless surrounded by space [In reply to]

On Aug 9, 2011, at 4:17 PM, Paul Jordan wrote:

>
> Hi
>
> 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?

Regards,

David
--
David Christensen
End Point Corporation
david [at] endpoint
Attachments: smime.p7s (1.36 KB)


paul at gishnetwork

Aug 9, 2011, 3:16 PM

Post #3 of 4 (209 views)
Permalink
Re: date_convert zerofix fails unless surrounded by space [In reply to]

> 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


paul at gishnetwork

Aug 9, 2011, 3:47 PM

Post #4 of 4 (209 views)
Permalink
Re: date_convert zerofix fails unless surrounded by space [In reply to]

> 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
Paul, try this: fmt="%-I%P" http://linux.die.net/man/3/strftime Says if you are using glibc there are additional conversation flags. It works for me with your test code. Paul

Interchange users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.