Update index.html
Browse files- index.html +22 -8
index.html
CHANGED
|
@@ -78,10 +78,10 @@
|
|
| 78 |
|
| 79 |
<script>
|
| 80 |
const sessions = [
|
| 81 |
-
{ center: "Sydney", tz: "Australia/Sydney", open: "08:00
|
| 82 |
-
{ center: "Tokyo", tz: "Asia/Tokyo", open: "09:00
|
| 83 |
-
{ center: "London", tz: "Europe/London", open: "08:00
|
| 84 |
-
{ center: "New York", tz: "America/New_York", open: "09:30
|
| 85 |
];
|
| 86 |
|
| 87 |
function updateSessions() {
|
|
@@ -95,12 +95,26 @@ function updateSessions() {
|
|
| 95 |
|
| 96 |
sessions.forEach(s => {
|
| 97 |
const nowInTZ = new Date(new Date().toLocaleString("en-US", { timeZone: s.tz }));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
const open = new Date(nowInTZ);
|
|
|
|
|
|
|
| 99 |
const close = new Date(nowInTZ);
|
| 100 |
-
|
| 101 |
-
const [ch, cm] = s.close.split(":");
|
| 102 |
-
open.setHours(oh, om, 0);
|
| 103 |
-
close.setHours(ch, cm, 0);
|
| 104 |
|
| 105 |
const today = nowInTZ.getDay();
|
| 106 |
const isWeekend = today === 0 || today === 6;
|
|
|
|
| 78 |
|
| 79 |
<script>
|
| 80 |
const sessions = [
|
| 81 |
+
{ center: "Sydney", tz: "Australia/Sydney", open: "08:00", close: "16:00" },
|
| 82 |
+
{ center: "Tokyo", tz: "Asia/Tokyo", open: "09:00", close: "17:00" },
|
| 83 |
+
{ center: "London", tz: "Europe/London", open: "08:00", close: "16:00" },
|
| 84 |
+
{ center: "New York", tz: "America/New_York", open: "09:30", close: "16:00" }
|
| 85 |
];
|
| 86 |
|
| 87 |
function updateSessions() {
|
|
|
|
| 95 |
|
| 96 |
sessions.forEach(s => {
|
| 97 |
const nowInTZ = new Date(new Date().toLocaleString("en-US", { timeZone: s.tz }));
|
| 98 |
+
const parseTime = (timeStr) => {
|
| 99 |
+
let [time, modifier] = timeStr.split(' ');
|
| 100 |
+
let [hours, minutes] = time.split(':').map(Number);
|
| 101 |
+
if (modifier === 'PM' && hours < 12) {
|
| 102 |
+
hours += 12;
|
| 103 |
+
}
|
| 104 |
+
if (modifier === 'AM' && hours === 12) {
|
| 105 |
+
hours = 0;
|
| 106 |
+
}
|
| 107 |
+
return { hours, minutes };
|
| 108 |
+
};
|
| 109 |
+
|
| 110 |
+
const openTime = parseTime(s.open);
|
| 111 |
+
const closeTime = parseTime(s.close);
|
| 112 |
+
|
| 113 |
const open = new Date(nowInTZ);
|
| 114 |
+
open.setHours(openTime.hours, openTime.minutes, 0, 0);
|
| 115 |
+
|
| 116 |
const close = new Date(nowInTZ);
|
| 117 |
+
close.setHours(closeTime.hours, closeTime.minutes, 0, 0);
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
const today = nowInTZ.getDay();
|
| 120 |
const isWeekend = today === 0 || today === 6;
|