by Michael S. Kaplan, published on 2008/11/25 03:01 -05:00, original URI: http://blogs.msdn.com/b/michkap/archive/2008/11/25/9140376.aspx
The question yesterday was:
For date formatting and parsing APIs, is there a difference between lower- and upper-case Ys? (I.e., “yyyy” v. “YYYY”.) The articles on MSDN seem to be inconclusive. Errr.
That's an interesting question, I think.
Whether one looks at the Custom Date and Time Format Strings used by things like DateTime.ToString(string) or the strings in GetDateFormat or the strings in GetTimeFormat, it is clear that some characters (like H and M) have specific meaning attached to the cased variants.
In my book, since only the lowercase y is used here, the uppercase behavior is undefined -- if it works then have fun but you really shouldn't; if it fails then you kind of asked for that failure....
And more importantly, if the meaning changes in the future then that is also something requested in the improper use. and the nature of H vs. h and M vs. m kind of underscores this.
In practice, if the stuff works now could it really be changed later if the letter is needed for something else? Hard to say, really.
This is the kind of decision that I really hated when it was on me, though in that position I'd likely say maintain and document the behavior. Although the temptation to spank the violators would always be there, the fact that the actual spanking would hit the customers of the violator rather than the violator and the fact that Microsoft would be blamed would keep that from ever going beyond temptation....
And if I were designing the formatting/parsing tags from scratch, I'd lock them down from the beginning. :-)
Note that this problem is made slightly more complicated by the fact that some of the localized Regional and Language Options tags (also ref:[Localized] Date/Time format tokens) actually change case during the localization process. This would not change code or code callers, but it would confuse understanding in some other languages!
This blog brought to you by Y, y, and ʏ (U+0059 U+0079 U+028f, aka LATIN CAPITAL LETTER Y, LATIN SMALL LETTER Y, and LATIN LETTER SMALL CAPITAL Y)
go to newer or older post, or back to index or month or day