Class: DateCalculator

DateCalculator

This class handles the date-related calculations for the GanttChart plugin.

Members

allowSplitWeeks

The current allowSplitWeeks option state.

daysInColumnsObject

Object containing references to the year days and their corresponding columns.

firstWeekDayString

First day of the week.

hideDaysAfterFullWeeks

The current hideDaysAfterFullWeeks option state.

hideDaysBeforeFullWeeks

The current hideDaysBeforeFullWeeks option state.

monthListCacheObject

Cache of lists of months and their week/day related information.
It's categorized by year, so month information for a certain year is stored under this.monthListCache[year].

weekSectionCountNumber

Number of week sections (full weeks + incomplete week blocks in months).

yearNumber

Year to base calculations on.

Methods

calculateMonthData(year){Array}

Calculate the month/day related information.

Parameters:
Name Type Description
year Number optional

Year to be used.

Returns: {Array}

columnToDate(column, year){Object}

Convert a column index to a certain date.

Parameters:
Name Type Description
column Number

Column index.

year Number optional

Year to be used.

Returns: {Object} Object in a form of {start: startDate, end: endDate}

countMonthDays(month, year){Number}

Count days in a month.

Parameters:
Name Type Description
month Number

Month index, where January = 1, February = 2, etc.

year Number optional

Year to be used.

Returns: {Number}

countMonthFullWeeks(month, year){Number}

Count full weeks in a month.

Parameters:
Name Type Description
month Number

Month index, where January = 1, February = 2, etc.

year Number optional

Year to be used.

Returns: {Number}

countMonths(year){Number}

Count the number of months.

Parameters:
Name Type Description
year Number optional

Year to be used.

Returns: {Number}

countWeekSections(){Number}

Count week sections (full weeks + incomplete weeks in the months).

Returns: {Number} Week section count.

dateToColumn(date){Number|Boolean}

Convert a date to a column number.

Parameters:
Name Type Description
date String | Date
Returns: {Number|Boolean}

getFirstWeekDay(){String}

Get the first week day.

Returns: {String}

getFullMonthList(){Object}

Get month lists for all years declared in the range bars.

Returns: {Object}

getMonthList(year){Array}

Get month list along with the month information.

Parameters:
Name Type Description
year Number optional

Year for the calculation.

Returns: {Array}

getYear(){Number}

Get the currently applied year.

Returns: {Number}

isValidRangeBarData(startDate, endDate){Boolean}

Check if the provided dates can be used in a range bar.

Parameters:
Name Type Description
startDate Date | String

Range start date.

endDate Date | String

Range end date.

Returns: {Boolean}

setFirstWeekDay(day)

Set the first week day.

Parameters:
Name Type Description
day String

Day of the week. Available options: 'monday' or 'sunday'.

setYear(year)

Set the year as a base for calculations.

Parameters:
Name Type Description
year Number