前幾天 Twitter 伺服器時間大爆炸的原因...

前幾天 Twitter 伺服器的時間大爆炸,跳到 2015 年:

剛剛在 Hacker News Daily 上看到原因:「If you're using YYYY in your JVM service or %G in anything, fix it now」,原因是這樣:

The single character G instead of Y took down Twitter's API today.
If you're using YYYY in your JVM service or %G in anything, fix it now. You're very likely using the wrong year format.

date
Mon Dec 29 00:44:45 EST 2014
date -u "+%G"
2015

ISO 8601 week numbering has 2015 start this week.

在自己電腦上也可以重製出來:

gslin@home [~] [01:22/W4] date 
Wed Dec 31 01:27:00 CST 2014
gslin@home [~] [01:27/W4] date +%Y
2014
gslin@home [~] [01:27/W4] date +%G
2015

依照說明,%G 的用途是:

year of ISO week number (see %V); normally useful only with %V

用錯好慘啊...

Leave a Reply

Your email address will not be published. Required fields are marked *