ranger icon indicating copy to clipboard operation
ranger copied to clipboard

Add support for level of specificity in date range

Open curtisgibby opened this issue 3 years ago • 1 comments

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.

curtisgibby avatar Nov 30 '20 16:11 curtisgibby

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! :-)

flack avatar Dec 01 '20 09:12 flack