{"id":32118,"date":"2021-04-14T15:30:30","date_gmt":"2021-04-14T19:30:30","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=32118"},"modified":"2021-04-14T15:33:20","modified_gmt":"2021-04-14T19:33:20","slug":"big-sur-has-changed-how-macos-formats-time","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2021\/04\/14\/big-sur-has-changed-how-macos-formats-time\/","title":{"rendered":"Big Sur Has Changed How macOS Formats Time"},"content":{"rendered":"<p><a href=\"https:\/\/eclecticlight.co\/2021\/04\/03\/big-sur-can-prevent-ulbow-mints-and-t2m2-from-browsing-its-log\/\">Howard Oakley<\/a>:<\/p>\n<blockquote cite=\"https:\/\/eclecticlight.co\/2021\/04\/03\/big-sur-can-prevent-ulbow-mints-and-t2m2-from-browsing-its-log\/\"><p>A number of those using my free utilities Ulbow, Mints and T2M2, and possibly others, have recently noticed a bug which prevents them from obtaining any log extracts. When you try to get a log extract or, in T2M2, to run a check on Time Machine, you are shown an error dialog reporting that<\/p>\n<blockquote><p>log command returned an error number 64<\/p><\/blockquote>\n<p>[&#8230;]<\/p>\n<p>The reason for this occurring is that, contrary to the scant documentation which Apple provides, when the system clock is set to display time using a 12-hour clock rather than 24-hours, <code>log show<\/code> now formats all its timestamp fields (field 0, timestamp) using a 12-hour clock and AM\/PM as appropriate.<\/p>\n<p>I have no earthly idea what possessed Apple to make this change, nor why it hasn&rsquo;t made this clear in its release notes. However, if you parse or analyse log entry timestamps, it breaks that completely.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/eclecticlight.co\/2021\/04\/08\/big-sur-has-changed-how-macos-formats-time\/\">Howard Oakley<\/a>:<\/p>\n<blockquote cite=\"https:\/\/eclecticlight.co\/2021\/04\/08\/big-sur-has-changed-how-macos-formats-time\/\">\n<p>Formatting like yyyy-MM-dd HH:mm:ss isn&rsquo;t defined by Apple, but conforms to Report TR35 from the Unicode Consortium, and is <a href=\"https:\/\/www.unicode.org\/reports\/tr35\/\" target=\"_blank\" rel=\"noopener noreferrer\">exhaustively defined here<\/a>. That makes it clear that setting the hour using HH returns the hour in 24-hour format, ranging from 00 to 23.<\/p>\n<p>Yet when a Mac is set to use 12-hour format, that rule is broken: the hour is returned in h format rather than HH, as unpadded digits between 0 and 11, or maybe even 1 and 12. Furthermore, the am\/pm value is being added to the string.<\/p>\n<p>[&#8230;]<\/p>\n<p>Sure enough, adding the line\n<code>dateFormatter.locale = Locale(identifier: \"en_US_POSIX\")<\/code>\nto my code restores respect for my formatting.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/eclecticlight.co\/2021\/04\/11\/last-week-on-my-mac-big-surs-broken-clock\/\">Howard Oakley<\/a>:<\/p>\n<blockquote cite=\"https:\/\/eclecticlight.co\/2021\/04\/11\/last-week-on-my-mac-big-surs-broken-clock\/\"><p>The <a href=\"https:\/\/developer.apple.com\/library\/archive\/qa\/qa1480\/_index.html\">advice given<\/a> is vague and raises more questions:<\/p>\n<p>&ldquo;if you&rsquo;re working with fixed-format dates, you should first set the locale of the date formatter to something appropriate for your fixed format. In most cases the best locale to choose is &ldquo;en_US_POSIX&rdquo;, a locale that&rsquo;s specifically designed to yield US English results regardless of both user and system preferences.&rdquo;<\/p>\n<p>How do we tell if our specific case is one of those &ldquo;most cases&rdquo;? What other effects might that setting have? If someone has set their Mac to run in Danish, should we be using something other than a US English setting here? But above all, why on earth would Apple change &ldquo;in unexpected ways&rdquo; a <strong><em>fixed<\/em><\/strong> format to something unspecified of its own invention which flies in the face of Report TR35? Just why is it impossible to follow the prescribed format string?<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2015\/05\/26\/predictable-date-formatting\/\">Predictable Date Formatting<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Howard Oakley: A number of those using my free utilities Ulbow, Mints and T2M2, and possibly others, have recently noticed a bug which prevents them from obtaining any log extracts. When you try to get a log extract or, in T2M2, to run a check on Time Machine, you are shown an error dialog reporting [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2021-04-14T19:30:33Z","apple_news_api_id":"0c6f2e80-1efe-4e85-968f-6e754cadcb9e","apple_news_api_modified_at":"2021-04-14T19:33:23Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAg==","apple_news_api_share_url":"https:\/\/apple.news\/ADG8ugB7-ToWWj251TK3Lng","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[69,30,1891,568,1504,71,364],"class_list":["post-32118","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-mac","tag-macos-11-0","tag-nsdateformatter","tag-os_log","tag-programming","tag-time"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=32118"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32118\/revisions"}],"predecessor-version":[{"id":32128,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32118\/revisions\/32128"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=32118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=32118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=32118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}