diff --git a/script.js b/script.js index 894db0e..1b96969 100644 --- a/script.js +++ b/script.js @@ -4,8 +4,8 @@ var msec_display = true; var fullscreen = false; var other_counters = [ // Title EN, Title RU, Start Unix timestamp, End Unix timestamp, Description EN, Description RU ["UNIX unsinged 32-bit timestamp", "UNIX 32 бита без знака", 0n, 4294967295n, "Developers of some systems have thought that singed 32-bit may not be enough and decided to use unsinged 32-bit.", "Разработчики некоторых систем додумались, что 32 бита со знаком однажды может не хватить и решили использовать 32 бита без знака."], - ["FAT filesystems timestamps", "Штампы времени файловой системы FAT", 315532800n, 4354819198n, "", "На каждую отметку времени отводится четыре байта: два - на дату и два - на время. Год хранится в формате количества лет от начала эпохи Microsoft. Отсюда и диапазон - от 1980 до 2107 года"], - ["ext4 filesystems timestamps", "Штампы времени файловой системы ext4", -2147483648n, 15032385529n, "Inode Timestamps", ""], + ["FAT filesystems timestamps", "Штампы времени файловой системы FAT", 315532800n, 4354819198n, "Four bytes are assigned to each timestamp: two for the date and two for the time. The year is stored in the last 7 bits in the format of the number of years since the beginning of the Microsoft era. Hence the range - from 1980 to 2107", "На каждую отметку времени отводится четыре байта: два - на дату и два - на время. Год хранится в последних 7 битах в формате количества лет от начала эпохи Microsoft. Отсюда и диапазон - от 1980 до 2107 года"], + ["ext4 Inode Timestamps", "Inode Timestamps файловой системы ext4", -2147483648n, 15032385535n, "Four timestamps are recorded in the lower 128 bytes of the inode structure -- inode change time (ctime), access time (atime), data modification time (mtime), and deletion time (dtime). The four fields are 32-bit signed integers that represent seconds since the Unix epoch (1970-01-01 00:00:00 GMT), which means that the fields will overflow in January 2038. If the inode structure size sb->s_inode_size is larger than 128 bytes and the i_inode_extra field is large enough to encompass the respective i_[cma]time_extra field, the ctime, atime, and mtime inode fields are widened to 64 bits. Within this \"extra\" 32-bit field, the lower two bits are used to extend the 32-bit seconds field to be 34 bit wide; the upper 30 bits are used to provide nanosecond timestamp accuracy. Therefore, timestamps should not overflow until May 2446. dtime was not widened.", "В нижних 128 байтах структуры индексного дескриптора записываются четыре метки времени: время изменения индексного дескриптора (ctime), время доступа (atime), время модификации данных (mtime) и время удаления (dtime). Четыре поля представляют собой 32-разрядные целые числа со знаком, представляющие секунды с эпохи Unix (1970-01-01 00:00:00 GMT), что означает, что поля будут переполнены в январе 2038 года. Если размер структуры inode sb->s_inode_size превышает 128 байт, а поле i_inode_extra достаточно велико, чтобы охватить соответствующее поле i_[cma]time_extra, поля ctime, atime и mtime inode расширяются до 64 бит. В этом «дополнительном» 32-битном поле младшие два бита используются для расширения 32-битного поля секунд до 34-бит; верхние 30 бит используются для обеспечения наносекундной точности отметки времени. Поэтому временные метки не должны переполняться до мая 2446 года. Время dtime не расширялось."], ["NTFS filesystems timestamps", "Штампы времени файловой системы NTFS", -11644473600n, 1833029984880n, "File times are 64-bit numbers counting 100-nanosecond intervals (ten million per second) since 1601, which is 58,000+ years", "Для хранения даты и времени отведено 64 бита; шаг — 100 наносекунд (десять миллионов интервалов в секунду). Это позволяет указать дату и время в промежутке из 58 тысяч лет."], // ["Year 32,768 bug", "Проблема 32 768 года", -62167219200, 971890963200, "", ""], // ["Year 65,536 bug", "Проблема 65 536 года", -62167219200, 2005949145600, "", ""], @@ -17,6 +17,7 @@ var language_user = window.navigator ? (window.navigator.language || window.navigator.userLanguage) : "ru"; language_user = language_user.substr(0, 2).toLowerCase(); language_site = (language_user == "ru" || language_user == "by" || language_user == "ua") ? "ru" : "en"; +var date_to_local = new Intl.DateTimeFormat(language_site, {timeZone: 'UTC', weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', timeZoneName: 'short'}); function ReadableTimerSwitcher(){ readable_timer_mode++ if(readable_timer_mode > 2){readable_timer_mode = 0} @@ -35,6 +36,7 @@ addEventListener("fullscreenchange", (event) => { }) function languageSwitcher(lang_code){ + counter_id = 0; switch (lang_code) { case "ru": $("#title_en").css("display", "none"); @@ -44,6 +46,11 @@ function languageSwitcher(lang_code){ $("#me_tg_en").css("display", "none"); $("#me_tg_ru").css("display", ""); language_site = "ru"; + other_counters.forEach(element => { + $("#title_"+counter_id).html(element[1]); + $("#desc_"+counter_id).html(element[5]); + counter_id++; + }); break; case "en": $("#title_ru").css("display", "none"); @@ -52,9 +59,15 @@ function languageSwitcher(lang_code){ $("#description_en").css("display", "block"); $("#me_tg_ru").css("display", "none"); $("#me_tg_en").css("display", ""); + other_counters.forEach(element => { + $("#title_"+counter_id).html(element[0]); + $("#desc_"+counter_id).html(element[4]); + counter_id++ + }); language_site = "en"; break; } + date_to_local = new Intl.DateTimeFormat(language_site, {timeZone: 'UTC', weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', timeZoneName: 'short'}); } languageSwitcher(language_site); function msecDisplaySwitcher(){ @@ -66,6 +79,34 @@ function msecDisplaySwitcher(){ $("#time-left-msec").css("display", "unset"); } } +function SpawnOtherCounters(){ + let other_counters_html = (language_site == "ru") ? "

Другие, более далёкие проблемы времени в вычислительной технике

" : "

Other, more distant time problems in computing

"; + counter_id = 0; + var timestamp = Date.now() / 1000; + other_counters.forEach(element => { + l = element[3] - BigInt(Math.trunc(timestamp)); + date_from = new Date(parseInt(element[2])*1000); + try { + date_from = date_to_local.format(date_from) + } catch (e) { + date_from = ((element[2] / 60n / 60n / 24n / 365n) + 1970n).toLocaleString(language_site, {style: "unit", unit: "year"}) + } + date_to = new Date(parseInt(element[3])*1000); + try { + date_to = date_to_local.format(date_to) + } catch (e) { + date_to = ((element[3] / 60n / 60n / 24n / 365n) + 1970n).toLocaleString(language_site, {style: "unit", unit: "year"}) + } + other_counters_html = other_counters_html + '

'+ element[(language_site == "ru") ? 1 : 0] + '

' + + l.toLocaleString(language_site) + '
' // second argument: {notation: "compact", compactDisplay: "long", style: "unit", unit: "second", unitDisplay: 'long'} + + ((timestamp-parseInt(element[2]))/(parseInt(element[3])-parseInt(element[2]))).toLocaleString(language_site, {style: "percent", minimumFractionDigits: 8}) + + " · " + date_from + " ‒ " + date_to + + ' · ' + (l / 60n / 60n / 24n / 365n).toLocaleString(language_site, {style: "unit", unit: "year"}) + ' ' + (l / 60n / 60n / 24n % 365n).toLocaleString(language_site, {style: "unit", unit: "day"}) + ' ' + ("0" + (l / 60n / 60n % 24n)).slice(-2) + ':' + ("0" + (l / 60n % 60n)).slice(-2) + ':' + ("0" + (l % 60n)).slice(-2) + + '

' + element[(language_site == "ru") ? 5 : 4] + '

'; counter_id++; + }); + $("#other_countdowns").html(other_counters_html) +} +SpawnOtherCounters(); function Cycle() { var timestamp = Date.now() / 1000, left = maxtimestamp - timestamp, @@ -103,19 +144,32 @@ function Cycle() { $("#time-left-readable").html(Math.trunc(timestamp).toLocaleString(language_site)+" / "+maxtimestamp.toLocaleString(language_site)+" ("+(timestamp/maxtimestamp).toLocaleString(language_site, {style: "percent", minimumFractionDigits: 8})+")"); break; } - let other_counters_html = (language_site == "ru") ? "

Другие, более далёкие проблемы времени в вычислительной технике

" : "

Other, more distant time problems in computing

"; +} +function OtherCountersCycle(){ + counter_id = 0; + var timestamp = Date.now() / 1000; other_counters.forEach(element => { l = element[3] - BigInt(Math.trunc(timestamp)); date_from = new Date(parseInt(element[2])*1000); + try { + date_from = date_to_local.format(date_from) + } catch (e) { + date_from = ((element[2] / 60n / 60n / 24n / 365n) + 1970n).toLocaleString(language_site, {style: "unit", unit: "year"}) + } date_to = new Date(parseInt(element[3])*1000); - date_to_local = new Intl.DateTimeFormat(language_site, {timeZone: 'UTC', weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', timeZoneName: 'short'}) - other_counters_html = other_counters_html + '

'+ element[(language_site == "ru") ? 1 : 0] + '

' - + l.toLocaleString(language_site) + '
' // second argument: {notation: "compact", compactDisplay: "long", style: "unit", unit: "second", unitDisplay: 'long'} - + ((timestamp-parseInt(element[2]))/(parseInt(element[3])-parseInt(element[2]))).toLocaleString(language_site, {style: "percent", minimumFractionDigits: 8}) - + " · "; try {other_counters_html = other_counters_html + date_to_local.format(date_from)} catch (e) {other_counters_html = other_counters_html + ((element[2] / 60n / 60n / 24n / 365n) + 1970n).toLocaleString(language_site, {style: "unit", unit: "year"})}; other_counters_html = other_counters_html + " ‒ "; try {other_counters_html = other_counters_html + date_to_local.format(date_to)} catch (e) {other_counters_html = other_counters_html + ((element[3] / 60n / 60n / 24n / 365n) + 1970n).toLocaleString(language_site, {style: "unit", unit: "year"})}; other_counters_html = other_counters_html + try { + date_to = date_to_local.format(date_to) + } catch (e) { + date_to = ((element[3] / 60n / 60n / 24n / 365n) + 1970n).toLocaleString(language_site, {style: "unit", unit: "year"}) + } + $("#main_cd_"+counter_id).html(l.toLocaleString(language_site)); + $("#othr_progress_"+counter_id).html( + ((timestamp-parseInt(element[2]))/(parseInt(element[3])-parseInt(element[2]))).toLocaleString(language_site, {style: "percent", minimumFractionDigits: 8}) + + " · " + date_from + " ‒ " + date_to + ' · ' + (l / 60n / 60n / 24n / 365n).toLocaleString(language_site, {style: "unit", unit: "year"}) + ' ' + (l / 60n / 60n / 24n % 365n).toLocaleString(language_site, {style: "unit", unit: "day"}) + ' ' + ("0" + (l / 60n / 60n % 24n)).slice(-2) + ':' + ("0" + (l / 60n % 60n)).slice(-2) + ':' + ("0" + (l % 60n)).slice(-2) - + '

' + element[(language_site == "ru") ? 5 : 4] + '

'; + ); + counter_id++; }); - $("#other_countdowns").html(other_counters_html) } -var c = setInterval(Cycle, 1000 / 15); \ No newline at end of file +var c = setInterval(Cycle, 1000 / 15); +var d = setInterval(OtherCountersCycle, 1000); \ No newline at end of file