fix: 修复前端页面的一些bug
This commit is contained in:
parent
87ff8f44d7
commit
a5ddaea5a8
@ -1,4 +1,10 @@
|
|||||||
const WeatherUtils = {
|
const WeatherUtils = {
|
||||||
|
formatDatetimeLocal(date) {
|
||||||
|
const offsetMinutes = date.getTimezoneOffset();
|
||||||
|
const local = new Date(date.getTime() - offsetMinutes * 60 * 1000);
|
||||||
|
return local.toISOString().slice(0, 16);
|
||||||
|
},
|
||||||
|
|
||||||
initializeDateInputs() {
|
initializeDateInputs() {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const startDate = new Date(now.getTime() - 24 * 60 * 60 * 1000);
|
const startDate = new Date(now.getTime() - 24 * 60 * 60 * 1000);
|
||||||
@ -8,10 +14,10 @@ const WeatherUtils = {
|
|||||||
const endDateInput = document.getElementById('endDate');
|
const endDateInput = document.getElementById('endDate');
|
||||||
|
|
||||||
if (startDateInput) {
|
if (startDateInput) {
|
||||||
startDateInput.value = startDate.toISOString().slice(0, 16);
|
startDateInput.value = this.formatDatetimeLocal(startDate);
|
||||||
}
|
}
|
||||||
if (endDateInput) {
|
if (endDateInput) {
|
||||||
endDateInput.value = endDate.toISOString().slice(0, 16);
|
endDateInput.value = this.formatDatetimeLocal(endDate);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user