mirror of
https://github.com/DCsunset/taskwarrior-webui.git
synced 2025-08-20 01:13:06 +02:00
feat(frontend): humanize date
This commit is contained in:
parent
f116a7e79d
commit
2da5ddd4ce
1 changed files with 8 additions and 1 deletions
|
@ -189,7 +189,14 @@ import TaskDialog from '../components/TaskDialog.vue';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
function displayDate(str?: string) {
|
function displayDate(str?: string) {
|
||||||
return str && moment(str).format('YYYY-MM-DD');
|
if (!str)
|
||||||
|
return str;
|
||||||
|
|
||||||
|
const date = moment(str);
|
||||||
|
const diff = moment.duration(date.diff(moment()));
|
||||||
|
if (Math.abs(diff.asDays()) < 1)
|
||||||
|
return diff.humanize(true);
|
||||||
|
return date.format('YYYY-MM-DD');
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue