Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for level of specificity in date range #5

Open
curtisgibby opened this issue Nov 30, 2020 · 1 comment
Open

Add support for level of specificity in date range #5

curtisgibby opened this issue Nov 30, 2020 · 1 comment

Comments

@curtisgibby
Copy link

curtisgibby commented Nov 30, 2020

This is a great project! It fills almost perfectly a need that I have. However, in my use-case, I would like to be more generic about the date range, by dropping the day field. For example, I currently get back from ranger->format() the text Jan 8 – Oct 26, 2020, but it would be nice to just say Jan – Oct 2020. (Or for the example dates Oct 13–26, 2020, simply saying Oct 2020.)

I could see potential use cases for dropping even the month:

  • For my dates above, outputting just 2020
  • An employment history (2015–2020)
  • A sports season (2019–2020)
  • A person's birth and death dates on a tombstone (1951–2013)

Is this theoretically possible in Ranger right now? Monkeying around with its internals, I seemed to find problems with creating an IntlDateFormatter using only parts of the date.

@flack
Copy link
Owner

flack commented Dec 1, 2020

Hi!

Well, it's an interesting idea and I think it should be possible. Probably there'd have to be some function like renderOnlyFrom(Ranger::MONTH) or similar and then the loop(s) in format would need to be adjusted to skip all the parts (and separators) that are below the chosen threshhold. It could be a bit finicky, but yeah, I think it could work. If I have some time, I'll try to take a look soonish, but otherwise, pull requests are always welcome of course! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants