Fix human date on iOS devices (#510)

This commit is contained in:
Thomas Miceli
2025-09-21 04:31:58 +02:00
committed by GitHub
parent c02bf97b63
commit 4106956f6d
14 changed files with 24 additions and 47 deletions

View File

@@ -1,23 +1,8 @@
import './style.scss';
import './favicon-32.png';
import './opengist.svg';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import 'dayjs/locale/cs';
import 'dayjs/locale/de';
import 'dayjs/locale/es';
import 'dayjs/locale/fr';
import 'dayjs/locale/hu';
import 'dayjs/locale/pt';
import 'dayjs/locale/ru';
import 'dayjs/locale/zh';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import jdenticon from 'jdenticon/standalone';
dayjs.extend(relativeTime);
dayjs.extend(localizedFormat);
dayjs.locale(window.opengist_locale || 'en');
jdenticon.update("[data-jdenticon-value]")
document.addEventListener('DOMContentLoaded', () => {
@@ -55,23 +40,13 @@ document.addEventListener('DOMContentLoaded', () => {
document.getElementById('user-menu').classList.toggle('hidden');
})
document.querySelectorAll('.moment-timestamp').forEach((e: HTMLElement) => {
e.title = dayjs.unix(parseInt(e.innerHTML)).format('LLLL');
e.innerHTML = dayjs.unix(parseInt(e.innerHTML)).fromNow();
});
document.querySelectorAll('.moment-timestamp-date').forEach((e: HTMLElement) => {
e.innerHTML = dayjs.unix(parseInt(e.innerHTML)).format('DD/MM/YYYY HH:mm');
});
document.querySelectorAll('form').forEach((form: HTMLFormElement) => {
form.onsubmit = () => {
form.querySelectorAll('input[type=datetime-local]').forEach((input: HTMLInputElement) => {
console.log(dayjs(input.value).unix());
const hiddenInput = document.createElement('input');
hiddenInput.type = 'hidden';
hiddenInput.name = 'expiredAtUnix'
hiddenInput.value = dayjs(input.value).unix().toString();
hiddenInput.value = Math.floor(new Date(input.value).getTime() / 1000).toString();
form.appendChild(hiddenInput);
});
return true;