Provides a function that calculates a new due date.
NB: this controller differs from the one on the client side!
- Version:
-
- 1.0
Methods
-
<inner> convertArrayIntoMatrix(array:, cols:)
-
Given an array and x columns, convert that array into a matrix of x columns
Parameters:
Name Type Description array:
Array.<Object> array of any types cols:
integer number of columns in the matrix Returns:
-
<inner> generateCalendarArr(daysFromPrevMonth:, prevMonthLastDay:, daysInCurrentMonth:)
-
Take a date as parameter and generate an array of days so that all the days from the current month are contained, plus last (prevMonthLastDay - daysFromPrevMonth) days from the previous month at the beginning of the array, and the first ones from the next at the bottom to make the array size % (#days in a week) = 0.
Parameters:
Name Type Description daysFromPrevMonth:
integer number of days from the previous month to be put at the beginning of the array. prevMonthLastDay:
integer last day of the previous month (eg. January last day = 31). daysInCurrentMonth:
integer last day of the current month (eg. ) -
<inner> getCalendar(date:)
-
Take a date as parameter and generate an array of arrays of days so that all the days from the specified year and month are contained in the matrix. The index of each array can be considered as the day (0 -> Sunday, 1 -> Monday etc.) and no cell is ever empty, so in case a month starts from Friday and ends on Monday, the remaining cells are filled in with, respectively, the last days from the previous month and the first ones from the next.
Parameters:
Name Type Description date:
Date date to be converted into a matrix Returns:
-
<inner> getDateOfFirstDayOf(year:, month:)
-
Given a month and a year return the date of the first day (Sunday = 0, Monday = 1 etc.)
Parameters:
Name Type Description year:
integer year month:
integer month Returns:
The date of the first day- Type
- integer
-
<inner> getDaysInMonth(year:, month:)
-
Given a month and a year, return the number of days.
Parameters:
Name Type Description year:
integer year month:
integer month Returns:
The number of days in that month for that year- Type
- integer
-
<inner> getNextDueDate(frequency, startingDate)
-
Get the next date
Parameters:
Name Type Description frequency
string the frequency in the given format startingDate
date the starting date from which to calculate the next date Example
// returns Date object of value 2018-01-04T00:00:00.000Z getNextDate('3-D', new Date(2018, 0 , 1));
-
<inner> isHoliday(date)
-
Check if a date is a holiday in the UK
Parameters:
Name Type Description date
date the date to check -
<inner> isSelected(isFromThisMonth:, selectedDay:, currentDate:, day:)
-
Return True if the day is selected
Parameters:
Name Type Description isFromThisMonth:
boolean the day belongs to the current month. selectedDay:
string the selected day in the form yyyy-(m)m-(d)d currentDate:
Date the date displayed on the header of the the calendar day:
integer the number of the day contained in this DayCell Returns:
True if the day is selected, False otherwise- Type
- boolean
-
<inner> isWeekend(date)
-
Check if the date falls on Saturday or Sunday.
Parameters:
Name Type Description date
date The date to check. Returns:
True if date is on weekend, false otherwise.- Type
- boolean
-
<inner> selectedDayIsFromCurrentMonth(selectedDate:, currentDate:)
-
Return True if the selected date is in the days of the calendar belonging to the current month
Parameters:
Name Type Description selectedDate:
string the selected day in the form yyyy-(m)m-(d)d currentDate:
Date the date displayed on the header of the the calendar Returns:
True iff the day appears in the calendar table and belongs to the current month, otherwise False- Type
- boolean
-
<inner> selectedDayIsFromNextMonth(selectedDate:, currentDate:, day:)
-
Return True if the selected date is in the days of the calendar belonging to the next month
Parameters:
Name Type Description selectedDate:
string the selected day in the form yyyy-(m)m-(d)d currentDate:
Date the date displayed on the header of the the calendar day:
integer the number of the day contained in this DayCell Returns:
True iff the day appears in the calendar table and belongs to the next month, otherwise False- Type
- boolean
-
<inner> selectedDayIsFromPreviousMonth(selectedDate:, currentDate:, day:)
-
Return True if the selected date is in the days of the calendar belonging to the previous month
Parameters:
Name Type Description selectedDate:
string the selected day in the form yyyy-(m)m-(d)d currentDate:
Date the date displayed on the header of the the calendar day:
integer the number of the day contained in this DayCell Returns:
True iff the day appears in the calendar table and belongs to the previous month, otherwise False- Type
- boolean
-
<inner> stringIsInteger(str)
-
Check if given string is an integer
Parameters:
Name Type Description str
string Returns:
true if string is an integer- Type
- boolean