parse-human-relative-time
parse-human-relative-time copied to clipboard
parse "last week"
How can we parse "last week" with this library best?
I mean, point to beginning of last week best. Pick "last Monday" instead?
We'll have to extend the grammar, the Luxon implementation and the date-fns implementation.
@derhuerst do you think you could add that?
Or give at least some clues where to start, and I can try.
@derhuerst do you think you could add that?
I currently have other priorities.
Or give at least some clues where to start, and I can try.
As I mentioned above, the grammar will have to be adapted, in order to parse the new syntax "last week".
Then, the code applying the parsed result to a DateTime (Luxon adapter) or Date (date-fns adapter), respectively, needs to be extended to handle the new cases.
Totally respect your priorities.
Cloned your repo yesterday and my first attempts failed. My idea was to have last week to return the first day of the last week.
But then I realised I can implement the last week date range with the following workaround:
const lastMonday = parseHumanRelative("last monday");
const lastSunday = parseHumanRelative("last sunday");
// then combine both and so on...
Guess for now can live with that.
But yeah, now I am stuck with “last month” as there is no workaround like the above: https://github.com/derhuerst/parse-human-relative-time/issues/6