DateUtils API
Set of functions useful to work with dates and modifiers.
import { DateUtils } from "react-day-picker";
Functions
addDayToRange (day: Date, range: ?Object<from: ?Date, to: ?Date>) ⇒ Object<from: ?Date, to: ?Date>
Add day
to a range of days, returning a new range including that day. A range is an object with from
and to
keys. See the range example for an example using this function.
import { DateUtils } from "react-day-picker";
const range = {
from: new Date(2015, 5, 14),
to: new Date(2015, 5, 18)
}
const newRange = DateUtils.addDayToRange(new Date(2015, 5, 24), range);
console.log(newRange.to) // 2015-05-24
addMonths (date: Date, n: number) ⇒ Date
Return date
as a new Date with n
months added. Missing days will be added to the final date, e.g. 2016-03-31 + 1 month = 2016-05-01
(since the 31th of April is missing).
clone (date: date) ⇒ Date
Clone date
returning a new Date with the same time.
isDate (value) ⇒ Boolean
Returns true
if value
is a valid Javascript Date.
isDayAfter (day1: Date, day2: Date) ⇒ boolean
Return true
if day1
is after day2
.
isDayBefore (day1: Date, day2: Date) ⇒ boolean
Return true
if day1
is before day2
.
isDayBetween (day: Date, day1: Date, day2: Date) ⇒ boolean
Returns true
if day
is between day1
and day2
, without including those days.
isDayInRange (day: Date, range: Object<from: ?Date, to: ?Date>) ⇒ boolean
Returns true
if day
is included in the specified range of days.
isFutureDay (day: Date) ⇒ boolean
Return true
if day
is in the future, i.e. is tomorrow or any day after tomorrow.
isPastDay (day: Date) ⇒ boolean
Return true
if day
is in the past, i.e. is yesterday or any day before yesterday.
isSameDay (day1: ?Date, day2: ?Date) ⇒ boolean
Return true
if day1
andday2
are the same day.
isSameMonth (day1: ?Date, day2: ?Date) ⇒ boolean
Return true
if day1
andday2
fall in the same month.