Proper Way To Determine AM or PM
-
Until now, I've just gone on my merry way assuming that the only way to determine whether a time was AM or PM was either to get back a string with .ToShortDateString() and parse it out using Split, or to check to see if the Hours field in the date's TimeOfDay field was greater than 12. I haven't been happy with either answer, but haven't found a better one. What is the "proper" API way of doing this? Or is what I've mentioned all I get? -Matt ------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall
-
Until now, I've just gone on my merry way assuming that the only way to determine whether a time was AM or PM was either to get back a string with .ToShortDateString() and parse it out using Split, or to check to see if the Hours field in the date's TimeOfDay field was greater than 12. I haven't been happy with either answer, but haven't found a better one. What is the "proper" API way of doing this? Or is what I've mentioned all I get? -Matt ------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall
Why not just check if
DateTime.Hour >= 12
?-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Why not just check if
DateTime.Hour >= 12
?-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
I'm an idiot! I recall stepping through the debugger on a recent project and I could have sworn a 1 o'clock appointment record was coming up with an hour value of 1 rather than 13, but sure enough, I just built a simple desktop app to test it again and it came up with 13 on a 1:00 pm. I had just ASSumed that there was someething I was missing to determine meridian. Oh well. Here's to assuming!! Thanks. I appreciate you answering a stupid question. ;-) -Matt ------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall