Search Results for

    Show / Hide Table of Contents

    Class MultiDuration

    Represents a set of durations that belong to this time span. Durations may overlap and can be explicitly flattened if required.

    Inheritance
    System.Object
    MultiDuration
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: TimeCockpit.Data.DataModel
    Assembly: TimeCockpit.Data.dll
    Syntax
    public class MultiDuration

    Constructors

    MultiDuration(IEnumerable<IDuration>)

    Initializes a new instance of the MultiDuration class.

    Declaration
    public MultiDuration(IEnumerable<IDuration> parts)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<IDuration> parts

    duration parts of the new multiduration.

    MultiDuration(IEnumerable<MultiDuration>)

    Initializes a new instance of the MultiDuration class by unionizing the given durations.

    Declaration
    public MultiDuration(IEnumerable<MultiDuration> durations)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<MultiDuration> durations

    duration parts of the new multiduration.

    MultiDuration(DateTime, DateTime)

    Initializes a new instance of the MultiDuration class. Shorthand version for a single duration.

    Declaration
    public MultiDuration(DateTime beginTime, DateTime endTime)
    Parameters
    Type Name Description
    System.DateTime beginTime

    begin time stamp of the duration.

    System.DateTime endTime

    end time stamp of the duration.

    Properties

    Durations

    Gets the durations of this multi-duration.

    Declaration
    public IEnumerable<IDuration> Durations { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<IDuration>

    EarliestBegin

    Gets the earliest begin time

    Declaration
    public DateTime EarliestBegin { get; }
    Property Value
    Type Description
    System.DateTime

    Flat

    Gets a value indicating whether none of the durations overlap.

    Declaration
    public bool Flat { get; }
    Property Value
    Type Description
    System.Boolean

    LatestEnd

    Gets the latest end time.

    Declaration
    public DateTime LatestEnd { get; }
    Property Value
    Type Description
    System.DateTime

    TotalTime

    Gets the total time / sum of the multi duration. Be aware that overlapping times are included in the calculation. Use Flatten before TotalTime if it is required that overlapping times are counted only once.

    Declaration
    public TimeSpan TotalTime { get; }
    Property Value
    Type Description
    System.TimeSpan

    Methods

    And(MultiDuration)

    Logical 'and' operation between this and another multi-duration.

    Declaration
    public MultiDuration And(MultiDuration other)
    Parameters
    Type Name Description
    MultiDuration other

    Other multi-duration.

    Returns
    Type Description
    MultiDuration

    Logical 'and' between this and another multi-duration.

    Cut(MultiDuration)

    cuts another multi duration by this multi duration. logical "this AND source" result does not contain elements of 0 duration

    Declaration
    [Obsolete("Use MultiDuration.And instead. Cut does not offer consistent naming compared to 'and', 'or' and 'subtract'.")]
    public MultiDuration Cut(MultiDuration source)
    Parameters
    Type Name Description
    MultiDuration source

    Source duration to cut agains this multi duration.

    Returns
    Type Description
    MultiDuration

    a new multiduration containing the source multiduration cut by this multiduration.

    Flatten()

    By default, multiple durations might overlap. the flatten method modifies the durations to not overlap and turns two overlapping durations into a single duration.

    Declaration
    public void Flatten()

    Intersects(DateTime, DateTime)

    Checks whether a given duration intersects with any of the durations.

    Declaration
    public bool Intersects(DateTime begin, DateTime end)
    Parameters
    Type Name Description
    System.DateTime begin

    begin of duration to check

    System.DateTime end

    end of duration to check

    Returns
    Type Description
    System.Boolean

    true if duration intersects

    Intersects(IDuration)

    Checks whether a given duration intersects with any of the durations.

    Declaration
    public bool Intersects(IDuration duration)
    Parameters
    Type Name Description
    IDuration duration

    duration to check

    Returns
    Type Description
    System.Boolean

    true if duration intersects

    IsInside(DateTime)

    checks whether a given timeStamp is within (or on the border of) any of the durations.

    Declaration
    public bool IsInside(DateTime timeStamp)
    Parameters
    Type Name Description
    System.DateTime timeStamp

    time stamp to check against multi duration.

    Returns
    Type Description
    System.Boolean

    Returns true if timeStamp is within any duration.

    Or(MultiDuration)

    Logical 'or' operation between this and another multi-duration.

    Declaration
    public MultiDuration Or(MultiDuration other)
    Parameters
    Type Name Description
    MultiDuration other

    Other multi-duration.

    Returns
    Type Description
    MultiDuration

    Logical 'or' between this and another multi-duration.

    Subtract(MultiDuration)

    Logically subtract another multi-duration from this one.

    Declaration
    public MultiDuration Subtract(MultiDuration other)
    Parameters
    Type Name Description
    MultiDuration other

    Other multi-duration.

    Returns
    Type Description
    MultiDuration

    Subraction result

    In This Article
    Back to top Copyright © 2020 software architects gmbh