-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
time-flies/public/js/script.js の function calc() の以下のコードでは、人類の歴史の開始が「今年から20万年前に開始」となり、毎年一年ずつ開始年がシフトする。
var d = now.getFullYear() + 200000.0*(r-1.0);
// 2016年のときの人類の開始年
r = 0; 2016 + 200000.0*(r-1.0);
-197984
// 2017年のときの人類の開始年
r = 0; 2017 + 200000.0*(r-1.0);
-197983
「新人類, 20万年間」とあるので、コードと説明は間違っていないが、人類の開始年が毎年繰り上がるのは感覚的におかしく感じるので、以下のようなコードのほうがよいのではないか?
■修正案
// now.getFullYear() の部分は 2016 で代用
var d = Math.floor( (2016 + 200000.0) * r - 200000.0 );
■修正案の計算結果
// 2016年の場合の年始と年末
r = 0; Math.floor( (2016 + 200000.0) * r - 200000.0 );
-200000
r = 1; Math.floor( (2016 + 200000.0) * r - 200000.0 );
2016
// 2017年の場合の年始と年末
r = 0; Math.floor( (2017 + 200000.0) * r - 200000.0 );
-200000
r = 1; Math.floor( (2017 + 200000.0) * r - 200000.0 );
2017
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels