date bugfix
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 30s
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 30s
This commit is contained in:
@@ -35,8 +35,9 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="start_date">Start Date (optional)</label>
|
||||
<input type="datetime-local" id="start_date" name="start_date" class="form-control">
|
||||
<label for="start_date_picker">Start Date (optional)</label>
|
||||
<input type="datetime-local" id="start_date_picker" class="form-control">
|
||||
<input type="hidden" id="start_date" name="start_date">
|
||||
<div class="form-hint">When the hunt becomes active. Leave blank to start immediately.</div>
|
||||
</div>
|
||||
|
||||
@@ -47,8 +48,9 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="expiry_date">Expiry Date (optional)</label>
|
||||
<input type="datetime-local" id="expiry_date" name="expiry_date" class="form-control">
|
||||
<label for="expiry_date_picker">Expiry Date (optional)</label>
|
||||
<input type="datetime-local" id="expiry_date_picker" class="form-control">
|
||||
<input type="hidden" id="expiry_date" name="expiry_date">
|
||||
<div class="form-hint">Leave blank for no expiry.</div>
|
||||
</div>
|
||||
|
||||
@@ -58,13 +60,12 @@
|
||||
</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();
|
||||
[['start_date_picker', 'start_date'], ['expiry_date_picker', 'expiry_date']].forEach(function(pair) {
|
||||
var picker = document.getElementById(pair[0]);
|
||||
var hidden = document.getElementById(pair[1]);
|
||||
if (picker.value) {
|
||||
hidden.value = new Date(picker.value).toISOString();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,8 +31,9 @@
|
||||
|
||||
<div class="form-group">
|
||||
<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_picker" class="form-control"
|
||||
data-utc="<%= hunt.start_date || '' %>">
|
||||
<input type="hidden" id="start_date" name="start_date">
|
||||
<div class="form-hint">When the hunt becomes active. Leave blank to start immediately.</div>
|
||||
</div>
|
||||
|
||||
@@ -44,8 +45,9 @@
|
||||
|
||||
<div class="form-group">
|
||||
<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_picker" class="form-control"
|
||||
data-utc="<%= hunt.expiry_date || '' %>">
|
||||
<input type="hidden" id="expiry_date" name="expiry_date">
|
||||
<div class="form-hint">Leave blank for no expiry.</div>
|
||||
</div>
|
||||
|
||||
@@ -54,7 +56,7 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Populate datetime-local inputs from stored UTC values (convert to local)
|
||||
// Populate datetime-local pickers from stored UTC values (convert to local)
|
||||
document.querySelectorAll('input[data-utc]').forEach(function(input) {
|
||||
var utc = input.dataset.utc;
|
||||
if (utc) {
|
||||
@@ -65,13 +67,13 @@ document.querySelectorAll('input[data-utc]').forEach(function(input) {
|
||||
}
|
||||
}
|
||||
});
|
||||
// Convert datetime-local (user's local time) to UTC ISO before submit
|
||||
// Convert picker local time to UTC ISO for hidden inputs on 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();
|
||||
[['start_date_picker', 'start_date'], ['expiry_date_picker', 'expiry_date']].forEach(function(pair) {
|
||||
var picker = document.getElementById(pair[0]);
|
||||
var hidden = document.getElementById(pair[1]);
|
||||
if (picker.value) {
|
||||
hidden.value = new Date(picker.value).toISOString();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user