From 49f66f2ffccce1b28f136e693ab652d1e23109fd Mon Sep 17 00:00:00 2001 From: root Date: Thu, 19 Sep 2024 07:10:24 +0200 Subject: [PATCH] first commit --- README.md | 0 index.html | 19 +++++++++++++++ index.js | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 README.md create mode 100644 index.html create mode 100644 index.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/index.html b/index.html new file mode 100644 index 0000000..bba8ca6 --- /dev/null +++ b/index.html @@ -0,0 +1,19 @@ + + + + + + Obliczanie daty Wielkanocy + + + + + + +
+

+
+ + + + \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..3434b51 --- /dev/null +++ b/index.js @@ -0,0 +1,69 @@ +function isNaturalNumber (str) { + var pattern = /^(0|([1-9]\d*))$/; + return pattern.test(str); +} + +function calculate(){ + let year = document.getElementById("year").value; + + if (isNaturalNumber(year) == false){ + document.getElementById("result").textContent = "Błąd. Podano nieodpowiedni ciąg znaków!" + } + else if (year < 1900 || year > 2099){ + document.getElementById("result").textContent = "Błąd. Podano rok spoza zakresu 1900-2099!" + } + else{ + let a, b, c, d, e, p, q, month; + p = 24; + q = 5; + month = 3; + a = year % 19; + b = year % 4; + c = year % 7; + d = ((19 * a) + p) % 30; + e = ((2 * b) + (4 * c) + (6 * d) + q) % 7; + result = d + e + 22; + if (result > 31){ + result = result - 31; + month += 1; + } + if (result > 25 && month == 4){ + result = result - 7; + } + document.getElementById("result").textContent = `Data wielkanocy: ${result}.0${month}.${year}`; + } +} + +// d + +// function calculate() { +// let year = document.getElementById("year").value; + +// if (isNaturalNumber(year) == false) { +// document.getElementById("result").textContent = "Błąd. Podano nieodpowiedni ciąg znaków!" +// } +// else if (year < 1 || year > 5000) { +// document.getElementById("result").textContent = "Błąd. Podano rok spoza zakresu 1-5000!" +// } +// else { +// let a, b, c, d, e, f, g, h, i, k, l, m, month, day; + +// a = year % 19; +// b = Math.floor(year / 100); +// c = year % 100; +// d = Math.floor(b / 4); +// e = b % 4; +// f = Math.floor((b + 8) / 25); +// g = Math.floor((b - f + 1) / 3); +// h = (19 * a + b - d - g + 15) % 30; +// i = Math.floor(c / 4); +// k = c % 4; +// l = (32 + 2 * e + 2 * i - h - k) % 7; +// m = Math.floor((a + 11 * h + 22 * l) / 451); + +// month = Math.floor((h + l - 7 * m + 114) / 31); +// day = ((h + l - 7 * m + 114) % 31) + 1; + +// document.getElementById("result").textContent = `Data wielkanocy: ${day.toString().padStart(2, '0')}.${month.toString().padStart(2, '0')}.${year}`; +// } +// }