# Dates with ranges and intervals

**URL:** <https://discourse.julialang.org/t/dates-with-ranges-and-intervals/5573>\
**Category:** General Usage\
**Created:** [August 26, 2017, 11:52am UTC](https://discourse.julialang.org/t/dates-with-ranges-and-intervals/5573 "2017-08-26T11:52:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin\_Beckingham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/colin_beckingham/32/4878_2.png) [@Colin\_Beckingham](https://discourse.julialang.org/u/Colin_Beckingham)\
**Post date:** [August 26, 2017, 11:52am UTC](https://discourse.julialang.org/t/dates-with-ranges-and-intervals/5573/1 "2017-08-26T11:52:48Z")

</div>

I’m considering an issue where all the elements are time stamps. An array of these elements can contain a single time stamp, an array, a range, an interval or combination of these. By range I intend a construction using such as collect(range(,)) which produces an array of discrete items, and by interval I intend a 2-something containing a lower and upper bound, indicating all values on the real line between the two bounds.

My thoughts so far are that if I indicate an interval as a 2-tuple then in a given mixed array I can distinguish a bounded interval from a 2-array based on its type. Just wondering if there has been prior thinking of this issue, and what the true Julia approach would be?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [August 26, 2017, 1:00pm UTC](https://discourse.julialang.org/t/dates-with-ranges-and-intervals/5573/2 "2017-08-26T13:00:07Z")

</div>

Hard to say but I believe a “true Julian approach” would think of a single time stamp, and an AbstractVector (array, range, interval) of timestamps as two different things, though your array could support both if needed. Have a look at TimeSeries.jl for a nice package working with times.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [August 26, 2017, 4:30pm UTC](https://discourse.julialang.org/t/dates-with-ranges-and-intervals/5573/3 "2017-08-26T16:30:56Z")

</div>

[IntervalSets.jl](https://github.com/JuliaMath/IntervalSets.jl) might be useful?

---

<div class="post-metadata">

**Author:** ![Colin\_Beckingham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/colin_beckingham/32/4878_2.png) [@Colin\_Beckingham](https://discourse.julialang.org/u/Colin_Beckingham)\
**Post date:** [August 28, 2017, 12:11pm UTC](https://discourse.julialang.org/t/dates-with-ranges-and-intervals/5573/4 "2017-08-28T12:11:16Z")

</div>

Yes, Tim, very apposite, good call. I was concerned about the treatment of unions of disjoint intervals for my purposes, but I see there has been previous discussion on this on GitHub and will try to catch up. At least the type definitions and basic ops will be very useful.
