Skip to content

Commit 717a8ba

Browse files
committed
fix: Merge branch 'main' of github.com:bellshade/Javascript into ui-server
2 parents 723b242 + d329ba7 commit 717a8ba

File tree

23 files changed

+774
-15
lines changed

23 files changed

+774
-15
lines changed

algorithm/conversion/dateToDay.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,31 @@ const dateToDay = (tanggal) => {
4242
const th = tahun % 100; // mengambil 2 digit tahun dari belakang
4343
const abad = Math.floor(tahun / 100); // mengambil 2 digit tahun dari depan
4444

45-
if ((bulan === 2) && (tahun % 4 === 0) && (tahun % 100 !== 0) || (tahun % 400 === 0)) {
46-
const hasil = Math.abs((tgl + Math.floor(2.6 * listBulan[bulan] - 0.2) - 2 * abad + th + Math.floor(th / 4) + Math.floor(abad / 4)+5) % 7);
45+
if (
46+
(bulan === 2 && tahun % 4 === 0 && tahun % 100 !== 0) ||
47+
tahun % 400 === 0
48+
) {
49+
const hasil = Math.abs(
50+
(tgl +
51+
Math.floor(2.6 * listBulan[bulan] - 0.2) -
52+
2 * abad +
53+
th +
54+
Math.floor(th / 4) +
55+
Math.floor(abad / 4) +
56+
5) %
57+
7
58+
);
4759
return listHari[hasil];
4860
} else {
49-
const hasil = Math.abs((tgl + Math.floor(2.6 * listBulan[bulan] - 0.2) - 2 * abad + th + Math.floor(th / 4) + Math.floor(abad / 4)) % 7);
61+
const hasil = Math.abs(
62+
(tgl +
63+
Math.floor(2.6 * listBulan[bulan] - 0.2) -
64+
2 * abad +
65+
th +
66+
Math.floor(th / 4) +
67+
Math.floor(abad / 4)) %
68+
7
69+
);
5070
return listHari[hasil];
5171
}
5272
};
@@ -61,4 +81,4 @@ console.log(dateToDay("29/03/2020")); // output: Minggu
6181
console.log(dateToDay("29/02/2020")); // output: Sabtu
6282
console.log(dateToDay("29/02/2024")); // output: Kamis
6383
console.log(dateToDay("29/02/2028")); // output: Selasa
64-
console.log(dateToDay("29/02/2032")); // output: Minggu
84+
console.log(dateToDay("29/02/2032")); // output: Minggu

0 commit comments

Comments
 (0)