tpope/vim-speeddating

AM/PM uppercase/lowercase recognition problem

sionleroux opened this issue · 5 comments

vim-latex's article template has a "last changed" line which I would like to be able to update with speeddating's d<C-X>. I've added a speeddating format SpeedDatingFormat %a %b %d %I:00 %p %Y which is basically copied from that line in the article template. The problem seems to be that %p in the template and %p in speeddating don't match.

The template generates a date with the word am/pm written in lowercase, the same as if I would do :strftime("%p") in vim or date +'%p' at the command line, but :SpeedDatingFormat shows Tue Apr 08 08:00 PM 2014 with %p as AM/PM in capital letters. If I place the cursor somewhere on the line generated by the template and try to update the date nothing happens unless I'm over a number in which case it turns into a very long number (presumably a UNIX epoch). However, if I change the generated am/pm to uppercase then everything works as expected and the whole line is updated to the current date.

I'm not sure where to start looking for the cause of this but I think it's strange that there's this difference, since both vim-latex and speeddating seem to be using strftime().

For me strftime('%p') and date +'%p' both return PM, which is consistent with strftime(3). Guessing this either a platform issue or locale issue.

I think the capitalisation varies between locales. Anyway, I just found out that using %P instead of %p in SpeedDatingFormat makes it work with lower case pm but not upper case. Edit: I just read strftime(3) and I suppose that makes sense, so I'll just carry on using %P for this. However I still thing it's strange that for %p speeddating uses upper case and everything else uses lower case.

Yeah, admittedly strange, but %p itself appears to be a strange beast. Is %P lowercase in your locale? If so, I think "always use %^p or %P" is probably an adequate workaround.

Is %P lowercase in your locale?

I had a look in /usr/share/i18n/locales/ and en_GB defines am_pm as am and pm but en_US defines am_pm as AM and PM. I use en_GB so yeah, that explains why it's lower case… sometimes (I just noticed the desktop clock has it in upper case).

always use %^p or %P

%^p doesn't work, I'm not sure what it's supposed to do.

Anyway since I have my solution I guess this issue can be closed.

^ should force uppercase. Actually I see that a bunch of the built-in formats are using %^P, probably related to a previous problem in this area.

Closing, but I'm open to further concrete suggestions for improvements.