bevacqua / rome

:calendar: Customizable date (and time) picker. Opt-in UI, no jQuery!
https://bevacqua.github.io/rome
MIT License
2.91k stars 223 forks source link

Why isn't same day min/max allowed? #182

Open Voyz opened 7 years ago

Voyz commented 7 years ago

I understand the purpose of rome.js / calendar selector is to select from within a range of days, and having only one day as an option makes the widget useless.

However, the problem I'm running into is that same Moment object can be used for rome.js and for time (hour/minute/etc.) selector. In such case the selection may sometimes be limited to one day, eg. between 8am and 11am. Rome.js will disallow such limits and forces me to duplicate one of the limit moments and move it by one day, in the end displaying an incorrect range to the user.

Lines 5085- 5087

if (o.max.clone().subtract(1, 'days').isBefore(o.min)) {
  throw new Error('`max` must be at least one day after `min`');
}

My question is: Is there anything really stopping rome.js from displaying only one day?

MikesGlitch commented 3 years ago

I'm running into this issue as well - I'm trying to show only one day.

My situation is it's two date selectors that are ideally 28 days apart. In certain situations that wont be possible (like if there are only 2 days between the start and now), so I want to lock them in to that one day for the start date so the chart shows as close to 28 days of data as possible.