{"id":103527,"date":"2020-03-04T07:00:00","date_gmt":"2020-03-04T15:00:00","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/oldnewthing\/?p=103527"},"modified":"2020-03-04T08:54:29","modified_gmt":"2020-03-04T16:54:29","slug":"20200304-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20200304-00\/?p=103527","title":{"rendered":"Meet me here on Savvyday 29 Oatmeal 94"},"content":{"rendered":"<p>The <code>Internet\u00adTime\u00adTo\u00adSystem\u00adTime<\/code> function takes an HTTP time\/date string and converts it to a windows <code>SYSTEM\u00adTIME<\/code> structure. A customer noticed that the <code>Internet\u00adTime\u00adTo\u00adSystem\u00adTime<\/code> returns strange results when given strange data.<\/p>\n<table class=\"cp3\" style=\"border-collapse: collapse;\" border=\"1\" cellpadding=\"3\">\n<tbody>\n<tr>\n<th>Input<\/th>\n<th>Result<\/th>\n<th>Notes<\/th>\n<\/tr>\n<tr>\n<td><tt>Sat, 29 Oct 1994 09:43:31 GMT<\/tt><\/td>\n<td>October 29, 1994 at 09:43:31 GMT<\/td>\n<td>As expected<\/td>\n<\/tr>\n<tr>\n<td><tt>Sat 29 Oct 1994 09:43:31 GMT<\/tt><\/td>\n<td>October 29, 1994 at 09:43:31 GMT<\/td>\n<td>Missing comma<\/td>\n<\/tr>\n<tr>\n<td><tt>Sat 29 Oct 1994 9:43:31 GMT<\/tt><\/td>\n<td>October 29, 1994 at 09:43:31 GMT<\/td>\n<td>Missing leading zero<\/td>\n<\/tr>\n<tr>\n<td><tt>Sat Oct 29 9:43:31 1994<\/tt><\/td>\n<td>October 29, 1994 at 09:43:31 GMT<\/td>\n<td>Flipped month\/day and trailing year<\/td>\n<\/tr>\n<tr>\n<td><tt>Sat 29 Oct 1994 9:43<\/tt><\/td>\n<td>October 29, 1994 at 09:43:00 GMT<\/td>\n<td>Missing seconds and time zone<\/td>\n<\/tr>\n<tr>\n<td><tt>Sat 29 Oct 1994<\/tt><\/td>\n<td>October 29, 1994 at 00:00:00 GMT<\/td>\n<td>Missing time<\/td>\n<\/tr>\n<tr>\n<td><tt>Sat 29 Oct 94<\/tt><\/td>\n<td>October 29, 1994 at 00:00:00 GMT<\/td>\n<td>Two-digit year<\/td>\n<\/tr>\n<tr>\n<td><tt>Savvyday 29 Oatmeal 94<\/tt><\/td>\n<td>October 29, 1994 at 00:00:00 GMT<\/td>\n<td>Horrible spelling errors<\/td>\n<\/tr>\n<tr>\n<td><tt>1<\/tt><\/td>\n<td>March 4, 2020 at 15:00:00 GMT<\/td>\n<td>Returns current time<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>What&#8217;s going on?<\/p>\n<p>The <code>Internet\u00adTime\u00adTo\u00adSystem\u00adTime<\/code> function tries really hard to make sense out of what you give it. This sometimes leads to the absurd, like treating <i>Savvyday<\/i> as if it were a misspelling of <i>Saturday<\/i> and <i>Oatmeal<\/i> as if it were a misspelling of <i>October<\/i>.<\/p>\n<p>The <code>Internet\u00adTime\u00adTo\u00adSystem\u00adTime<\/code> is not a validator. It&#8217;s a best-guess parser. The expectation is that you are giving <code>Internet\u00adTime\u00adTo\u00adSystem\u00adTime<\/code> a string that you got from an HTTP header, and you need to make as much sense out of it as you can, per Postel&#8217;s Principle.\u00b9<\/p>\n<p>Back in Windows 7, the feature team tried to make the parser more strict. This effort was a total disaster, because applications in practice were using the function to parse all sorts of things that didn&#8217;t even pretend to adhere to the RFC. For example, a photo processing shell extension used this function to parse dates, and the attempt to enforce strict validation caused the shell extension to stop working entirely.<\/p>\n<p>Consequently, all the changes were backed out, and the parser to this day remains as tolerant of malformed dates as it was when it was originally written. The generous parsing is now a required feature.<\/p>\n<p>\u00b9 There are those who believe that Postel&#8217;s Principle is wrong.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><CODE>Internet&shy;Time&shy;To&shy;System&shy;Time<\/CODE> tries really hard to make sense out of that sentence.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-103527","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p><CODE>Internet&shy;Time&shy;To&shy;System&shy;Time<\/CODE> tries really hard to make sense out of that sentence.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103527","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=103527"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103527\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=103527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=103527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=103527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}