parse-human-relative-time icon indicating copy to clipboard operation
parse-human-relative-time copied to clipboard

Unable to define weekStartsOn parameter

Open binarykitchen opened this issue 3 years ago • 1 comments

Some countries might start the week on another day, which can be configured in date-fns weekStartsOn parameter.

Unfortunately, this cannot be passed over here due to fixed lexing: https://github.com/derhuerst/parse-human-relative-time/blob/1fd21930e4568588233f33746984a152ba9bc6ab/date-fns.js#L18

Can we figure a way, a solution, how to support such a parameter?

binarykitchen avatar Feb 24 '22 23:02 binarykitchen

Huh, this is a tricky problem.

Without trying it out, I think the best way is to

  1. add an optional opt = {} to createParse
  2. const {weekStartsOn} = {weekStartsOn: 0, ...opt}
  3. if cmd is a date-fns command where the weekStartsOn option is accepted, pass it into args via args = [...args, {weekStartsOn}].

PR welcome!

derhuerst avatar Mar 15 '22 20:03 derhuerst