Options
All
  • Public
  • Public/Protected
  • All
Menu

A class for a range of time between two Day timestamps.

Hierarchy

  • DaySpan

Index

Constructors

constructor

  • Creates a new span of time.

    Parameters

    • start: Day

      The starting timestamp.

    • end: Day

      The ending timestamp.

    Returns DaySpan

Properties

end

end: Day

The endind timestamp of the span (inclusive).

start

start: Day

The starting timestamp of the span (inclusive).

Accessors

isPoint

isPoint:

Whether this span starts and ends on the same timestamp.

Methods

compareTo

  • compareTo(day: Day): number
  • Compares the given timestamp to this span. If the timestamp is before this span then -1 is returned, if the timestamp is after this span then 1 us returned, otherwise 0 is returned when the timestamp is in this span.

    Parameters

    • day: Day

      The timestamp to compare to.

    Returns number

    -1, 0, or 1 depending on the given timestamp relative to this span.

contains

  • contains(day: Day): boolean
  • Determines whether the given timestamp lies between the start and end timestamp.

    Parameters

    • day: Day

      The timestamp to test.

    Returns boolean

    True if the day is >= the start and <= the end of this span.

days

  • days(op?: Op, absolute?: boolean): number
  • Calculates the number of days between the start and end timestamp.

    see

    Day.daysBetween

    Parameters

    • Default value op: Op = Op.DOWN

      The operation to perform on the result.

    • Default value absolute: boolean = true

      Whether the result should always be positive.

    Returns number

    The time between the start and end timestamp.

endDelta

  • endDelta(relativeTo: Day): number
  • Returns a delta value between 0 and 1 which represents where the DaySpan.end is relative to the given day. The delta value would be greater than 1 if the end of the event is after the given day.

    Parameters

    • relativeTo: Day

      The day to find the end delta relative to.

    Returns number

    A number between 0 and 1 if the end of this span is in the 24-hour period starting at the given timestamp, otherwise the value returned may be less than 0 or greater than 1.

getBounds

  • getBounds(relativeTo: Day, dayHeight?: number, dayWidth?: number, columnOffset?: number, clip?: boolean, offsetX?: number, offsetY?: number): DaySpanBounds
  • Calculates the bounds for span event if it were placed in a rectangle which represents a day (24 hour period). By default the returned values are between 0 and 1 and can be scaled by the proper rectangle dimensions or the rectangle dimensions can be passed to this function.

    Parameters

    • relativeTo: Day

      The day to find the bounds relative to. If this is not the start of the day the returned bounds is relative to the given time.

    • Default value dayHeight: number = 1

      The height of the rectangle of the day.

    • Default value dayWidth: number = 1

      The width of the rectangle of the day.

    • Default value columnOffset: number = 0

      The offset in the rectangle of the day to adjust this span by. This also reduces the width of the returned bounds to keep the bounds in the rectangle of the day.

    • Default value clip: boolean = true

      true if the bounds should stay in the day rectangle, false and the bounds may go outside the rectangle of the day for multi-day spans.

    • Default value offsetX: number = 0

      How much to translate the left & right properties by.

    • Default value offsetY: number = 0

      How much to translate the top & bottom properties by.

    Returns DaySpanBounds

    The calculated bounds for this span.

hours

  • hours(op?: Op, absolute?: boolean): number
  • Calculates the number of hours between the start and end timestamp.

    see

    Day.hoursBetween

    Parameters

    • Default value op: Op = Op.DOWN

      The operation to perform on the result.

    • Default value absolute: boolean = true

      Whether the result should always be positive.

    Returns number

    The time between the start and end timestamp.

intersection

  • Calculates the intersection between this span and the given span. If there is no intersection between the two spans then null is returned.

    Parameters

    • span: DaySpan

      The span to calculate the intersection with.

    Returns DaySpan

    The intersection or null if none exists.

intersects

  • intersects(span: DaySpan): boolean
  • Determines whether the gven span intersects with this span.

    Parameters

    Returns boolean

    true if the spans intersect, otherwise false.

matchesDay

  • matchesDay(day: Day): boolean
  • Determines whether the given timestamp is between the start and end timestamp or lies on the same day as the start or end timestamp.

    see

    Day.sameDay

    Parameters

    • day: Day

      The timestamp to test.

    Returns boolean

matchesMonth

  • matchesMonth(day: Day): boolean
  • Determines whether the given timestamp is between the start and end timestamp or lies on the same month as the start or end timestamp.

    see

    Day.sameMonth

    Parameters

    • day: Day

      The timestamp to test.

    Returns boolean

matchesWeek

  • matchesWeek(day: Day): boolean
  • Determines whether the given timestamp is between the start and end timestamp or lies on the same week as the start or end timestamp.

    see

    Day.sameWeek

    Parameters

    • day: Day

      The timestamp to test.

    Returns boolean

matchesYear

  • matchesYear(day: Day): boolean
  • Determines whether the given timestamp is between the start and end timestamp or lies on the same year as the start or end timestamp.

    see

    Day.sameYear

    Parameters

    • day: Day

      The timestamp to test.

    Returns boolean

millis

  • millis(op?: Op, absolute?: boolean): number
  • Calculates the number of milliseconds between the start and end timestamp.

    see

    Day.millisBetween

    Parameters

    • Default value op: Op = Op.DOWN

      The operation to perform on the result.

    • Default value absolute: boolean = true

      Whether the result should always be positive.

    Returns number

    The time between the start and end timestamp.

minutes

  • minutes(op?: Op, absolute?: boolean): number
  • Calculates the number of minutes between the start and end timestamp.

    see

    Day.minutesBetween

    Parameters

    • Default value op: Op = Op.DOWN

      The operation to perform on the result.

    • Default value absolute: boolean = true

      Whether the result should always be positive.

    Returns number

    The time between the start and end timestamp.

months

  • months(op?: Op, absolute?: boolean): number
  • Calculates the number of months between the start and end timestamp.

    see

    Day.monthsBetween

    Parameters

    • Default value op: Op = Op.DOWN

      The operation to perform on the result.

    • Default value absolute: boolean = true

      Whether the result should always be positive.

    Returns number

    The time between the start and end timestamp.

seconds

  • seconds(op?: Op, absolute?: boolean): number
  • Calculates the number of seconds between the start and end timestamp.

    see

    Day.secondsBetween

    Parameters

    • Default value op: Op = Op.DOWN

      The operation to perform on the result.

    • Default value absolute: boolean = true

      Whether the result should always be positive.

    Returns number

    The time between the start and end timestamp.

startDelta

  • startDelta(relativeTo: Day): number
  • Returns a delta value between 0 and 1 which represents where the DaySpan.start is relative to the given day. The delta value would be less than 0 if the start of the event is before the given day.

    Parameters

    • relativeTo: Day

      The day to find the start delta relative to.

    Returns number

    A number between 0 and 1 if the start of this span is in the 24-hour period starting at the given timestamp, otherwise the value returned may be less than 0 or greater than 1.

summary

  • summary(type: Units, dayOfWeek?: boolean, short?: boolean, repeat?: boolean, contextual?: boolean, delimiter?: string): string
  • Summarizes this span given an approximate unit of time and a few other options. If the start and end are on the same unit, a single value will be returned. Otherwise a start and end will be returned with a delimiter.

    Parameters

    • type: Units

      The unit of time this span is for.

    • Default value dayOfWeek: boolean = true

      When true the weekday of the start and end are included.

    • Default value short: boolean = false

      When true the short form of weekdays and months will be used.

    • Default value repeat: boolean = false

      When true the year will be repeated on the start and end timestamp even if they are the same year.

    • Default value contextual: boolean = true

      When true the year will be hidden if it's the current year.

    • Default value delimiter: string = " - "

      The string to separate the start and end timestamps with.

    Returns string

    The summary of this span.

union

  • Calculates the union between this span and the given span.

    Parameters

    • span: DaySpan

      The span to calculate the union with.

    Returns DaySpan

    The union of the two spans.

weeks

  • weeks(op?: Op, absolute?: boolean): number
  • Calculates the number of weeks between the start and end timestamp.

    see

    Day.weeksBetween

    Parameters

    • Default value op: Op = Op.DOWN

      The operation to perform on the result.

    • Default value absolute: boolean = true

      Whether the result should always be positive.

    Returns number

    The time between the start and end timestamp.

years

  • years(op?: Op, absolute?: boolean): number
  • Calculates the number of years between the start and end timestamp.

    see

    Day.yearsBetween

    Parameters

    • Default value op: Op = Op.DOWN

      The operation to perform on the result.

    • Default value absolute: boolean = true

      Whether the result should always be positive.

    Returns number

    The time between the start and end timestamp.

Static point

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc