-
-
+
+
+
+
Параметры опроса
+
+
+
+
+
+
+
+
+
+
Формат: ["Вариант 1", "Вариант 2", ...]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -282,17 +319,25 @@
// Заполняем форму
document.getElementById('vk_post_id').value = post.vk_post_id || '';
document.getElementById('shortname').value = post.shortname || '';
- document.getElementById('action_number').value = post.action_number || '';
document.getElementById('auto_unit').value = post.auto_unit || '';
document.getElementById('text').value = post.text || '';
document.getElementById('image_url').value = post.image_url || '';
document.getElementById('vk_post_url').value = post.vk_post_url || '';
// Форматирование дат для input[type=datetime-local]
+ // Конвертация UTC в локальное время с округлением до минут
const formatForInput = (dateStr) => {
if (!dateStr) return '';
const date = new Date(dateStr);
- return date.toISOString().slice(0, 16);
+ // Округляем до минут (убираем секунды и миллисекунды)
+ date.setSeconds(0, 0);
+ // Возвращаем в локальном времени в формате YYYY-MM-DDTHH:MM
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+ const day = String(date.getDate()).padStart(2, '0');
+ const hours = String(date.getHours()).padStart(2, '0');
+ const minutes = String(date.getMinutes()).padStart(2, '0');
+ return `${year}-${month}-${day}T${hours}:${minutes}`;
};
document.getElementById('published_at').value = formatForInput(post.published_at);
@@ -329,6 +374,16 @@
}
}
+ // Функция конвертации локального времени в UTC для отправки на сервер
+ const convertLocalToUTC = (localString) => {
+ if (!localString) return null;
+ const date = new Date(localString);
+ // Округляем до минут
+ date.setSeconds(0, 0);
+ // Возвращаем в UTC формате для сервера
+ return date.toISOString().slice(0, 19).replace('T', ' ');
+ };
+
// Сохранение поста
async function savePost() {
const postId = document.getElementById('post-id').value;
@@ -349,21 +404,20 @@
const formData = {
vk_post_id: document.getElementById('vk_post_id').value,
shortname: document.getElementById('shortname').value,
- action_number: document.getElementById('action_number').value,
auto_unit: document.getElementById('auto_unit').value,
text: document.getElementById('text').value,
image_url: document.getElementById('image_url').value,
vk_post_url: document.getElementById('vk_post_url').value,
- published_at: document.getElementById('published_at').value,
+ published_at: convertLocalToUTC(document.getElementById('published_at').value),
is_event: document.getElementById('is_event').checked, // Новое поле
is_poll: document.getElementById('is_poll').checked,
poll_question: document.getElementById('poll_question').value,
poll_options: document.getElementById('poll_options').value,
poll_multiple: document.getElementById('poll_multiple').checked,
- poll_end_date: document.getElementById('poll_end_date').value,
+ poll_end_date: convertLocalToUTC(document.getElementById('poll_end_date').value),
marked_for_publication: document.getElementById('marked_for_publication').checked,
published_in_tg: document.getElementById('published_in_tg').checked,
- tg_publication_date: document.getElementById('tg_publication_date').value,
+ tg_publication_date: convertLocalToUTC(document.getElementById('tg_publication_date').value),
tg_message_id: document.getElementById('tg_message_id').value,
tg_poll_id: document.getElementById('tg_poll_id').value,
tg_markpost_id: document.getElementById('tg_markpost_id').value,