Skip to content

Commit

Permalink
Merge pull request #15 from davwheat/master
Browse files Browse the repository at this point in the history
feat: use i18n built-ins
  • Loading branch information
t5r7 committed Jun 6, 2023
2 parents 7c799eb + 0f7c035 commit 1891060
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions js/addedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,13 @@ function setActual(which) {
}

function setNow(which) {
const now = new Date();

let date = `${now.getDate().toString().padStart(2, '0')}.${(now.getMonth() + 1).toString().padStart(2, '0')}.${now.getFullYear()}`;
let time = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}`;
const now = new Intl.DateTimeFormat('da-DK', { dateStyle: 'short', timeStyle: 'short', timeZone: 'Europe/Copenhagen' }).format(new Date())

if(which === "dep") {
journey.departureTimeActual = `${date} ${time}`;
journey.departureTimeActual = now;
} else {
// if anything other than "dep" then set arrival time (in case I missed something somewhere that calls this)
journey.arrivalTimeActual = `${date} ${time}`;
journey.arrivalTimeActual = now;
}

loadJourney();
Expand Down

0 comments on commit 1891060

Please sign in to comment.