Skip to content

Commit

Permalink
feat: 🎸 add gen chosei san
Browse files Browse the repository at this point in the history
  • Loading branch information
t-akira012 committed Jul 4, 2024
1 parent 303f67a commit cdd380b
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
commit:
npx git-cz
85 changes: 85 additions & 0 deletions be/generate_chosei_san.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>スケジュール生成</title>
<style>
body {
font-family: Arial, sans-serif;
}
.schedule {
margin: 20px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
width: 300px;
text-align: center;
}
.input-container {
text-align: center;
margin: 20px;
}
.input-container input {
margin: 5px;
}
.schedule textarea {
width: 100%;
height: 300px;
margin-top: 10px;
font-family: Arial, sans-serif;
}
</style>
</head>
<body>
<div class="input-container">
<label for="year">年:</label>
<input type="number" id="year" value="2024">
<label for="month">月:</label>
<input type="number" id="month" value="8">
<button onclick="updateSchedule()">更新</button>
</div>

<div class="schedule">
<h2>スケジュール</h2>
<textarea id="schedule-text" readonly></textarea>
</div>

<script>
function getSchedule(year, month) {
const japaneseWeekdays = ["月", "火", "水", "木", "金", "土", "日"];
const schedule = [];
const daysInMonth = new Date(year, month, 0).getDate(); // Get the number of days in the given month

for (let day = 1; day <= daysInMonth; day++) {
const date = new Date(year, month - 1, day);
const weekday = date.getDay();
const dayName = japaneseWeekdays[weekday === 0 ? 6 : weekday - 1]; // Get the Japanese weekday name

if (weekday >= 1 && weekday <= 5) { // Monday to Friday
schedule.push(`${month}/${day}(${dayName}) 20:00〜`);
} else { // Saturday and Sunday
schedule.push(`${month}/${day}(${dayName}) 10:00〜`);
schedule.push(`${month}/${day}(${dayName}) 14:00〜`);
schedule.push(`${month}/${day}(${dayName}) 20:00〜`);
}
}
return schedule.join('\n');
}

function displaySchedule(year, month) {
const schedule = getSchedule(year, month);
const scheduleText = document.getElementById("schedule-text");
scheduleText.value = schedule;
}

function updateSchedule() {
const year = document.getElementById("year").value;
const month = document.getElementById("month").value;
displaySchedule(year, month);
}

// Initial display with default values
updateSchedule();
</script>
</body>
</html>

0 comments on commit cdd380b

Please sign in to comment.