Skip to content

Allow union to merge adjacent spans #14

@cfwdman

Description

@cfwdman

Observed Behaviour

Using two datespans:
span1: date1, 11:00 - 12:00 (duration: 60 Minutes) and
span1: date1, 12:00 - 13:00

the union of such ranges is always null.
span3 = span1.union(span2); // null

Expected Behaviour

The union of such ranges "in many usecases" - e.g. merging the freebusytimes of an exchange server -
should be
r3: date 1, 11:00 - 13:00
It might be helpful to have a flag "mergeAdjacent" which can be set to true/false.
when set to true r3 shall be created if set to false r3 shall be null.
see .e.g. moment-range - npm - https://www.npmjs.com/package/moment-range#add

Steps to Reproduce

var currentStartDate = new Date(2021, 02, 20, 11, 0, 0, 0);
let intervalMinutes = 60
let span1 = myDateSpanCTor(currentStartDate, null, intervalMinutes, 0, 0)
currentStartDate = new Date(currentStartDate.getTime() + intervalMinutes * 60000)
let span2 = myDateSpanCTor(currentStartDate, null, intervalMinutes, 0, 0)
span3 = span1.union(span2); // null instead of

System Configuration

caltime version: 1.4.5
Node.js version: 15.8.0
NPM version: 7.5.4
lodash version: ./.
moment-timezone version: ./.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions