On 12/05/15 14:51, Michael Stone wrote: > On Tue, May 12, 2015 at 03:36:17PM +0200, op...@mumm.ac.be wrote: >> I'm just upgrading my server from debian 7 (wheezy) to debian 8 (jessie) and >> several of my scripts are not working anymore. After some tests, it turns >> out that the problem likely comes from the fact the 'date' function does not >> work as expected. >> >> In wheezy, the command line >>> date /bin/date +"%Y%m%d.%p" >> would have returned >>> 20150512.PM >> >> In jessie, the same command line returns >>> 20150512. >> omitting PM. >> >> As a consequence of this omission, my scripts are crashing. >> >> Have you got any idea why this is happening? > > I can't reproduce it: > >> /bin/date +"%Y%m%d.%p" > 20150512.AM > > If I had to guess, I'd say it's a locale issue. What does > env LANG=C LC_ALL=C /bin/date +"%Y%m%d.%p" > return? > > If that works, what does > locale > return when run by itself?
%p is blank in many locales unfortunately. You can see the am_pm vary with these commands: $ LC_ALL=en_IE locale -k LC_TIME $ LC_TIME=C locale -k LC_TIME $ LC_ALL=zh_CN.utf8 date +%p 下午 $ LC_ALL=en_US.utf8 date +%p PM $ LC_ALL=en_US date +%p PM locales with blank am_pm should be fixed up to allow one to get an explicit 12 hour format like `date +%I:%m%p` for example. Note some locales (like en_GB for example) default to 24 hour (t_fmt="%T"), and also provide an am_pm entry, which is the correct behavior in my opinion. cheers, Pádraig -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org