# Implementing a zero width type for IntervalSets

**URL:** https://discourse.julialang.org/t/implementing-a-zero-width-type-for-intervalsets/23444
**Category:** General Usage
**Tags:** question
**Created:** [April 23, 2019, 2:09pm UTC](https://discourse.julialang.org/t/implementing-a-zero-width-type-for-intervalsets/23444 "2019-04-23T14:09:43Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [April 24, 2019, 7:39am UTC](https://discourse.julialang.org/t/implementing-a-zero-width-type-for-intervalsets/23444/3 "2019-04-24T07:39:26Z")

</div>

Very cool, thank you, but, why are the arguments of `duration` limited to integers and dates…? Wouldn’t it be better to define it along similar lines to the implementation of `width`:

```julia
function duration(A::AbstractInterval)
    _width = rightendpoint(A) - leftendpoint(A)
    max(zero(_width), _width + oneunit(_width)) # this works when T is a Date
end

```

This way it should work with _any_ typed interval.

---

_[View the full topic](https://discourse.julialang.org/t/implementing-a-zero-width-type-for-intervalsets/23444)._
