question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Only display 1 date when same start and end date is the same

See original GitHub issue

This might already be a feature that is supported, but I didn’t find any information on it.

When using one element and range picker, the output will be more clear if it only shows one date without a delimiter, when 1 day is selected. Now it shows YYYY-MM-DD - YYYY-MM-DD when YYYY-MM-DD === YYYY-MM-DD. It would be nice to be able to show YYYY-MM-DD when the same day is selected for start and end date.

Describe alternatives you’ve considered I’ve havent found a quick work around for this yet, but would love to see suggestions. I was thinking something like this:

picker.on('selected', (date1, date2) => {
  if(date1.dateInstance === date2.dateInstance) {
    pickerInput.value = date1.howToOutPutSelectedFormat();
  }
});

But are a bit unsure how I can output the date in the format set for the picker…

Additional context Great library btw! It’s the best JS datepicker I’ve tried so far in my 11 years as a developer 🖤

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wakirincommented, Feb 14, 2021

You can do something like that:

https://jsfiddle.net/4dkocgjz/

Sorry, I do not plan include it in the core.

0reactions
lassemtcommented, Feb 14, 2021

You can do something like that:

https://jsfiddle.net/4dkocgjz/

Sorry, I do not plan include it in the core.

Ah yeah, that is definitly a better workaround than using setTimeout on deplaying value change. That will work for now, but I still believe this is more of a hack than a solution. The reason why I think it would be good to display one day instead of same day in range is that YYYY-MM-DD - YYYY-MM-DD when it’s the same date, is a bit weird from a reading persepctive. So it would be an ehancement.

Anyway, this works. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Date-only range, show only start date [#3279076] | Drupal.org
I am using the "smartdate_only" widget, which delivers the date-only field. But it does show the end date. There is an widget setting...
Read more >
Generate Dates between Start and End Date in Power Query
My Courses - - - -✔️ Mastering DAX in Power BI -https://goodly.co.in/learn-dax-powerbi/✔️ Power Query ...
Read more >
DAX and the Start Date End Date Problem aka Events In ...
Calculating the number of people present or processes running at the end of the data or during the month is tricky and requires...
Read more >
How to extract data between a date range which has only start ...
Something along these lines should work, I believe: SELECT item_ID FROM my_table WHERE item_active_date <= $endDate AND (item_inactive_date ...
Read more >
Show the end date only if end date (not end time) is different ...
I need to display the dates for events in this format: “1 Oct” for a single day event and “1 to 2 Oct”...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found