Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with interval difference #76

Closed
malcolmsparks opened this issue Jan 23, 2020 · 5 comments · Fixed by #77
Closed

Bug with interval difference #76

malcolmsparks opened this issue Jan 23, 2020 · 5 comments · Fixed by #77

Comments

@malcolmsparks
Copy link
Contributor

(t/difference
 [(t/new-interval (t/in (t/date-time "2020-02-01T00:00") juxt.time/LONDON)
                  (t/in (t/date-time "2020-02-02T00:00") juxt.time/LONDON))
  (t/new-interval (t/in (t/date-time "2020-02-02T00:00") juxt.time/LONDON)
                  (t/in (t/date-time "2020-02-03T00:00") juxt.time/LONDON))
  (t/new-interval (t/in (t/date-time "2020-02-03T00:00") juxt.time/LONDON)
                  (t/in (t/date-time "2020-02-04T00:00") juxt.time/LONDON))
  ]
 [
  (t/new-interval (t/in (t/date-time "2020-02-01T12:00") juxt.time/LONDON)
                  (t/in (t/date-time "2020-02-03T12:00") juxt.time/LONDON))
  ]
 
 )

gives

(#:tick{:beginning
        #time/zoned-date-time "2020-02-01T00:00Z[Europe/London]",
        :end
        #time/zoned-date-time "2020-02-01T12:00Z[Europe/London]"}
 #:tick{:beginning
        #time/zoned-date-time "2020-02-03T00:00Z[Europe/London]",
        :end
        #time/zoned-date-time "2020-02-04T00:00Z[Europe/London]"})
@t-taylor
Copy link
Contributor

t-taylor commented Jan 27, 2020

(t/difference
  [(t/new-interval (t/date-time "2020-02-01T00:00")
                   (t/date-time "2020-02-02T00:00"))]
  [(t/new-interval (t/date-time "2020-02-01T00:00")
                   (t/date-time "2020-02-02T12:00"))])

returns

;; => ()

@t-taylor
Copy link
Contributor

t-taylor commented Jan 27, 2020

;; X |-------------------|
;; Y |----------|
;; should be :started-by, return :starts
(t/relation
  (t/new-interval (t/date-time "2020-02-01T00:00")
                  (t/date-time "2020-02-02T00:00"))
  (t/new-interval (t/date-time "2020-02-01T00:00")
                  (t/date-time "2020-02-02T12:00")))

@malcolmsparks
Copy link
Contributor Author

Very nice spot! If you have time, please send on a PR. This bug has derailed some time calculation I wanted to complete.

@t-taylor
Copy link
Contributor

This isn't right actually :/ the example has a typo on the 2nd interval, so Y ends later than X. This part works correctly. It is to do with chuncking the intervals instead

@t-taylor
Copy link
Contributor

t-taylor commented Jan 29, 2020

;; X     |-----|-----|
;; Y  |-----------|
;;=>           |-----|
;; (broken)
(t/difference
  [(t/new-interval (t/date-time "2020-02-02T00:00")
                   (t/date-time "2020-02-03T00:00"))
   (t/new-interval (t/date-time "2020-02-03T00:00")
                   (t/date-time "2020-02-04T00:00"))]
  [(t/new-interval (t/date-time "2020-02-01T00:00")
                   (t/date-time "2020-02-03T12:00"))])

;; X     |-----|-----|
;; Y     |--------|
;;=>              |--|
;; (works)
(t/difference
  [(t/new-interval (t/date-time "2020-02-02T00:00")
                   (t/date-time "2020-02-03T00:00"))
   (t/new-interval (t/date-time "2020-02-03T00:00")
                   (t/date-time "2020-02-04T00:00"))]
  [(t/new-interval (t/date-time "2020-02-02T00:00")
                   (t/date-time "2020-02-03T12:00"))])

;; Seems problem is when a :during is followed by a :overlapped-by

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants