tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Looking for comments on changing strptime(3) %p behavior
> b. strptime(str, "%p", &tm)
> Currently if str contains a am/pm string and no hour is specified
> then tm_hour is adjusted as per above or an error is returned
> based on tm_hour. This would seem to be a bug on both counts.
> The %p should be parsed and only applied to a valid 12-hour clock
> value obtained via the same parse.
I think I disagree. What you suggest leaves no way for someone to
parse a 12-hour time and then, later, correct for an AM/PM indicator,
short of either (1) doing one or both of those operations some way than
strptime or (2) assembling a single string containing (at least) the
hour and the AM/PM indicator and strptime()ing it. This seems
suboptimal to me, especially since the current implementation supports
that operation just fine.
Does XPG specify what happens when %p is used without an hour spec, or
with %H but not %I? (And what if both %H and %I are used?)
> c. strptime("12", "%I", &tm)
> Currently the 12 is converted tm_hour = 0. This seems rather odd
> since %I must be in the range of 1-12.
Well, tm_hour is a 24-hour hour figure; I'm not sure what else you
think a 12-hour "12" should convert into.
Unfortunately, fixing this right seems to me to require changing struct
tm so it contains a 12-hour hour, a 24-hour hour, and an AM/PM
indicator. But that would be a significant API (not to mention ABI)
change, and may well conflict with XPG.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index