Skip to content

Commit

Permalink
Use dayjs instead of moment (thomiceli#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomiceli committed Sep 5, 2023
1 parent d4eed91 commit 0d7305d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
29 changes: 13 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"autoprefixer": "^10.4.14",
"codemirror": "^6.0.1",
"cssnano": "^5.1.15",
"dayjs": "^1.11.9",
"github-markdown-css": "^5.2.0",
"highlight.js": "^11.7.0",
"markdown-it": "^13.0.1",
"moment": "^2.29.3",
"nodemon": "^2.0.22",
"postcss": "^8.4.13",
"postcss-cssnext": "^3.1.1",
Expand Down
14 changes: 8 additions & 6 deletions public/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import './style.css';
import './style.scss';
import './favicon.svg';
import './default.png';
import moment from 'moment';
import md from 'markdown-it';
import hljs from 'highlight.js';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import localizedFormat from 'dayjs/plugin/localizedFormat';

dayjs.extend(relativeTime);
dayjs.extend(localizedFormat);

document.addEventListener('DOMContentLoaded', () => {
const themeMenu = document.getElementById('theme-menu')!;
Expand Down Expand Up @@ -43,12 +45,12 @@ document.addEventListener('DOMContentLoaded', () => {
})

document.querySelectorAll('.moment-timestamp').forEach((e: HTMLElement) => {
e.title = moment.unix(parseInt(e.innerHTML)).format('LLLL');
e.innerHTML = moment.unix(parseInt(e.innerHTML)).fromNow();
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 = moment.unix(parseInt(e.innerHTML)).format('DD/MM/YYYY HH:mm');
e.innerHTML = dayjs.unix(parseInt(e.innerHTML)).format('DD/MM/YYYY HH:mm');
});

const rev = document.querySelector<HTMLElement>('.revision-text');
Expand Down

0 comments on commit 0d7305d

Please sign in to comment.