Long time reader of this blog Ivan Petrov asked in the Suggestion Box:

Hi Michael.

From where can I customize the Short Time Format?

The Long Time Format can be Customized from Regional and Language Options > Customize (button)=>Customize Regional Options > Time (tab), but the Short one?

Regards,
Ivan.

Ivan has an excellent point. The .NET Framework has its DateTimeFormatInfo class with its LongTimePattern and ShortTimePattern, but Regional Options does not have anything like it.

So where is the short time pattern, and why is it not in Regional Options?

Well, to start, Regional Options has the job of supporting all of the fields in the Win32 locales that can be overridden. And functions like Win32's GetLocaleInfo only has a LOCALE_STIME, which matches the data in the .NET LongTimePattern. Win32 has never had such a concept.

Which of course leads us to wonder where .NET got the idea from.

The important thing to remember is that while to many .NET is the successor to Win32, it is more accurate to consider .NET to be the successor to COM and the VB/VBA world. Now VBA supports a FormatDateTime function that accepts a vbShortTime, but that has never been a Win32 locale functionality.

There are probably people who will be reminded of the limitations in percent functionality I have discussed previously, and indeed the issue is similar -- the need to be compatible with a feature that was written by somebody else and for which there has not been a real push to understand the globalization scenarios is never going to get the same kind of support as one that has.

With that said, the .NET ShortTimePattern is a settable property, so one could always override it. And obviously one could even cleverly remove the AM/PM indicator if it exists in the long time format if one needed to.

As an interesting data point, often when customers have mentioned this issue in the past, they expect that the time pattern in Regional Options would affect both the long and short time patterns in the .NET Framework, which is a fascinating idea (though if it were up to me I would add a LOCALE_SSHORTTIME before I'd put Win32 or Regional Options into the string parsing game). And since it has come up as a point of confusion when people compare/contrast the managed and unmanaged worlds, it is probably on people's radar at this point.

But for now, the short time is something that is only in the COM and .NET worlds, while traditional Win32 only has the long time, which it simply calls the time.

 

This post brought to you by "𝄵" (U+1d135, a.k.a. MUSICAL SYMBOL CUT TIME)