fix: update date handling to remove timezone offset for hunts
Build Images and Deploy / Update-PROD-Stack (push) Successful in 29s
Build Images and Deploy / Update-PROD-Stack (push) Successful in 29s
This commit is contained in:
+2
-2
@@ -224,12 +224,12 @@ const Hunts = {
|
|||||||
|
|
||||||
isHidden(hunt) {
|
isHidden(hunt) {
|
||||||
if (!hunt.hidden_until_start || !hunt.start_date) return false;
|
if (!hunt.hidden_until_start || !hunt.start_date) return false;
|
||||||
return new Date(hunt.start_date + 'Z') > new Date();
|
return new Date(hunt.start_date) > new Date();
|
||||||
},
|
},
|
||||||
|
|
||||||
hasStarted(hunt) {
|
hasStarted(hunt) {
|
||||||
if (!hunt.start_date) return true;
|
if (!hunt.start_date) return true;
|
||||||
return new Date(hunt.start_date + 'Z') <= new Date();
|
return new Date(hunt.start_date) <= new Date();
|
||||||
},
|
},
|
||||||
|
|
||||||
resetScans(id) {
|
resetScans(id) {
|
||||||
|
|||||||
@@ -57,4 +57,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Convert datetime-local (user's local time) to UTC ISO before submit
|
||||||
|
document.querySelector('form').addEventListener('submit', function() {
|
||||||
|
['start_date', 'expiry_date'].forEach(function(name) {
|
||||||
|
var input = document.getElementById(name);
|
||||||
|
if (input && input.value) {
|
||||||
|
var d = new Date(input.value);
|
||||||
|
if (!isNaN(d)) input.value = d.toISOString();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<%- include('../partials/footer') %>
|
<%- include('../partials/footer') %>
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex; gap: 0.4rem; align-items: center;">
|
<div style="display: flex; gap: 0.4rem; align-items: center;">
|
||||||
<% if (hunt.hidden_until_start && hunt.start_date && new Date(hunt.start_date + 'Z') > new Date()) { %>
|
<% if (hunt.hidden_until_start && hunt.start_date && new Date(hunt.start_date) > new Date()) { %>
|
||||||
<span class="badge expired" style="font-size: 0.7rem;">Hidden</span>
|
<span class="badge expired" style="font-size: 0.7rem;">Hidden</span>
|
||||||
<% } else if (hunt.start_date && new Date(hunt.start_date + 'Z') > new Date()) { %>
|
<% } else if (hunt.start_date && new Date(hunt.start_date) > new Date()) { %>
|
||||||
<span class="badge" style="font-size: 0.7rem;">Upcoming</span>
|
<span class="badge" style="font-size: 0.7rem;">Upcoming</span>
|
||||||
<% } %>
|
<% } %>
|
||||||
<span class="badge">Manage</span>
|
<span class="badge">Manage</span>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="start_date">Start Date (optional)</label>
|
<label for="start_date">Start Date (optional)</label>
|
||||||
<input type="datetime-local" id="start_date" name="start_date" class="form-control"
|
<input type="datetime-local" id="start_date" name="start_date" class="form-control"
|
||||||
value="<%= hunt.start_date ? new Date(hunt.start_date).toISOString().slice(0, 16) : '' %>">
|
data-utc="<%= hunt.start_date || '' %>">
|
||||||
<div class="form-hint">When the hunt becomes active. Leave blank to start immediately.</div>
|
<div class="form-hint">When the hunt becomes active. Leave blank to start immediately.</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="expiry_date">Expiry Date (optional)</label>
|
<label for="expiry_date">Expiry Date (optional)</label>
|
||||||
<input type="datetime-local" id="expiry_date" name="expiry_date" class="form-control"
|
<input type="datetime-local" id="expiry_date" name="expiry_date" class="form-control"
|
||||||
value="<%= hunt.expiry_date ? new Date(hunt.expiry_date).toISOString().slice(0, 16) : '' %>">
|
data-utc="<%= hunt.expiry_date || '' %>">
|
||||||
<div class="form-hint">Leave blank for no expiry.</div>
|
<div class="form-hint">Leave blank for no expiry.</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -53,6 +53,30 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Populate datetime-local inputs from stored UTC values (convert to local)
|
||||||
|
document.querySelectorAll('input[data-utc]').forEach(function(input) {
|
||||||
|
var utc = input.dataset.utc;
|
||||||
|
if (utc) {
|
||||||
|
var d = new Date(utc);
|
||||||
|
if (!isNaN(d)) {
|
||||||
|
var local = new Date(d.getTime() - d.getTimezoneOffset() * 60000);
|
||||||
|
input.value = local.toISOString().slice(0, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Convert datetime-local (user's local time) to UTC ISO before submit
|
||||||
|
document.querySelector('form').addEventListener('submit', function() {
|
||||||
|
['start_date', 'expiry_date'].forEach(function(name) {
|
||||||
|
var input = document.getElementById(name);
|
||||||
|
if (input && input.value) {
|
||||||
|
var d = new Date(input.value);
|
||||||
|
if (!isNaN(d)) input.value = d.toISOString();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="card" style="border: 2px solid var(--danger); margin-top: 1.5rem;">
|
<div class="card" style="border: 2px solid var(--danger); margin-top: 1.5rem;">
|
||||||
<div class="card-header" style="color: var(--danger);">Danger Zone</div>
|
<div class="card-header" style="color: var(--danger);">Danger Zone</div>
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -56,9 +56,9 @@
|
|||||||
<% if (hunt.expiry_date) { %> · Expires <time datetime="<%= hunt.expiry_date %>"><%= new Date(hunt.expiry_date).toLocaleDateString() %></time><% } %>
|
<% if (hunt.expiry_date) { %> · Expires <time datetime="<%= hunt.expiry_date %>"><%= new Date(hunt.expiry_date).toLocaleDateString() %></time><% } %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<% if (hunt.expiry_date && new Date(hunt.expiry_date + 'Z') < new Date()) { %>
|
<% if (hunt.expiry_date && new Date(hunt.expiry_date) < new Date()) { %>
|
||||||
<span class="badge expired">Expired</span>
|
<span class="badge expired">Expired</span>
|
||||||
<% } else if (hunt.start_date && new Date(hunt.start_date + 'Z') > new Date()) { %>
|
<% } else if (hunt.start_date && new Date(hunt.start_date) > new Date()) { %>
|
||||||
<span class="badge">Upcoming</span>
|
<span class="badge">Upcoming</span>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<span class="badge"><%= hunt.package_count %> packages</span>
|
<span class="badge"><%= hunt.package_count %> packages</span>
|
||||||
|
|||||||
@@ -16,14 +16,14 @@
|
|||||||
<% if (hunt.expiry_date) { %>
|
<% if (hunt.expiry_date) { %>
|
||||||
· Expires <time datetime="<%= hunt.expiry_date %>"><%= new Date(hunt.expiry_date).toLocaleDateString() %></time>
|
· Expires <time datetime="<%= hunt.expiry_date %>"><%= new Date(hunt.expiry_date).toLocaleDateString() %></time>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if (hunt.start_date && new Date(hunt.start_date + 'Z') > new Date()) { %>
|
<% if (hunt.start_date && new Date(hunt.start_date) > new Date()) { %>
|
||||||
· Starts <time datetime="<%= hunt.start_date %>"><%= new Date(hunt.start_date).toLocaleDateString() %></time>
|
· Starts <time datetime="<%= hunt.start_date %>"><%= new Date(hunt.start_date).toLocaleDateString() %></time>
|
||||||
<% } %>
|
<% } %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<% if (hunt.expiry_date && new Date(hunt.expiry_date + 'Z') < new Date()) { %>
|
<% if (hunt.expiry_date && new Date(hunt.expiry_date) < new Date()) { %>
|
||||||
<span class="badge expired">Expired</span>
|
<span class="badge expired">Expired</span>
|
||||||
<% } else if (hunt.start_date && new Date(hunt.start_date + 'Z') > new Date()) { %>
|
<% } else if (hunt.start_date && new Date(hunt.start_date) > new Date()) { %>
|
||||||
<span class="badge">Upcoming</span>
|
<span class="badge">Upcoming</span>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<span class="badge"><%= hunt.package_count %> packages</span>
|
<span class="badge"><%= hunt.package_count %> packages</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user