I saw this question posted last week on a previous post I had discussing the Date/Time format in OneNote. I also got a few emails asking this same question from different users so I figured this may be interesting to write about.
"I am having trouble figuring out how to change the format of the time/date inserted. It defaults to 4/31/2009. [I]n my perfect world I would like Thursday, April 30, 2009."
Pasted from <http://blogs.msdn.com/johnguin/archive/2007/09/10/testing-insert-date-and-time-functionality.aspx?CommentPosted=true#commentmessage>
There is a way to do this, and this will show one way that testing OneNote becomes a bit simpler.
First, let's see how Windows displays date formats. It varies from country to country and region to region. In Windows XP, you can open the control panel \ Regional and Language Options application to see how your system is configured. On Vista, depending on how your control panel is configured, it is under Clock, Language and Region settings, then "Change the date, time or number format."
Here's what it looks like in Vista:
And in XP:
If you click customize, the dialogs now start to match more and it looks like this:
See that Short date format circled? That is where Windows gets its information on how to display a compact date format. Your machine probably has this as the default:
M/d/yyyy if you live in the US.
The format here is not all that complicated and should be easy to understand. The M refers to month, the d for the day of the month, and yyyy is year.
Anyway, you can change the format here to this to get what Gunnar wants:
dddd, MMMM dd/yyyy
Clever readers will note that all Gunnar really wanted was the long date format used for the system short date format. All I did was copy/paste the format. This is pretty much true. You can also either play with and figure out the schema yourself, or look it up in excruciating detail online.
And very clever readers will note that I do not truly know if this is exactly what he wants. His "specification" is unclear since he only defines the desired result if the day of the month is 2 digits long:
Thursday, April 30, 2009
If the day is only one digit long, such as Friday, May 1, 2009, there are two ways that can be displayed:
Friday, May 1, 2009
Friday, May 01, 2009
Notice the "0" in front of the "1" in the day of the month. I had to guess which of these two formats Gunnar actually wants, and decided having 2 digits for consistency is preferred. I may have guessed wrong, but at least the workaround in this case is easy: remove the two "d" characters and use this string for short date format instead:
dddd, MMMM d/yyyy
Here's where testing gets easier, though. It is pretty obvious that we merely ask Windows what short date format to display when I type SHIFT+ALT+D. The advantage this gives me if I am the tester is that I know we have no specific OneNote code to change, alter, configure or otherwise adjust the date format. We simply rely on what the user has defined in Windows. If we did have our own code, we would need to ensure we were getting the date format correct for every language and region in the world, make sure we had it configurable for the users, test that code in addition to the code that actually inserts the string and maintain this code long term. We would wind up duplicating a lot of code and services Windows already gives us, and perform a lot of unneeded testing to maintain that code base. It's just easier to let the team over at Windows handle this and just give us a formatted string when we ask.
Questions, comments, concerns and criticisms always welcome,