This commit is contained in:
Vasilisk9812 2025-04-05 00:14:36 +09:00
parent 0f130c640c
commit e67a9c6455

View file

@ -15,18 +15,25 @@
let inputLat = '56.3576'; let inputLat = '56.3576';
let inputLng = '39.8666'; let inputLng = '39.8666';
function formatLaunchDateTime(date, time) { function formatLaunchDateTime(dateObj, timeStr) {
// Parse the date // Ensure date is a Date object
const d = new Date(date); const date = new Date(dateObj);
const year = d.getUTCFullYear();
const month = String(d.getUTCMonth() + 1).padStart(2, '0');
const day = String(d.getUTCDate()).padStart(2, '0');
// Parse the time (add seconds if missing) // Extract date components
const [hours, minutes, seconds = '00'] = time.split(':'); const year = date.getFullYear();
const formattedTime = `${hours.padStart(2, '0')}:${minutes.padStart(2, '0')}:${seconds.padStart(2, '0')}`; const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return new Date(`${year}-${month}-${day}T${formattedTime}Z`).toISOString(); // Format time (ensure it has seconds)
let formattedTime = timeStr;
if (timeStr.split(':').length === 2) {
formattedTime += ':00'; // Add seconds if missing
}
// Combine into ISO string
const isoString = new Date(`${year}-${month}-${day}T${formattedTime}Z`).toISOString();
return isoString;
} }
const launch_datetime = formatLaunchDateTime(startDate, startTime); const launch_datetime = formatLaunchDateTime(startDate, startTime);