MySQL 的 TIME 範圍

這篇算是考古文,找出 MySQLTIME 資料型態奇怪範圍的由來:「TIME for a WTF MySQL moment」。

在官方的文件裡面可以看到 TIME 的範圍是個奇怪的數字,如果把各版本的文件都拉出來看,會發現都沒改過:「11.2.3 The TIME Type (8.0)」、「11.2.3 The TIME Type (5.7)」、「11.2.3 The TIME Type (5.6)」,「11.3.2 The TIME Type (5.5,靠 Internet Archive 的存檔頁面)」、「11.3.2 The TIME Type (5.1,靠 Internet Archive 的存檔頁面)」、「11.3.2 The TIME Type (5.0,靠 Internet Archive 的存檔頁面)」,裡面一直都是:

TIME values may range from '-838:59:59' to '838:59:59'.

這個數字看起來應該是某個限制,但作者粗粗算了幾種可能都不像,所以就一路考古,發現算是在 MySQL 3 年代因為某個特別公式留下來的遺毒,就一路用到現在了:

One of the bits was used for the sign as well, but the remaining 23 bits were an integer value produced like this: Hours × 10000 + Minutes × 100 + Seconds; in other words, the two least significant decimal digits of the number contained the seconds, the next two contained the minutes, and the remaining ones contained the hours. 223 is 83888608, i.e. 838:86:08, therefore, the maximum valid time in this format is 838:59:59.

話說回來,用 MySQL 的人還是很習慣用 INTBIGINT 來存時間,這樣可以自動遠離這些鳥問題,之前在「MySQL 裡儲存時間的方式...」與「Facebook 在 MySQL 裡存時間的型態」這邊都寫過...

不過最近用 PostgreSQL 比較多,可以比較「正常」的使用各種資料型態...

跨各平台的 Microsoft Edge 又讓搞網站的人爆炸...

還好用的人應該不會太多 (?)

微軟宣佈在 iOSAndroid 以及微軟自家的系統上都推出 Microsoft Edge:「Announcing Microsoft Edge for iOS and Android, Microsoft Launcher」,另外也很「貼心」的整理了一篇不同平台上的差異 (尤其是 iOS 與 Android):「Microsoft Edge for iOS and Android: What developers need to know」。

不過 Twitter 上微軟自家人 Kyle Pflug‏ 講的比較簡單:

把重點講的超清楚,然後順建讓人有種 WTF 的感覺 XDDD (等於是一次推出三個不同行為的 browser 啊!)

設計師鐵定會詛咒他不要流行起來 XDDD