import * as chrono from 'chrono-node';
var now = new Date();
console.log("Reference date", now)
console.log("2 days ago", chrono.parseDate('2 days ago', now, {}));
console.log("2 weeks ago", chrono.parseDate('2 weeks ago', now, {}));
console.log("2 months ago", chrono.parseDate('2 months ago', now, {}));
console.log("2 days ago, forwardDate", chrono.parseDate('2 days ago', now, { forwardDate: true }));
console.log("2 weeks ago, forwardDate", chrono.parseDate('2 weeks ago', now, { forwardDate: true }));
console.log("2 months ago, forwardDate", chrono.parseDate('2 months ago', now, { forwardDate: true }));
I get
Reference date 2024-09-10T21:24:37.968Z
2 days ago 2024-09-08T21:24:37.968Z
2 weeks ago 2024-08-27T21:24:37.968Z
2 months ago 2024-07-10T21:24:37.968Z
2 days ago, forwardDate 2024-09-08T21:24:37.968Z
2 weeks ago, forwardDate 2024-09-11T21:24:37.968Z
2 months ago, forwardDate 2024-07-10T21:24:37.968Z
Note that all of them are in the past except for "2 weeks ago, forwardDate", which is 1 day in the future
Using v2.7.6, when I run:
I get
Note that all of them are in the past except for "2 weeks ago, forwardDate", which is 1 day in the future
This is demonstrated in https://replit.com/@group44/HarshPalegreenFacts