Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When it uses the 12-hour clock, datetime prints "noon" instead of "pm" when the time is between 12 noon and 1pm. Probably a bug rather than by design?

How can it be made to print "12.34pm" rather than "12.34 noon"?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

I'm answering my own question here, in the hope that others might find this useful.

The answer is simple. Just put:

\usepackage{datetime}
\renewcommand*{\noon}{\pmname}
share|improve this answer
    
for those of us who believe that noon is 12:00am and that 12:00pm is midnight, this is too confusing. this is why insurance companies always start a policy at 12:01am. @egreg's first suggestion is more precise. –  barbara beeton Jan 30 '12 at 13:37
1  
@barbarabeeton: Forgive me if I disagree with you, Barbara, but 12:00am and 12:00pm are meaningless and should be removed from the vocabulary of thinking people, I believe. 12:00 should be called 12 noon and 00:00/24:00 12 midnight. 12am and 12pm are artifacts of some lazy programmer, I suspect. –  Brent.Longborough Jan 30 '12 at 14:00
    
@Brent.Longborough -- oh, i agree with you thoroughly that 12am and 12pm shouldn't be used at all, and many years ago had that fight with a meetings group who needed a printed schedule produced by tex from a database. (fortunately, the database internally used a 24-hour clock.) "noon" is how that time is represented in the printed program; even the "12:00" becomes unnecessary at that point. –  barbara beeton Jan 30 '12 at 14:21
1  
I use time-stamps on versions of docs I'm preparing, not docs for other people such as embargoed releases or insurance policies. But noon and midnight are instants. I need a 12:00 (am or pm) time-stamp to refer to the time when I've put it on, i.e. an instant in the open interval (12:00,12:01). The whole of this interval is either am or pm. Hitting noon or midnight exactly has probability zero. (Agreed this pov is unworkable in the media or insurance.) –  Harry Macpherson Jan 30 '12 at 14:28
    
@HarryMacpherson: I agree, any time is an instant, but if you need precision, tou should add it. E.g.: 12:00:00.00001pm is completely valid. –  Brent.Longborough Jan 30 '12 at 17:25
show 6 more comments

The way to circumvent this feature while leaving datetime display noon as "12:00 Noon" is to patch the \timeformat@ampmtime adding a check also on minutes:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\timeformat@ampmtime}
  {\value{HOUR}=12} % existent check 
  {\value{HOUR}=12 \AND \value{MINUTE}=0} % new check
  {}{}
\makeatother

If one doesn't want "Noon" and prefers that noon is displayed as "12:00pm", then

\renewcommand{\noon}{\unskip\pmname}

is the way to go, as the macros add a space between the hour and "Noon".

share|improve this answer
    
Many thanks for this. I was wondering how to get rid of the space which appeared before "pm" when the time was between noon and 1pm but otherwise didn't! I'm of the school that says noon is an instant, so would see even 12:00 as pm (seconds are there even when not shown, and microseconds at 12:00:00 etc.). Other people's mileage may of course vary! :) –  Harry Macpherson Jan 30 '12 at 12:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.