Skip to content

How to figure out which parts of the date were not provided? #22

@roma-glushko

Description

@roma-glushko

Hey thanks for the great library!

I would like to see if there is a reliable way to figure out which parts of the date were not provided directly in the input string but rather inferred?

For example,

  • the input string was May 13th, so I would like to know that month/day was provided while year was missed.
  • the input string was 1997, so I would like to know that month/day were missed and only year was provided.

I believe Period was supposed to be the answer, but it gives me Day for May 13th meaning that it's confident in year -> month -> day? But it can't be confident in year in this case as it was not provided.

Another question: is it possible to figure that which parsed date was relative? E.g. last week, yesterday, in 3 days, etc.

My use cases are a bunch of little functionalities around scheduling/reminding:

  • If someone wants to record May 13th as someone's birthday, then we shouldn't show how old that person is since we don't know the year they were born.
  • If relative date was provided, we need to "fix" it in time by turning into an exact timestamp vs keeping incomplete absolute dates as is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions