Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Make ztrftime pass more things to strftime



On Wed, Jul 8, 2015 at 4:03 PM, Jun T. <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>
> 2015/07/08 08:21, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>> % print -P %D\{%x\}
>> 2015年07月08日
>> % print -P %D\{%Ex\}
>> 平成27年07月08日
>
> It works for %Ex but not for %Ey.
> ztrftime() does not send %Ey to strftime() but ignores E and
> handles %y by itself.
>
> % date +%y
> 15
> % date +%Ey
> 27
> % print -P '%D{%y %Ey}'
> 15 15
>
> Is it possible to pass the entire format string to strftime()
> if HAVE_STRFTIME is defined?

With my latest patch, I can now do this,
% print -P '%D{%y %Ey %f}'
15 27 9
% date +'%y %Ey %f'
15 27 %f

If anyone wants me to make %3f work, I humbly ask them to keep this to
themselves.

Bonus, weird stuff strftime() does:
% date +%014EA #zeropadding the unchanged format string
00000000%014EA
% date +%020Ey #padding Ey is fine
00000000000000000027
% date +%020Oy #but not Oy
十五
% date +%_20Oe #not any O* it seems
九
% date +%020Oe #applies to english locale too
 9

If you find any problems, please check that it doesn't happen with
date with the same format string.

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author