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 inputLng = '39.8666';
function formatLaunchDateTime(date, time) {
// Parse the date
const d = new Date(date);
const year = d.getUTCFullYear();
const month = String(d.getUTCMonth() + 1).padStart(2, '0');
const day = String(d.getUTCDate()).padStart(2, '0');
function formatLaunchDateTime(dateObj, timeStr) {
// Ensure date is a Date object
const date = new Date(dateObj);
// Parse the time (add seconds if missing)
const [hours, minutes, seconds = '00'] = time.split(':');
const formattedTime = `${hours.padStart(2, '0')}:${minutes.padStart(2, '0')}:${seconds.padStart(2, '0')}`;
// Extract date components
const year = date.getFullYear();
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);