|
29 | 29 | <script> |
30 | 30 | function createCalendar(elem, year, month) { |
31 | 31 |
|
32 | | - let mon = month - 1; // months in JS are 0..11, not 1..12 |
| 32 | + let mon = month - 1; // JS'da aylar 0..11'dir, 1..12 değildir |
33 | 33 | let d = new Date(year, mon); |
34 | 34 |
|
35 | 35 | let table = '<table><tr><th>MO</th><th>TU</th><th>WE</th><th>TH</th><th>FR</th><th>SA</th><th>SU</th></tr><tr>'; |
36 | 36 |
|
37 | | - // spaces for the first row |
38 | | - // from Monday till the first day of the month |
| 37 | + // ilk satır için yer |
| 38 | + // Pazartesi'den ayın ilk gününe kadar |
39 | 39 | // * * * 1 2 3 4 |
40 | 40 | for (let i = 0; i < getDay(d); i++) { |
41 | 41 | table += '<td></td>'; |
42 | 42 | } |
43 | 43 |
|
44 | | - // <td> with actual dates |
| 44 | + // asıl tarihlerle <td> |
45 | 45 | while (d.getMonth() == mon) { |
46 | 46 | table += '<td>' + d.getDate() + '</td>'; |
47 | 47 |
|
48 | | - if (getDay(d) % 7 == 6) { // sunday, last day of week - newline |
| 48 | + if (getDay(d) % 7 == 6) { // Pazar günü, haftanın son günü - yeni satır |
49 | 49 | table += '</tr><tr>'; |
50 | 50 | } |
51 | 51 |
|
52 | 52 | d.setDate(d.getDate() + 1); |
53 | 53 | } |
54 | 54 |
|
55 | | - // add spaces after last days of month for the last row |
| 55 | + // ayın son günlerinden sonra, son satır için boş yer ekleyin |
56 | 56 | // 29 30 31 * * * * |
57 | 57 | if (getDay(d) != 0) { |
58 | 58 | for (let i = getDay(d); i < 7; i++) { |
59 | 59 | table += '<td></td>'; |
60 | 60 | } |
61 | 61 | } |
62 | 62 |
|
63 | | - // close the table |
| 63 | + // tabloyu kapat |
64 | 64 | table += '</tr></table>'; |
65 | 65 |
|
66 | 66 | elem.innerHTML = table; |
67 | 67 | } |
68 | 68 |
|
69 | | - function getDay(date) { // get day number from 0 (monday) to 6 (sunday) |
| 69 | + function getDay(date) { // 0 (pazartesi günü)n'den 6 (pazar günü)'ne kadar gün numarası alın |
70 | 70 | let day = date.getDay(); |
71 | | - if (day == 0) day = 7; // make Sunday (0) the last day |
| 71 | + if (day == 0) day = 7; // Pazar günü (0) son gün |
72 | 72 | return day - 1; |
73 | 73 | } |
74 | 74 |
|
|
0 commit comments