date diff

This commit is contained in:
Romein van Buren 2023-04-13 17:20:49 +02:00
parent 60d8d7501c
commit 7ae80ae062
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
3 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,10 @@
const differenceInCalendarDays = require('date-fns/differenceInCalendarDays');
const earlier = new Date(2023, 6, 31);
const later = new Date(2028, 6, 1);
const dif = differenceInCalendarDays(later, earlier);
console.log('from:', earlier.toLocaleDateString('en-GB', { dateStyle: 'full' }));
console.log('to:', later.toLocaleDateString('en-GB', { dateStyle: 'full' }));
console.log(dif);

31
js/date-difference/package-lock.json generated Normal file
View File

@ -0,0 +1,31 @@
{
"name": "date-difference",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"dependencies": {
"date-fns": "^2.29.3"
}
},
"node_modules/date-fns": {
"version": "2.29.3",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz",
"integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==",
"engines": {
"node": ">=0.11"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/date-fns"
}
}
},
"dependencies": {
"date-fns": {
"version": "2.29.3",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz",
"integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA=="
}
}
}

View File

@ -0,0 +1,5 @@
{
"dependencies": {
"date-fns": "^2.29.3"
}
}