diff --git a/public/Assets/JS/CurrentAge.js b/public/Assets/JS/CurrentAge.js new file mode 100644 index 0000000..f02dc83 --- /dev/null +++ b/public/Assets/JS/CurrentAge.js @@ -0,0 +1,20 @@ +// All Unix time values are in milliseconds (ms) +const UnixDay = 86400000; +const UnixYear = 31536000000; +const BirthTime = 1082713500000; + +function UnixTime() { + let DateNow = Date.now(); + let TimeSinceBirth = DateNow - BirthTime; + let YearsSinceBirth = TimeSinceBirth / UnixYear; + let LeapYears = ~~(YearsSinceBirth / 4); + return DateNow - UnixDay*LeapYears; +} + +function UnixAgeNow() { + return UnixTime() - BirthTime; +} + +function UnixToYears() { + return UnixAgeNow() / UnixYear; +} \ No newline at end of file diff --git a/public/index.html b/public/index.html index 168f53c..18e944a 100644 --- a/public/index.html +++ b/public/index.html @@ -13,6 +13,7 @@ +
@@ -25,9 +26,20 @@