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.

[Interval] inclusion partially works when check if a date is between two others date

See original GitHub issue

Describe the bug Coming from momentjs… When using luxon’s Interval class to check if date is between two others, I get unexpected behavior.

To Reproduce Here is code: image

Actual vs Expected behavior Actually test (2021-01-01) return correctly “true” Second test(2021-06-30) return “false” while I expect “true”

Desktop (please complete the following information):

  • OS: windows
  • Browser Version 96.0.4664.110 (Build officiel) (64 bits)
  • Luxon version ^2.2.0
  • Your timezone fr

Additional context Start of 2.13.0 momentjs introduced inclusivity. I could do what i need with inlusivity = '[]'

Am i using it wrongly ? Thanks

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
icambroncommented, Dec 31, 2021

Luxon intervals are half-open, so like inclusivity=[). There is currently no way to change that, besides adding a millisecond to the end

0reactions
icambroncommented, Feb 23, 2022

@elvisbegovic Most applications want half-open intervals. If I want to represent “today”, then I mean from 00:00:00.000 through 23:59:59.999. But I don’t want to say that. I want to say “00:00:00 today to 00:00:00”. E.g.:

Interval.fromDateTimes(
  DateTime.fromISO("2020-11-16"),
  DateTime.fromISO("2020-11-17"))

So we do that that half-open. This is the standard default for time intervals across most of the libraries I’ve used. If you want to include the endtime, do what @RemWisteria is doing.

By adding inclusivity param or create another method

It would require that every method in Interval check that parameter

Read more comments on GitHub >

github_iconTop Results From Across the Web

Determine Whether Two Date Ranges Overlap - Stack Overflow
(If one range is neither completely after the other, nor completely before the other, then they must overlap.) Now one of De Morgan's...
Read more >
Does a date (or interval) fall within an interval? - lubridate
Check whether a lies within the interval b, inclusive of the endpoints.
Read more >
Check IF a Date is Between Two Given Dates in Excel (Easy ...
Data analysis in Excel often involves working with dates. ... In this tutorial, I will show you how to check if the date...
Read more >
Excel DATE function with formula examples to calculate dates
The tutorial explains the syntax and uses of the Excel DATE function and provides formula examples for calculating dates.
Read more >
Test if two date ranges overlap in Ruby or Rails - makandra dev
The code below shows how to implement this in Ruby on Rails. The example is a class Interval , which has two attributes...
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