// ==UserScript==
// @name         Gitlab 24h Time
// @namespace    https://jloewe.net
// @version      0.1
// @description  Format dates on Gitlab using the german date format
// @author       Jan Loewe
// @match        https://gitlab.com/*
// @match        https://gitlab1.ptb.de/*
// @icon         https://gitlab.com/favicon.ico
// @updateURL	 https://gitlab1.ptb.de/-/snippets/66/raw/main/gitlab-24h-time.user.js
// @grant        none
// ==/UserScript==

// This code is based on the UserScript by Benjamin Bock (https://gitlab.com/bnjmnbck)
// see https://gitlab.com/gitlab-org/gitlab/-/issues/15206#note_847008519

function format(date) {
    if(!date) return;
    return date.toLocaleString("de-DE", { year: "numeric", month: "2-digit", day: "2-digit", hour:"2-digit", minute: "2-digit", second: "2-digit"});
}

function fixTime() {
    document.querySelectorAll("time").forEach(e => {e.innerHTML = format(new Date(e.getAttribute("datetime"))) })
}

(function() {
    'use strict';

    fixTime();
    setTimeout(fixTime, 100);
    setTimeout(fixTime, 300);
})();