From 09e44d625e69a7d5ab5a498c51f14d3cba3fb6ee Mon Sep 17 00:00:00 2001 From: Lesha Koss Date: Thu, 6 Apr 2017 13:58:42 +0700 Subject: [PATCH] Fix corner cases (#460) * Invalid Date tests for `addX`, `setX` and `subX` * Invalid Date tests for `getX` * Invalid Date tests for `startOfX`, `endOfX` and `lastDayOfX` * Invalid Date tests for `isSameX` * Invalid Date tests for `differenceInX` * `isX(new Date(NaN))` tests * `isAfter`, `isBefore` and `isEqual` Invalid Date tests * Interval functions Invalid Date tests * `compareAsc` and `compareDesc` Invalid Date tests * `closestTo`, `closestIndexTo`, `max` and `min` Invalid Date tests * Test `toDate` if `options.additionalDigits` is not 0, 1, 2 or undefined * Test `parse` if baseDate is `Invalid Date` * `distanceInWords` and `distanceInWordsStrict` invalid values tests * Invalid `options.weekStartsOn` tests * Invalid value implementation fixes * `parse` implementation fix * `weekStartsOn` implementation fix * Rename `partialMethod` to `roundingMethod` * `distanceInWordsStrict` implementation fix * Rebuild typings * `toDate` implementation fix * Add CHANGELOG.md entry * Add missing tests * Make interval functions throw RangeError * Fix @throws docs messages * Add `@throws {RangeError}` to all functions docs * Add `@param [options.additionalDigits]` to all functions docs * Add `options.additionalDigits` tests to all functions * Complete corner cases changelog entry * Add missing `$ExpectedMistake` --- CHANGELOG.md | 43 ++++++++++- docs/Options.js | 16 ++++- src/addDays/index.js | 2 + src/addDays/index.js.flow | 4 +- src/addDays/test.js | 16 +++++ src/addHours/index.js | 2 + src/addHours/index.js.flow | 4 +- src/addHours/test.js | 16 +++++ src/addISOYears/index.js | 2 + src/addISOYears/index.js.flow | 4 +- src/addISOYears/test.js | 16 +++++ src/addMilliseconds/index.js | 2 + src/addMilliseconds/index.js.flow | 4 +- src/addMilliseconds/test.js | 16 +++++ src/addMinutes/index.js | 2 + src/addMinutes/index.js.flow | 4 +- src/addMinutes/test.js | 16 +++++ src/addMonths/index.js | 2 + src/addMonths/index.js.flow | 4 +- src/addMonths/test.js | 16 +++++ src/addQuarters/index.js | 2 + src/addQuarters/index.js.flow | 4 +- src/addQuarters/test.js | 16 +++++ src/addSeconds/index.js | 2 + src/addSeconds/index.js.flow | 4 +- src/addSeconds/test.js | 16 +++++ src/addWeeks/index.js | 2 + src/addWeeks/index.js.flow | 4 +- src/addWeeks/test.js | 16 +++++ src/addYears/index.js | 2 + src/addYears/index.js.flow | 4 +- src/addYears/test.js | 16 +++++ src/areIntervalsOverlapping/index.js | 9 ++- src/areIntervalsOverlapping/index.js.flow | 4 +- src/areIntervalsOverlapping/test.js | 56 ++++++++++++++- src/closestIndexTo/index.js | 14 ++++ src/closestIndexTo/index.js.flow | 4 +- src/closestIndexTo/test.js | 40 +++++++++++ src/closestTo/index.js | 14 ++++ src/closestTo/index.js.flow | 4 +- src/closestTo/test.js | 50 +++++++++++++ src/compareAsc/index.js | 13 ++-- src/compareAsc/index.js.flow | 4 +- src/compareAsc/test.js | 35 +++++++++ src/compareDesc/index.js | 13 ++-- src/compareDesc/index.js.flow | 4 +- src/compareDesc/test.js | 35 +++++++++ src/differenceInCalendarDays/index.js | 2 + src/differenceInCalendarDays/index.js.flow | 4 +- src/differenceInCalendarDays/test.js | 35 +++++++++ src/differenceInCalendarISOWeeks/index.js | 2 + .../index.js.flow | 4 +- src/differenceInCalendarISOWeeks/test.js | 35 +++++++++ src/differenceInCalendarISOYears/index.js | 2 + .../index.js.flow | 4 +- src/differenceInCalendarISOYears/test.js | 35 +++++++++ src/differenceInCalendarMonths/index.js | 2 + src/differenceInCalendarMonths/index.js.flow | 4 +- src/differenceInCalendarMonths/test.js | 35 +++++++++ src/differenceInCalendarQuarters/index.js | 2 + .../index.js.flow | 4 +- src/differenceInCalendarQuarters/test.js | 35 +++++++++ src/differenceInCalendarWeeks/index.js | 5 +- src/differenceInCalendarWeeks/index.js.flow | 4 +- src/differenceInCalendarWeeks/test.js | 46 ++++++++++++ src/differenceInCalendarYears/index.js | 2 + src/differenceInCalendarYears/index.js.flow | 4 +- src/differenceInCalendarYears/test.js | 35 +++++++++ src/differenceInDays/index.js | 2 + src/differenceInDays/index.js.flow | 4 +- src/differenceInDays/test.js | 35 +++++++++ src/differenceInHours/index.js | 2 + src/differenceInHours/index.js.flow | 4 +- src/differenceInHours/test.js | 35 +++++++++ src/differenceInISOYears/index.js | 2 + src/differenceInISOYears/index.js.flow | 4 +- src/differenceInISOYears/test.js | 35 +++++++++ src/differenceInMilliseconds/index.js | 2 + src/differenceInMilliseconds/index.js.flow | 4 +- src/differenceInMilliseconds/test.js | 35 +++++++++ src/differenceInMinutes/index.js | 2 + src/differenceInMinutes/index.js.flow | 4 +- src/differenceInMinutes/test.js | 35 +++++++++ src/differenceInMonths/index.js | 2 + src/differenceInMonths/index.js.flow | 4 +- src/differenceInMonths/test.js | 35 +++++++++ src/differenceInQuarters/index.js | 2 + src/differenceInQuarters/index.js.flow | 4 +- src/differenceInQuarters/test.js | 35 +++++++++ src/differenceInSeconds/index.js | 2 + src/differenceInSeconds/index.js.flow | 4 +- src/differenceInSeconds/test.js | 35 +++++++++ src/differenceInWeeks/index.js | 2 + src/differenceInWeeks/index.js.flow | 4 +- src/differenceInWeeks/test.js | 35 +++++++++ src/differenceInYears/index.js | 2 + src/differenceInYears/index.js.flow | 4 +- src/differenceInYears/test.js | 35 +++++++++ src/distanceInWords/index.js | 6 ++ src/distanceInWords/index.js.flow | 4 +- src/distanceInWords/test.js | 35 +++++++++ src/distanceInWordsStrict/index.js | 47 ++++++++---- src/distanceInWordsStrict/index.js.flow | 4 +- src/distanceInWordsStrict/test.js | 71 +++++++++++++++++-- src/eachDayOfInterval/index.js | 10 ++- src/eachDayOfInterval/index.js.flow | 4 +- src/eachDayOfInterval/test.js | 33 ++++++++- src/endOfDay/index.js | 2 + src/endOfDay/index.js.flow | 4 +- src/endOfDay/test.js | 12 ++++ src/endOfHour/index.js | 2 + src/endOfHour/index.js.flow | 4 +- src/endOfHour/test.js | 12 ++++ src/endOfISOWeek/index.js | 2 + src/endOfISOWeek/index.js.flow | 4 +- src/endOfISOWeek/test.js | 12 ++++ src/endOfISOYear/index.js | 2 + src/endOfISOYear/index.js.flow | 4 +- src/endOfISOYear/test.js | 11 +++ src/endOfMinute/index.js | 2 + src/endOfMinute/index.js.flow | 4 +- src/endOfMinute/test.js | 12 ++++ src/endOfMonth/index.js | 2 + src/endOfMonth/index.js.flow | 4 +- src/endOfMonth/test.js | 12 ++++ src/endOfQuarter/index.js | 2 + src/endOfQuarter/index.js.flow | 4 +- src/endOfQuarter/test.js | 12 ++++ src/endOfSecond/index.js | 2 + src/endOfSecond/index.js.flow | 4 +- src/endOfSecond/test.js | 12 ++++ src/endOfWeek/index.js | 15 +++- src/endOfWeek/index.js.flow | 4 +- src/endOfWeek/test.js | 18 +++++ src/endOfYear/index.js | 2 + src/endOfYear/index.js.flow | 4 +- src/endOfYear/test.js | 12 ++++ src/format/index.js | 2 + src/format/index.js.flow | 4 +- src/format/test.js | 6 ++ src/fp/addDays/index.js.flow | 4 +- src/fp/addDaysWithOptions/index.js.flow | 4 +- src/fp/addHours/index.js.flow | 4 +- src/fp/addHoursWithOptions/index.js.flow | 4 +- src/fp/addISOYears/index.js.flow | 4 +- src/fp/addISOYearsWithOptions/index.js.flow | 4 +- src/fp/addMilliseconds/index.js.flow | 4 +- .../addMillisecondsWithOptions/index.js.flow | 4 +- src/fp/addMinutes/index.js.flow | 4 +- src/fp/addMinutesWithOptions/index.js.flow | 4 +- src/fp/addMonths/index.js.flow | 4 +- src/fp/addMonthsWithOptions/index.js.flow | 4 +- src/fp/addQuarters/index.js.flow | 4 +- src/fp/addQuartersWithOptions/index.js.flow | 4 +- src/fp/addSeconds/index.js.flow | 4 +- src/fp/addSecondsWithOptions/index.js.flow | 4 +- src/fp/addWeeks/index.js.flow | 4 +- src/fp/addWeeksWithOptions/index.js.flow | 4 +- src/fp/addYears/index.js.flow | 4 +- src/fp/addYearsWithOptions/index.js.flow | 4 +- src/fp/areIntervalsOverlapping/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/closestIndexTo/index.js.flow | 4 +- .../closestIndexToWithOptions/index.js.flow | 4 +- src/fp/closestTo/index.js.flow | 4 +- src/fp/closestToWithOptions/index.js.flow | 4 +- src/fp/compareAsc/index.js.flow | 4 +- src/fp/compareAscWithOptions/index.js.flow | 4 +- src/fp/compareDesc/index.js.flow | 4 +- src/fp/compareDescWithOptions/index.js.flow | 4 +- src/fp/differenceInCalendarDays/index.js.flow | 4 +- .../index.js.flow | 4 +- .../index.js.flow | 4 +- .../index.js.flow | 4 +- .../index.js.flow | 4 +- .../index.js.flow | 4 +- .../differenceInCalendarMonths/index.js.flow | 4 +- .../index.js.flow | 4 +- .../index.js.flow | 4 +- .../index.js.flow | 4 +- .../differenceInCalendarWeeks/index.js.flow | 4 +- .../index.js.flow | 4 +- .../differenceInCalendarYears/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/differenceInDays/index.js.flow | 4 +- .../differenceInDaysWithOptions/index.js.flow | 4 +- src/fp/differenceInHours/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/differenceInISOYears/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/differenceInMilliseconds/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/differenceInMinutes/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/differenceInMonths/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/differenceInQuarters/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/differenceInSeconds/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/differenceInWeeks/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/differenceInYears/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/distanceInWords/index.js.flow | 4 +- src/fp/distanceInWordsStrict/index.js.flow | 4 +- .../index.js.flow | 4 +- .../distanceInWordsWithOptions/index.js.flow | 4 +- src/fp/eachDayOfInterval/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/endOfDay/index.js.flow | 4 +- src/fp/endOfDayWithOptions/index.js.flow | 4 +- src/fp/endOfHour/index.js.flow | 4 +- src/fp/endOfHourWithOptions/index.js.flow | 4 +- src/fp/endOfISOWeek/index.js.flow | 4 +- src/fp/endOfISOWeekWithOptions/index.js.flow | 4 +- src/fp/endOfISOYear/index.js.flow | 4 +- src/fp/endOfISOYearWithOptions/index.js.flow | 4 +- src/fp/endOfMinute/index.js.flow | 4 +- src/fp/endOfMinuteWithOptions/index.js.flow | 4 +- src/fp/endOfMonth/index.js.flow | 4 +- src/fp/endOfMonthWithOptions/index.js.flow | 4 +- src/fp/endOfQuarter/index.js.flow | 4 +- src/fp/endOfQuarterWithOptions/index.js.flow | 4 +- src/fp/endOfSecond/index.js.flow | 4 +- src/fp/endOfSecondWithOptions/index.js.flow | 4 +- src/fp/endOfWeek/index.js.flow | 4 +- src/fp/endOfWeekWithOptions/index.js.flow | 4 +- src/fp/endOfYear/index.js.flow | 4 +- src/fp/endOfYearWithOptions/index.js.flow | 4 +- src/fp/format/index.js.flow | 4 +- src/fp/formatWithOptions/index.js.flow | 4 +- src/fp/getDate/index.js.flow | 4 +- src/fp/getDateWithOptions/index.js.flow | 4 +- src/fp/getDay/index.js.flow | 4 +- src/fp/getDayOfYear/index.js.flow | 4 +- src/fp/getDayOfYearWithOptions/index.js.flow | 4 +- src/fp/getDayWithOptions/index.js.flow | 4 +- src/fp/getDaysInMonth/index.js.flow | 4 +- .../getDaysInMonthWithOptions/index.js.flow | 4 +- src/fp/getDaysInYear/index.js.flow | 4 +- src/fp/getDaysInYearWithOptions/index.js.flow | 4 +- src/fp/getHours/index.js.flow | 4 +- src/fp/getHoursWithOptions/index.js.flow | 4 +- src/fp/getISODay/index.js.flow | 4 +- src/fp/getISODayWithOptions/index.js.flow | 4 +- src/fp/getISOWeek/index.js.flow | 4 +- src/fp/getISOWeekWithOptions/index.js.flow | 4 +- src/fp/getISOWeeksInYear/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/getISOYear/index.js.flow | 4 +- src/fp/getISOYearWithOptions/index.js.flow | 4 +- src/fp/getMilliseconds/index.js.flow | 4 +- .../getMillisecondsWithOptions/index.js.flow | 4 +- src/fp/getMinutes/index.js.flow | 4 +- src/fp/getMinutesWithOptions/index.js.flow | 4 +- src/fp/getMonth/index.js.flow | 4 +- src/fp/getMonthWithOptions/index.js.flow | 4 +- .../index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/getQuarter/index.js.flow | 4 +- src/fp/getQuarterWithOptions/index.js.flow | 4 +- src/fp/getSeconds/index.js.flow | 4 +- src/fp/getSecondsWithOptions/index.js.flow | 4 +- src/fp/getTime/index.js.flow | 4 +- src/fp/getTimeWithOptions/index.js.flow | 4 +- src/fp/getYear/index.js.flow | 4 +- src/fp/getYearWithOptions/index.js.flow | 4 +- src/fp/isAfter/index.js.flow | 4 +- src/fp/isAfterWithOptions/index.js.flow | 4 +- src/fp/isBefore/index.js.flow | 4 +- src/fp/isBeforeWithOptions/index.js.flow | 4 +- src/fp/isDate/index.js.flow | 4 +- src/fp/isDateWithOptions/index.js.flow | 4 +- src/fp/isEqual/index.js.flow | 4 +- src/fp/isEqualWithOptions/index.js.flow | 4 +- src/fp/isFirstDayOfMonth/index.js.flow | 4 +- .../index.js.flow | 4 +- src/fp/isFriday/index.js.flow | 4 +- src/fp/isFridayWithOptions/index.js.flow | 4 +- src/fp/isLastDayOfMonth/index.js.flow | 4 +- .../isLastDayOfMonthWithOptions/index.js.flow | 4 +- src/fp/isLeapYear/index.js.flow | 4 +- src/fp/isLeapYearWithOptions/index.js.flow | 4 +- src/fp/isMonday/index.js.flow | 4 +- src/fp/isMondayWithOptions/index.js.flow | 4 +- src/fp/isSameDay/index.js.flow | 4 +- src/fp/isSameDayWithOptions/index.js.flow | 4 +- src/fp/isSameHour/index.js.flow | 4 +- src/fp/isSameHourWithOptions/index.js.flow | 4 +- src/fp/isSameISOWeek/index.js.flow | 4 +- src/fp/isSameISOWeekWithOptions/index.js.flow | 4 +- src/fp/isSameISOYear/index.js.flow | 4 +- src/fp/isSameISOYearWithOptions/index.js.flow | 4 +- src/fp/isSameMinute/index.js.flow | 4 +- src/fp/isSameMinuteWithOptions/index.js.flow | 4 +- src/fp/isSameMonth/index.js.flow | 4 +- src/fp/isSameMonthWithOptions/index.js.flow | 4 +- src/fp/isSameQuarter/index.js.flow | 4 +- src/fp/isSameQuarterWithOptions/index.js.flow | 4 +- src/fp/isSameSecond/index.js.flow | 4 +- src/fp/isSameSecondWithOptions/index.js.flow | 4 +- src/fp/isSameWeek/index.js.flow | 4 +- src/fp/isSameWeekWithOptions/index.js.flow | 4 +- src/fp/isSameYear/index.js.flow | 4 +- src/fp/isSameYearWithOptions/index.js.flow | 4 +- src/fp/isSaturday/index.js.flow | 4 +- src/fp/isSaturdayWithOptions/index.js.flow | 4 +- src/fp/isSunday/index.js.flow | 4 +- src/fp/isSundayWithOptions/index.js.flow | 4 +- src/fp/isThursday/index.js.flow | 4 +- src/fp/isThursdayWithOptions/index.js.flow | 4 +- src/fp/isTuesday/index.js.flow | 4 +- src/fp/isTuesdayWithOptions/index.js.flow | 4 +- src/fp/isValid/index.js.flow | 4 +- src/fp/isValidWithOptions/index.js.flow | 4 +- src/fp/isWednesday/index.js.flow | 4 +- src/fp/isWednesdayWithOptions/index.js.flow | 4 +- src/fp/isWeekend/index.js.flow | 4 +- src/fp/isWeekendWithOptions/index.js.flow | 4 +- src/fp/isWithinInterval/index.js.flow | 4 +- .../isWithinIntervalWithOptions/index.js.flow | 4 +- src/fp/lastDayOfISOWeek/index.js.flow | 4 +- .../lastDayOfISOWeekWithOptions/index.js.flow | 4 +- src/fp/lastDayOfISOYear/index.js.flow | 4 +- .../lastDayOfISOYearWithOptions/index.js.flow | 4 +- src/fp/lastDayOfMonth/index.js.flow | 4 +- .../lastDayOfMonthWithOptions/index.js.flow | 4 +- src/fp/lastDayOfQuarter/index.js.flow | 4 +- .../lastDayOfQuarterWithOptions/index.js.flow | 4 +- src/fp/lastDayOfWeek/index.js.flow | 4 +- src/fp/lastDayOfWeekWithOptions/index.js.flow | 4 +- src/fp/lastDayOfYear/index.js.flow | 4 +- src/fp/lastDayOfYearWithOptions/index.js.flow | 4 +- src/fp/max/index.js.flow | 4 +- src/fp/maxWithOptions/index.js.flow | 4 +- src/fp/min/index.js.flow | 4 +- src/fp/minWithOptions/index.js.flow | 4 +- src/fp/parse/index.js.flow | 4 +- src/fp/parseWithOptions/index.js.flow | 4 +- src/fp/setDate/index.js.flow | 4 +- src/fp/setDateWithOptions/index.js.flow | 4 +- src/fp/setDay/index.js.flow | 4 +- src/fp/setDayOfYear/index.js.flow | 4 +- src/fp/setDayOfYearWithOptions/index.js.flow | 4 +- src/fp/setDayWithOptions/index.js.flow | 4 +- src/fp/setHours/index.js.flow | 4 +- src/fp/setHoursWithOptions/index.js.flow | 4 +- src/fp/setISODay/index.js.flow | 4 +- src/fp/setISODayWithOptions/index.js.flow | 4 +- src/fp/setISOWeek/index.js.flow | 4 +- src/fp/setISOWeekWithOptions/index.js.flow | 4 +- src/fp/setISOYear/index.js.flow | 4 +- src/fp/setISOYearWithOptions/index.js.flow | 4 +- src/fp/setMilliseconds/index.js.flow | 4 +- .../setMillisecondsWithOptions/index.js.flow | 4 +- src/fp/setMinutes/index.js.flow | 4 +- src/fp/setMinutesWithOptions/index.js.flow | 4 +- src/fp/setMonth/index.js.flow | 4 +- src/fp/setMonthWithOptions/index.js.flow | 4 +- src/fp/setQuarter/index.js.flow | 4 +- src/fp/setQuarterWithOptions/index.js.flow | 4 +- src/fp/setSeconds/index.js.flow | 4 +- src/fp/setSecondsWithOptions/index.js.flow | 4 +- src/fp/setYear/index.js.flow | 4 +- src/fp/setYearWithOptions/index.js.flow | 4 +- src/fp/startOfDay/index.js.flow | 4 +- src/fp/startOfDayWithOptions/index.js.flow | 4 +- src/fp/startOfHour/index.js.flow | 4 +- src/fp/startOfHourWithOptions/index.js.flow | 4 +- src/fp/startOfISOWeek/index.js.flow | 4 +- .../startOfISOWeekWithOptions/index.js.flow | 4 +- src/fp/startOfISOYear/index.js.flow | 4 +- .../startOfISOYearWithOptions/index.js.flow | 4 +- src/fp/startOfMinute/index.js.flow | 4 +- src/fp/startOfMinuteWithOptions/index.js.flow | 4 +- src/fp/startOfMonth/index.js.flow | 4 +- src/fp/startOfMonthWithOptions/index.js.flow | 4 +- src/fp/startOfQuarter/index.js.flow | 4 +- .../startOfQuarterWithOptions/index.js.flow | 4 +- src/fp/startOfSecond/index.js.flow | 4 +- src/fp/startOfSecondWithOptions/index.js.flow | 4 +- src/fp/startOfWeek/index.js.flow | 4 +- src/fp/startOfWeekWithOptions/index.js.flow | 4 +- src/fp/startOfYear/index.js.flow | 4 +- src/fp/startOfYearWithOptions/index.js.flow | 4 +- src/fp/subDays/index.js.flow | 4 +- src/fp/subDaysWithOptions/index.js.flow | 4 +- src/fp/subHours/index.js.flow | 4 +- src/fp/subHoursWithOptions/index.js.flow | 4 +- src/fp/subISOYears/index.js.flow | 4 +- src/fp/subISOYearsWithOptions/index.js.flow | 4 +- src/fp/subMilliseconds/index.js.flow | 4 +- .../subMillisecondsWithOptions/index.js.flow | 4 +- src/fp/subMinutes/index.js.flow | 4 +- src/fp/subMinutesWithOptions/index.js.flow | 4 +- src/fp/subMonths/index.js.flow | 4 +- src/fp/subMonthsWithOptions/index.js.flow | 4 +- src/fp/subQuarters/index.js.flow | 4 +- src/fp/subQuartersWithOptions/index.js.flow | 4 +- src/fp/subSeconds/index.js.flow | 4 +- src/fp/subSecondsWithOptions/index.js.flow | 4 +- src/fp/subWeeks/index.js.flow | 4 +- src/fp/subWeeksWithOptions/index.js.flow | 4 +- src/fp/subYears/index.js.flow | 4 +- src/fp/subYearsWithOptions/index.js.flow | 4 +- src/fp/toDate/index.js.flow | 4 +- src/fp/toDateWithOptions/index.js.flow | 4 +- src/getDate/index.js | 2 + src/getDate/index.js.flow | 4 +- src/getDate/test.js | 11 +++ src/getDay/index.js | 2 + src/getDay/index.js.flow | 4 +- src/getDay/test.js | 11 +++ src/getDayOfYear/index.js | 2 + src/getDayOfYear/index.js.flow | 4 +- src/getDayOfYear/test.js | 11 +++ src/getDaysInMonth/index.js | 2 + src/getDaysInMonth/index.js.flow | 4 +- src/getDaysInMonth/test.js | 11 +++ src/getDaysInYear/index.js | 11 ++- src/getDaysInYear/index.js.flow | 4 +- src/getDaysInYear/test.js | 11 +++ src/getHours/index.js | 2 + src/getHours/index.js.flow | 4 +- src/getHours/test.js | 11 +++ src/getISODay/index.js | 2 + src/getISODay/index.js.flow | 4 +- src/getISODay/test.js | 11 +++ src/getISOWeek/index.js | 2 + src/getISOWeek/index.js.flow | 4 +- src/getISOWeek/test.js | 11 +++ src/getISOWeeksInYear/index.js | 2 + src/getISOWeeksInYear/index.js.flow | 4 +- src/getISOWeeksInYear/test.js | 11 +++ src/getISOYear/index.js | 2 + src/getISOYear/index.js.flow | 4 +- src/getISOYear/test.js | 11 +++ src/getMilliseconds/index.js | 2 + src/getMilliseconds/index.js.flow | 4 +- src/getMilliseconds/test.js | 11 +++ src/getMinutes/index.js | 2 + src/getMinutes/index.js.flow | 4 +- src/getMinutes/test.js | 11 +++ src/getMonth/index.js | 2 + src/getMonth/index.js.flow | 4 +- src/getMonth/test.js | 11 +++ src/getOverlappingDaysInIntervals/index.js | 10 ++- .../index.js.flow | 4 +- src/getOverlappingDaysInIntervals/test.js | 56 ++++++++++++++- src/getQuarter/index.js | 2 + src/getQuarter/index.js.flow | 4 +- src/getQuarter/test.js | 11 +++ src/getSeconds/index.js | 2 + src/getSeconds/index.js.flow | 4 +- src/getSeconds/test.js | 11 +++ src/getTime/index.js | 2 + src/getTime/index.js.flow | 4 +- src/getTime/test.js | 12 ++++ src/getYear/index.js | 2 + src/getYear/index.js.flow | 4 +- src/getYear/test.js | 11 +++ src/isAfter/index.js | 2 + src/isAfter/index.js.flow | 4 +- src/isAfter/test.js | 35 +++++++++ src/isBefore/index.js | 2 + src/isBefore/index.js.flow | 4 +- src/isBefore/test.js | 35 +++++++++ src/isDate/index.js.flow | 4 +- src/isEqual/index.js | 2 + src/isEqual/index.js.flow | 4 +- src/isEqual/test.js | 35 +++++++++ src/isFirstDayOfMonth/index.js | 2 + src/isFirstDayOfMonth/index.js.flow | 4 +- src/isFirstDayOfMonth/test.js | 11 +++ src/isFriday/index.js | 2 + src/isFriday/index.js.flow | 4 +- src/isFriday/test.js | 11 +++ src/isLastDayOfMonth/index.js | 2 + src/isLastDayOfMonth/index.js.flow | 4 +- src/isLastDayOfMonth/test.js | 11 +++ src/isLeapYear/index.js | 2 + src/isLeapYear/index.js.flow | 4 +- src/isLeapYear/test.js | 11 +++ src/isMonday/index.js | 2 + src/isMonday/index.js.flow | 4 +- src/isMonday/test.js | 11 +++ src/isSameDay/index.js | 2 + src/isSameDay/index.js.flow | 4 +- src/isSameDay/test.js | 35 +++++++++ src/isSameHour/index.js | 2 + src/isSameHour/index.js.flow | 4 +- src/isSameHour/test.js | 35 +++++++++ src/isSameISOWeek/index.js | 2 + src/isSameISOWeek/index.js.flow | 4 +- src/isSameISOWeek/test.js | 35 +++++++++ src/isSameISOYear/index.js | 2 + src/isSameISOYear/index.js.flow | 4 +- src/isSameISOYear/test.js | 35 +++++++++ src/isSameMinute/index.js | 2 + src/isSameMinute/index.js.flow | 4 +- src/isSameMinute/test.js | 35 +++++++++ src/isSameMonth/index.js | 2 + src/isSameMonth/index.js.flow | 4 +- src/isSameMonth/test.js | 35 +++++++++ src/isSameQuarter/index.js | 2 + src/isSameQuarter/index.js.flow | 4 +- src/isSameQuarter/test.js | 35 +++++++++ src/isSameSecond/index.js | 2 + src/isSameSecond/index.js.flow | 4 +- src/isSameSecond/test.js | 35 +++++++++ src/isSameWeek/index.js | 5 +- src/isSameWeek/index.js.flow | 4 +- src/isSameWeek/test.js | 46 ++++++++++++ src/isSameYear/index.js | 2 + src/isSameYear/index.js.flow | 4 +- src/isSameYear/test.js | 35 +++++++++ src/isSaturday/index.js | 2 + src/isSaturday/index.js.flow | 4 +- src/isSaturday/test.js | 11 +++ src/isSunday/index.js | 2 + src/isSunday/index.js.flow | 4 +- src/isSunday/test.js | 11 +++ src/isThursday/index.js | 2 + src/isThursday/index.js.flow | 4 +- src/isThursday/test.js | 11 +++ src/isTuesday/index.js | 2 + src/isTuesday/index.js.flow | 4 +- src/isTuesday/test.js | 11 +++ src/isValid/index.js | 2 + src/isValid/index.js.flow | 4 +- src/isValid/test.js | 6 ++ src/isWednesday/index.js | 2 + src/isWednesday/index.js.flow | 4 +- src/isWednesday/test.js | 11 +++ src/isWeekend/index.js | 2 + src/isWeekend/index.js.flow | 4 +- src/isWeekend/test.js | 11 +++ src/isWithinInterval/index.js | 10 ++- src/isWithinInterval/index.js.flow | 4 +- src/isWithinInterval/test.js | 39 +++++++++- src/lastDayOfISOWeek/index.js | 2 + src/lastDayOfISOWeek/index.js.flow | 4 +- src/lastDayOfISOWeek/test.js | 12 ++++ src/lastDayOfISOYear/index.js | 2 + src/lastDayOfISOYear/index.js.flow | 4 +- src/lastDayOfISOYear/test.js | 11 +++ src/lastDayOfMonth/index.js | 2 + src/lastDayOfMonth/index.js.flow | 4 +- src/lastDayOfMonth/test.js | 12 ++++ src/lastDayOfQuarter/index.js | 2 + src/lastDayOfQuarter/index.js.flow | 4 +- src/lastDayOfQuarter/test.js | 12 ++++ src/lastDayOfWeek/index.js | 13 +++- src/lastDayOfWeek/index.js.flow | 4 +- src/lastDayOfWeek/test.js | 18 +++++ src/lastDayOfYear/index.js | 2 + src/lastDayOfYear/index.js.flow | 4 +- src/lastDayOfYear/test.js | 12 ++++ src/max/index.js | 2 + src/max/index.js.flow | 4 +- src/max/test.js | 32 +++++++++ src/min/index.js | 2 + src/min/index.js.flow | 4 +- src/min/test.js | 32 +++++++++ src/parse/index.js | 18 ++++- src/parse/index.js.flow | 4 +- src/parse/test.js | 21 ++++++ src/setDate/index.js | 2 + src/setDate/index.js.flow | 4 +- src/setDate/test.js | 16 +++++ src/setDay/index.js | 18 +++-- src/setDay/index.js.flow | 4 +- src/setDay/test.js | 22 ++++++ src/setDayOfYear/index.js | 2 + src/setDayOfYear/index.js.flow | 4 +- src/setDayOfYear/test.js | 16 +++++ src/setHours/index.js | 2 + src/setHours/index.js.flow | 4 +- src/setHours/test.js | 16 +++++ src/setISODay/index.js | 2 + src/setISODay/index.js.flow | 4 +- src/setISODay/test.js | 16 +++++ src/setISOWeek/index.js | 2 + src/setISOWeek/index.js.flow | 4 +- src/setISOWeek/test.js | 16 +++++ src/setISOYear/index.js | 2 + src/setISOYear/index.js.flow | 4 +- src/setISOYear/test.js | 16 +++++ src/setMilliseconds/index.js | 2 + src/setMilliseconds/index.js.flow | 4 +- src/setMilliseconds/test.js | 16 +++++ src/setMinutes/index.js | 2 + src/setMinutes/index.js.flow | 4 +- src/setMinutes/test.js | 16 +++++ src/setMonth/index.js | 2 + src/setMonth/index.js.flow | 4 +- src/setMonth/test.js | 16 +++++ src/setQuarter/index.js | 2 + src/setQuarter/index.js.flow | 4 +- src/setQuarter/test.js | 16 +++++ src/setSeconds/index.js | 2 + src/setSeconds/index.js.flow | 4 +- src/setSeconds/test.js | 16 +++++ src/setYear/index.js | 8 +++ src/setYear/index.js.flow | 4 +- src/setYear/test.js | 16 +++++ src/startOfDay/index.js | 2 + src/startOfDay/index.js.flow | 4 +- src/startOfDay/test.js | 12 ++++ src/startOfHour/index.js | 2 + src/startOfHour/index.js.flow | 4 +- src/startOfHour/test.js | 12 ++++ src/startOfISOWeek/index.js | 2 + src/startOfISOWeek/index.js.flow | 4 +- src/startOfISOWeek/test.js | 12 ++++ src/startOfISOYear/index.js | 2 + src/startOfISOYear/index.js.flow | 4 +- src/startOfISOYear/test.js | 11 +++ src/startOfMinute/index.js | 2 + src/startOfMinute/index.js.flow | 4 +- src/startOfMinute/test.js | 12 ++++ src/startOfMonth/index.js | 2 + src/startOfMonth/index.js.flow | 4 +- src/startOfMonth/test.js | 12 ++++ src/startOfQuarter/index.js | 2 + src/startOfQuarter/index.js.flow | 4 +- src/startOfQuarter/test.js | 12 ++++ src/startOfSecond/index.js | 2 + src/startOfSecond/index.js.flow | 4 +- src/startOfSecond/test.js | 12 ++++ src/startOfWeek/index.js | 15 +++- src/startOfWeek/index.js.flow | 4 +- src/startOfWeek/test.js | 18 +++++ src/startOfYear/index.js | 2 + src/startOfYear/index.js.flow | 4 +- src/startOfYear/test.js | 12 ++++ src/subDays/index.js | 2 + src/subDays/index.js.flow | 4 +- src/subDays/test.js | 16 +++++ src/subHours/index.js | 2 + src/subHours/index.js.flow | 4 +- src/subHours/test.js | 16 +++++ src/subISOYears/index.js | 2 + src/subISOYears/index.js.flow | 4 +- src/subISOYears/test.js | 16 +++++ src/subMilliseconds/index.js | 2 + src/subMilliseconds/index.js.flow | 4 +- src/subMilliseconds/test.js | 16 +++++ src/subMinutes/index.js | 2 + src/subMinutes/index.js.flow | 4 +- src/subMinutes/test.js | 16 +++++ src/subMonths/index.js | 2 + src/subMonths/index.js.flow | 4 +- src/subMonths/test.js | 16 +++++ src/subQuarters/index.js | 2 + src/subQuarters/index.js.flow | 4 +- src/subQuarters/test.js | 16 +++++ src/subSeconds/index.js | 2 + src/subSeconds/index.js.flow | 4 +- src/subSeconds/test.js | 16 +++++ src/subWeeks/index.js | 2 + src/subWeeks/index.js.flow | 4 +- src/subWeeks/test.js | 16 +++++ src/subYears/index.js | 2 + src/subYears/index.js.flow | 4 +- src/subYears/test.js | 16 +++++ src/toDate/index.js | 19 ++--- src/toDate/index.js.flow | 4 +- src/toDate/test.js | 6 ++ typings.d.ts | 6 +- 671 files changed, 4081 insertions(+), 886 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a030ca8514..19d5a13805 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -187,8 +187,9 @@ This change log follows the format documented in [Keep a CHANGELOG]. ``` Also these functions now accept an object with `start` and `end` properties - instead of two arguments as an interval. All these functions, as before, - throw an exception if the start of the interval is after its end. + instead of two arguments as an interval. All these functions + throw `RangeError` if the start of the interval is after its end + or if any date in interval is `Invalid Date`. ```javascript // Before v2.0.0 @@ -311,7 +312,43 @@ This change log follows the format documented in [Keep a CHANGELOG]. We introduce this change to make *date-fns* consistent with ECMAScript behavior that try to coerce arguments to the expected type - (which is also the case with other *date-fns* functions). + (which is also the case with other *date-fns* functions). + +- **BREAKING**: `partialMethod` option in `distanceInWordsStrict` is renamed to `roundingMethod`. + + ```javascript + // Before v2.0.0 + var options = {partialMethod: 'ceil'} + // v2.0.0 onward + var options = {roundingMethod: 'ceil'} + + var result = distanceInWordsStrict( + new Date(1986, 3, 4, 10, 32, 0), + new Date(1986, 3, 4, 10, 33, 1), + options + ) + ``` + +- **BREAKING**: functions now throw `RangeError` if optional values passed to `options` + are not `undefined` or have expected values. + This change is introduced for consistency with ECMAScript standard library which does the same. + See [docs/Options.js](https://github.com/date-fns/date-fns/blob/master/docs/Options.js) + +- **BREAKING**: all functions now handle arguments by following rules: + + - as before, arguments expected to be `Date` are converted to `Date` using *date-fns'* `toDate` function; + - arguments expected to be numbers are converted to numbers using JavaScript's `Number` function; + - arguments expected to be strings arguments are converted to strings using JavaScript's `String` function. + + If any of resulting arguments is invalid (i.e. `NaN` for numbers and `Invalid Date` for dates), + an invalid value will be returned: + + - `false` for functions that return booleans (expect `isValid`); + - `Invalid Date` for functions that return dates; + - `NaN` for functions that return numbers; + - and `String('Invalid Date')` for functions that return strings. + + See tests and PR [#460](https://github.com/date-fns/date-fns/pull/460) for exact behavior. - Every function now has `options` as the last argument which is passed to all its dependencies for consistency and future features. diff --git a/docs/Options.js b/docs/Options.js index cae5a1a15b..556225f4e8 100644 --- a/docs/Options.js +++ b/docs/Options.js @@ -6,9 +6,9 @@ * An object passed as the last optional argument to all functions. * * @typedef {Object} Options - * @property {Number} [weekStartsOn=0] - the index of the first day of the week (0 - Sunday). + * @property {0|1|2|3|4|5|6} [weekStartsOn=0] - the index of the first day of the week (0 - Sunday). * Used by `differenceInCalendarWeeks`, `endOfWeek`, `isSameWeek`, - * `isThisWeek`, `lastDayOfWeek`, `setDay`, and `startOfWeek` + * `lastDayOfWeek`, `parse`, `setDay`, and `startOfWeek` * @property {0|1|2} [additionalDigits=2] - the additional number of digits in the extended year format. * Used by all functions that take String as Date-like argument. * Internally, passed to `toDate` to specify which way to convert extended year formatted String to Date. @@ -22,9 +22,19 @@ * If true, the result will indicate if the second date is earlier or later than the first * @property {'s'|'m'|'h'|'d'|'M'|'Y'} [unit] - used by `distanceInWordsStrict`. * If specified, will force a unit - * @property {'floor'|'ceil'|'round'} [partialMethod='floor'] - used by `distanceInWordsStrict`. + * @property {'floor'|'ceil'|'round'} [roundingMethod='floor'] - used by `distanceInWordsStrict`. * Specifies, which way to round partial units * + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2. + * Thrown by **all** functions + * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6. + * Thrown by `differenceInCalendarWeeks`, `endOfWeek`, `isSameWeek`, + * `lastDayOfWeek`, `parse`, `setDay`, and `startOfWeek`. + * @throws {RangeError} `options.roundingMethod` must be 'floor', 'ceil' or 'round'. + * Thrown by `distanceInWordsStrict` + * @throws {RangeError} `options.unit` must be 's', 'm', 'h', 'd', 'M' or 'Y'. + * Thrown by `distanceInWordsStrict` + * * @example * // For 15 December 12345 AD, represent the start of the week in Esperanto, * // if the first day of the week is Monday: diff --git a/src/addDays/index.js b/src/addDays/index.js index c0a873d77e..7b34fa0c53 100644 --- a/src/addDays/index.js +++ b/src/addDays/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of days to be added * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the days added + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Add 10 days to 1 September 2014: diff --git a/src/addDays/index.js.flow b/src/addDays/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/addDays/index.js.flow +++ b/src/addDays/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/addDays/test.js b/src/addDays/test.js index 19935209a4..cae4a77ba2 100644 --- a/src/addDays/test.js +++ b/src/addDays/test.js @@ -31,4 +31,20 @@ describe('addDays', function () { addDays(date, 11) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = addDays(new Date(NaN), 10) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = addDays(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = addDays.bind(null, new Date(2014, 8 /* Sep */, 1), 10, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/addHours/index.js b/src/addHours/index.js index 974a47e0c7..ac09bc4583 100644 --- a/src/addHours/index.js +++ b/src/addHours/index.js @@ -13,7 +13,9 @@ var MILLISECONDS_IN_HOUR = 3600000 * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of hours to be added * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the hours added + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Add 2 hours to 10 July 2014 23:00:00: diff --git a/src/addHours/index.js.flow b/src/addHours/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/addHours/index.js.flow +++ b/src/addHours/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/addHours/test.js b/src/addHours/test.js index 4b6b87b8df..ffd6d97acf 100644 --- a/src/addHours/test.js +++ b/src/addHours/test.js @@ -35,4 +35,20 @@ describe('addHours', function () { addHours(date, 10) assert.deepEqual(date, new Date(2014, 6 /* Jul */, 10, 23, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = addHours(new Date(NaN), 2) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = addHours(new Date(2014, 6 /* Jul */, 10, 23, 0), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = addHours.bind(null, new Date(2014, 6 /* Jul */, 10, 23, 0), 2, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/addISOYears/index.js b/src/addISOYears/index.js index c95eeac136..e332bb04f0 100644 --- a/src/addISOYears/index.js +++ b/src/addISOYears/index.js @@ -14,7 +14,9 @@ import setISOYear from '../setISOYear/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of ISO week-numbering years to be added * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the ISO week-numbering years added + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Add 5 ISO week-numbering years to 2 July 2010: diff --git a/src/addISOYears/index.js.flow b/src/addISOYears/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/addISOYears/index.js.flow +++ b/src/addISOYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/addISOYears/test.js b/src/addISOYears/test.js index 3ba0dcf9a9..c558051c37 100644 --- a/src/addISOYears/test.js +++ b/src/addISOYears/test.js @@ -42,4 +42,20 @@ describe('addISOYears', function () { var result = addISOYears(initialDate, 5) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = addISOYears(new Date(NaN), 5) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = addISOYears(new Date(2010, 6 /* Jul */, 2), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = addISOYears.bind(null, new Date(2010, 6 /* Jul */, 2), 5, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/addMilliseconds/index.js b/src/addMilliseconds/index.js index 12f57c2f71..3c2a578dd8 100644 --- a/src/addMilliseconds/index.js +++ b/src/addMilliseconds/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of milliseconds to be added * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the milliseconds added + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Add 750 milliseconds to 10 July 2014 12:45:30.000: diff --git a/src/addMilliseconds/index.js.flow b/src/addMilliseconds/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/addMilliseconds/index.js.flow +++ b/src/addMilliseconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/addMilliseconds/test.js b/src/addMilliseconds/test.js index 147158faee..5943bf1188 100644 --- a/src/addMilliseconds/test.js +++ b/src/addMilliseconds/test.js @@ -35,4 +35,20 @@ describe('addMilliseconds', function () { addMilliseconds(date, 250) assert.deepEqual(date, new Date(2014, 6 /* Jul */, 10, 12, 45, 30, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = addMilliseconds(new Date(NaN), 750) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = addMilliseconds(new Date(2014, 6 /* Jul */, 10, 12, 45, 30, 0), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = addMilliseconds.bind(null, new Date(2014, 6 /* Jul */, 10, 12, 45, 30, 0), 750, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/addMinutes/index.js b/src/addMinutes/index.js index 0a5126b679..1ec2f7513e 100644 --- a/src/addMinutes/index.js +++ b/src/addMinutes/index.js @@ -13,7 +13,9 @@ var MILLISECONDS_IN_MINUTE = 60000 * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of minutes to be added * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the minutes added + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Add 30 minutes to 10 July 2014 12:00:00: diff --git a/src/addMinutes/index.js.flow b/src/addMinutes/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/addMinutes/index.js.flow +++ b/src/addMinutes/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/addMinutes/test.js b/src/addMinutes/test.js index 968ce660e2..97ca8c2286 100644 --- a/src/addMinutes/test.js +++ b/src/addMinutes/test.js @@ -35,4 +35,20 @@ describe('addMinutes', function () { addMinutes(date, 25) assert.deepEqual(date, new Date(2014, 6 /* Jul */, 10, 12, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = addMinutes(new Date(NaN), 30) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = addMinutes(new Date(2014, 6 /* Jul */, 10, 12, 0), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = addMinutes.bind(null, new Date(2014, 6 /* Jul */, 10, 12, 0), 30, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/addMonths/index.js b/src/addMonths/index.js index a915ec7fbe..54786fd674 100644 --- a/src/addMonths/index.js +++ b/src/addMonths/index.js @@ -12,7 +12,9 @@ import getDaysInMonth from '../getDaysInMonth/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of months to be added * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the months added + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Add 5 months to 1 September 2014: diff --git a/src/addMonths/index.js.flow b/src/addMonths/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/addMonths/index.js.flow +++ b/src/addMonths/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/addMonths/test.js b/src/addMonths/test.js index 46908a17ad..efe5f5966e 100644 --- a/src/addMonths/test.js +++ b/src/addMonths/test.js @@ -48,4 +48,20 @@ describe('addMonths', function () { var result = addMonths(initialDate, 1) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = addMonths(new Date(NaN), 5) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = addMonths(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = addMonths.bind(null, new Date(2014, 8 /* Sep */, 1), 5, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/addQuarters/index.js b/src/addQuarters/index.js index abcbc1059c..d7c8f9a044 100644 --- a/src/addQuarters/index.js +++ b/src/addQuarters/index.js @@ -11,7 +11,9 @@ import addMonths from '../addMonths/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of quarters to be added * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the quarters added + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Add 1 quarter to 1 September 2014: diff --git a/src/addQuarters/index.js.flow b/src/addQuarters/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/addQuarters/index.js.flow +++ b/src/addQuarters/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/addQuarters/test.js b/src/addQuarters/test.js index 53e9f6e7f2..de56f138c0 100644 --- a/src/addQuarters/test.js +++ b/src/addQuarters/test.js @@ -48,4 +48,20 @@ describe('addQuarters', function () { var result = addQuarters(initialDate, 1) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = addQuarters(new Date(NaN), 1) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = addQuarters(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = addQuarters.bind(null, new Date(2014, 8 /* Sep */, 1), 1, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/addSeconds/index.js b/src/addSeconds/index.js index 1db34be06f..2853fa0e62 100644 --- a/src/addSeconds/index.js +++ b/src/addSeconds/index.js @@ -11,7 +11,9 @@ import addMilliseconds from '../addMilliseconds/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of seconds to be added * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the seconds added + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Add 30 seconds to 10 July 2014 12:45:00: diff --git a/src/addSeconds/index.js.flow b/src/addSeconds/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/addSeconds/index.js.flow +++ b/src/addSeconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/addSeconds/test.js b/src/addSeconds/test.js index 355df71712..0bd84d5365 100644 --- a/src/addSeconds/test.js +++ b/src/addSeconds/test.js @@ -35,4 +35,20 @@ describe('addSeconds', function () { addSeconds(date, 15) assert.deepEqual(date, new Date(2014, 6 /* Jul */, 10, 12, 45, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = addSeconds(new Date(NaN), 30) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = addSeconds(new Date(2014, 6 /* Jul */, 10, 12, 45, 0), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = addSeconds.bind(null, new Date(2014, 6 /* Jul */, 10, 12, 45, 0), 30, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/addWeeks/index.js b/src/addWeeks/index.js index 815b033adf..c97ec63079 100644 --- a/src/addWeeks/index.js +++ b/src/addWeeks/index.js @@ -11,7 +11,9 @@ import addDays from '../addDays/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of weeks to be added * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the weeks added + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Add 4 weeks to 1 September 2014: diff --git a/src/addWeeks/index.js.flow b/src/addWeeks/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/addWeeks/index.js.flow +++ b/src/addWeeks/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/addWeeks/test.js b/src/addWeeks/test.js index 5e56f88093..724a79e626 100644 --- a/src/addWeeks/test.js +++ b/src/addWeeks/test.js @@ -31,4 +31,20 @@ describe('addWeeks', function () { addWeeks(date, 2) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = addWeeks(new Date(NaN), 4) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = addWeeks(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = addWeeks.bind(null, new Date(2014, 8 /* Sep */, 1), 4, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/addYears/index.js b/src/addYears/index.js index a6ecf55a89..eacf35dd41 100644 --- a/src/addYears/index.js +++ b/src/addYears/index.js @@ -11,7 +11,9 @@ import addMonths from '../addMonths/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of years to be added * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the years added + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Add 5 years to 1 September 2014: diff --git a/src/addYears/index.js.flow b/src/addYears/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/addYears/index.js.flow +++ b/src/addYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/addYears/test.js b/src/addYears/test.js index e14e312c46..7a51a07072 100644 --- a/src/addYears/test.js +++ b/src/addYears/test.js @@ -47,4 +47,20 @@ describe('addYears', function () { var result = addYears(initialDate, 1) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = addYears(new Date(NaN), 5) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = addYears(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = addYears.bind(null, new Date(2014, 8 /* Sep */, 1), 5, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/areIntervalsOverlapping/index.js b/src/areIntervalsOverlapping/index.js index 8ba1f3731b..1ef4e5159e 100644 --- a/src/areIntervalsOverlapping/index.js +++ b/src/areIntervalsOverlapping/index.js @@ -12,7 +12,9 @@ import toDate from '../toDate/index.js' * @param {Interval} intervalRight - the second interval to compare. See [Interval]{@link docs/types/Interval} * @param {Options} [options] - the object with options. See [Options]{@link docs/types/Options} * @returns {Boolean} whether the time intervals are overlapping - * @throws {Error} The start of an interval cannot be after its end + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} The start of an interval cannot be after its end + * @throws {RangeError} Date in interval cannot be `Invalid Date` * * @example * // For overlapping time intervals: @@ -36,8 +38,9 @@ export default function areIntervalsOverlapping (dirtyIntervalLeft, dirtyInterva var rightStartTime = toDate(dirtyIntervalRight.start, dirtyOptions).getTime() var rightEndTime = toDate(dirtyIntervalRight.end, dirtyOptions).getTime() - if (leftStartTime > leftEndTime || rightStartTime > rightEndTime) { - throw new Error('The start of an interval cannot be after its end') + // Throw an exception if start date is after end date or if any date is `Invalid Date` + if (!(leftStartTime <= leftEndTime && rightStartTime <= rightEndTime)) { + throw new RangeError('Invalid interval') } return leftStartTime < rightEndTime && rightStartTime < leftEndTime diff --git a/src/areIntervalsOverlapping/index.js.flow b/src/areIntervalsOverlapping/index.js.flow index a9d71bbd6e..10d9850fb1 100644 --- a/src/areIntervalsOverlapping/index.js.flow +++ b/src/areIntervalsOverlapping/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/areIntervalsOverlapping/test.js b/src/areIntervalsOverlapping/test.js index 1d1cc23645..60bce66fba 100644 --- a/src/areIntervalsOverlapping/test.js +++ b/src/areIntervalsOverlapping/test.js @@ -156,7 +156,7 @@ describe('areIntervalsOverlapping', function () { {start: new Date(2016, 10, 7), end: new Date(2016, 10, 3)}, {start: new Date(2016, 10, 5), end: new Date(2016, 10, 15)} ) - assert.throws(block) + assert.throws(block, RangeError) }) it('throws an exception if the start date of the compared time interval is after the end date', function () { @@ -165,6 +165,58 @@ describe('areIntervalsOverlapping', function () { {start: new Date(2016, 10, 3), end: new Date(2016, 10, 7)}, {start: new Date(2016, 10, 15), end: new Date(2016, 10, 5)} ) - assert.throws(block) + assert.throws(block, RangeError) + }) + + context('one of the dates is `Invalid Date`', function () { + it('throws an exception if the start date of the initial time interval is `Invalid Date`', function () { + var block = areIntervalsOverlapping.bind( + null, + {start: new Date(NaN), end: new Date(2016, 10, 3)}, + {start: new Date(2016, 10, 5), end: new Date(2016, 10, 15)} + ) + assert.throws(block, RangeError) + }) + + it('throws an exception if the end date of the initial time interval is `Invalid Date`', function () { + var block = areIntervalsOverlapping.bind( + null, + {start: new Date(2016, 10, 3), end: new Date(NaN)}, + {start: new Date(2016, 10, 5), end: new Date(2016, 10, 15)} + ) + assert.throws(block, RangeError) + }) + + it('throws an exception if the start date of the compared time interval is `Invalid Date`', function () { + var block = areIntervalsOverlapping.bind( + null, + {start: new Date(2016, 10, 3), end: new Date(2016, 10, 7)}, + {start: new Date(NaN), end: new Date(2016, 10, 5)} + ) + assert.throws(block, RangeError) + }) + + it('throws an exception if the end date of the compared time interval is `Invalid Date`', function () { + var block = areIntervalsOverlapping.bind( + null, + {start: new Date(2016, 10, 3), end: new Date(2016, 10, 7)}, + {start: new Date(2016, 10, 5), end: new Date(NaN)} + ) + assert.throws(block, RangeError) + }) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var earlierIntervalStart = new Date(2016, 9, 25) + var earlierIntervalEnd = new Date(2016, 10, 9) + + var block = areIntervalsOverlapping.bind( + null, + {start: initialIntervalStart, end: initialIntervalEnd}, + {start: earlierIntervalStart, end: earlierIntervalEnd}, + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) }) }) diff --git a/src/closestIndexTo/index.js b/src/closestIndexTo/index.js index 27a9651bad..6f1d011ba5 100644 --- a/src/closestIndexTo/index.js +++ b/src/closestIndexTo/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} dateToCompare - the date to compare with * @param {Date[]|String[]|Number[]} datesArray - the array to search * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} an index of the date closest to the given date + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which date is closer to 6 September 2015? @@ -26,6 +28,11 @@ import toDate from '../toDate/index.js' */ export default function closestIndexTo (dirtyDateToCompare, dirtyDatesArray, dirtyOptions) { var dateToCompare = toDate(dirtyDateToCompare, dirtyOptions) + + if (isNaN(dateToCompare)) { + return NaN + } + var timeToCompare = dateToCompare.getTime() var result @@ -33,6 +40,13 @@ export default function closestIndexTo (dirtyDateToCompare, dirtyDatesArray, dir dirtyDatesArray.forEach(function (dirtyDate, index) { var currentDate = toDate(dirtyDate, dirtyOptions) + + if (isNaN(currentDate)) { + result = NaN + minDistance = NaN + return + } + var distance = Math.abs(timeToCompare - currentDate.getTime()) if (result === undefined || distance < minDistance) { result = index diff --git a/src/closestIndexTo/index.js.flow b/src/closestIndexTo/index.js.flow index bce07e6ba3..b1cb4cb14e 100644 --- a/src/closestIndexTo/index.js.flow +++ b/src/closestIndexTo/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/closestIndexTo/test.js b/src/closestIndexTo/test.js index 75bf80919b..7c12ea8730 100644 --- a/src/closestIndexTo/test.js +++ b/src/closestIndexTo/test.js @@ -47,4 +47,44 @@ describe('closestIndexTo', function () { var result = closestIndexTo(date, []) assert(result === undefined) }) + + it('returns NaN if the given date is `Invalid Date`', function () { + var date = new Date(NaN) + var result = closestIndexTo(date, [ + new Date(2015, 7 /* Aug */, 31), + new Date(2012, 6 /* Jul */, 2) + ]) + assert(isNaN(result)) + }) + + it('returns NaN if any date in the given array is `Invalid Date`', function () { + var date = new Date(2014, 6 /* Jul */, 2) + var result = closestIndexTo(date, [ + new Date(2015, 7 /* Aug */, 31), + new Date(NaN), + new Date(2012, 6 /* Jul */, 2) + ]) + assert(isNaN(result)) + }) + + it('returns NaN if any value in the given array is undefined', function () { + var date = new Date(2014, 6 /* Jul */, 2) + var result = closestIndexTo(date, [ + new Date(2015, 7 /* Aug */, 31), + // $ExpectedMistake + undefined, + new Date(2012, 6 /* Jul */, 2) + ]) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var date = new Date(2014, 6 /* Jul */, 2) + var block = closestIndexTo.bind(null, date, [ + new Date(2015, 7 /* Aug */, 31), + new Date(2012, 6 /* Jul */, 2) + // $ExpectedMistake + ], {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/closestTo/index.js b/src/closestTo/index.js index 16718e7b11..35db90144a 100644 --- a/src/closestTo/index.js +++ b/src/closestTo/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} dateToCompare - the date to compare with * @param {Date[]|String[]|Number[]} datesArray - the array to search * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the date from the array closest to the given date + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which date is closer to 6 September 2015: 1 January 2000 or 1 January 2030? @@ -24,6 +26,11 @@ import toDate from '../toDate/index.js' */ export default function closestTo (dirtyDateToCompare, dirtyDatesArray, dirtyOptions) { var dateToCompare = toDate(dirtyDateToCompare, dirtyOptions) + + if (isNaN(dateToCompare)) { + return new Date(NaN) + } + var timeToCompare = dateToCompare.getTime() var result @@ -31,6 +38,13 @@ export default function closestTo (dirtyDateToCompare, dirtyDatesArray, dirtyOpt dirtyDatesArray.forEach(function (dirtyDate) { var currentDate = toDate(dirtyDate, dirtyOptions) + + if (isNaN(currentDate)) { + result = new Date(NaN) + minDistance = NaN + return + } + var distance = Math.abs(timeToCompare - currentDate.getTime()) if (result === undefined || distance < minDistance) { result = currentDate diff --git a/src/closestTo/index.js.flow b/src/closestTo/index.js.flow index 4fae04feac..270a4c5451 100644 --- a/src/closestTo/index.js.flow +++ b/src/closestTo/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/closestTo/test.js b/src/closestTo/test.js index 158f584ddb..86da9ab80d 100644 --- a/src/closestTo/test.js +++ b/src/closestTo/test.js @@ -47,4 +47,54 @@ describe('closestTo', function () { var result = closestTo(date, []) assert(result === undefined) }) + + it('returns `Invalid Date` if the given date is `Invalid Date`', function () { + var date = new Date(NaN) + var result = closestTo(date, [ + new Date(2015, 7 /* Aug */, 31), + new Date(2012, 6 /* Jul */, 2) + ]) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if any date in the given array is `Invalid Date`', function () { + var date = new Date(2014, 6 /* Jul */, 2) + var result = closestTo(date, [ + new Date(2015, 7 /* Aug */, 31), + new Date(NaN), + new Date(2012, 6 /* Jul */, 2) + ]) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if any date in the given array is `Invalid Date`', function () { + var date = new Date(2014, 6 /* Jul */, 2) + var result = closestTo(date, [ + new Date(2015, 7 /* Aug */, 31), + new Date(NaN), + new Date(2012, 6 /* Jul */, 2) + ]) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if any value in the given array is undefined', function () { + var date = new Date(2014, 6 /* Jul */, 2) + var result = closestTo(date, [ + new Date(2015, 7 /* Aug */, 31), + // $ExpectedMistake + undefined, + new Date(2012, 6 /* Jul */, 2) + ]) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var date = new Date(2014, 6 /* Jul */, 2) + var block = closestTo.bind(null, date, [ + new Date(2015, 7 /* Aug */, 31), + new Date(2012, 6 /* Jul */, 2) + // $ExpectedMistake + ], {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/compareAsc/index.js b/src/compareAsc/index.js index 6bc4ee8ab8..9da45b1455 100644 --- a/src/compareAsc/index.js +++ b/src/compareAsc/index.js @@ -12,7 +12,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} dateLeft - the first date to compare * @param {Date|String|Number} dateRight - the second date to compare * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the result of the comparison + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Compare 11 February 1987 and 10 July 1989: @@ -37,15 +39,16 @@ import toDate from '../toDate/index.js' */ export default function compareAsc (dirtyDateLeft, dirtyDateRight, dirtyOptions) { var dateLeft = toDate(dirtyDateLeft, dirtyOptions) - var timeLeft = dateLeft.getTime() var dateRight = toDate(dirtyDateRight, dirtyOptions) - var timeRight = dateRight.getTime() - if (timeLeft < timeRight) { + var diff = dateLeft.getTime() - dateRight.getTime() + + if (diff < 0) { return -1 - } else if (timeLeft > timeRight) { + } else if (diff > 0) { return 1 + // Return 0 if diff is 0; return NaN if diff is NaN } else { - return 0 + return diff } } diff --git a/src/compareAsc/index.js.flow b/src/compareAsc/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/compareAsc/index.js.flow +++ b/src/compareAsc/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/compareAsc/test.js b/src/compareAsc/test.js index dd4c625df4..efe1f2a239 100644 --- a/src/compareAsc/test.js +++ b/src/compareAsc/test.js @@ -62,4 +62,39 @@ describe('compareAsc', function () { ) assert(result === -1) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = compareAsc( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = compareAsc( + new Date(1989, 6 /* Jul */, 10), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = compareAsc( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = compareAsc.bind( + null, + new Date(1989, 6 /* Jul */, 10), + new Date(1989, 6 /* Jul */, 10), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/compareDesc/index.js b/src/compareDesc/index.js index 8a6d62b324..c59765b49a 100644 --- a/src/compareDesc/index.js +++ b/src/compareDesc/index.js @@ -12,7 +12,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} dateLeft - the first date to compare * @param {Date|String|Number} dateRight - the second date to compare * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the result of the comparison + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Compare 11 February 1987 and 10 July 1989 reverse chronologically: @@ -37,15 +39,16 @@ import toDate from '../toDate/index.js' */ export default function compareDesc (dirtyDateLeft, dirtyDateRight, dirtyOptions) { var dateLeft = toDate(dirtyDateLeft, dirtyOptions) - var timeLeft = dateLeft.getTime() var dateRight = toDate(dirtyDateRight, dirtyOptions) - var timeRight = dateRight.getTime() - if (timeLeft > timeRight) { + var diff = dateLeft.getTime() - dateRight.getTime() + + if (diff > 0) { return -1 - } else if (timeLeft < timeRight) { + } else if (diff < 0) { return 1 + // Return 0 if diff is 0; return NaN if diff is NaN } else { - return 0 + return diff } } diff --git a/src/compareDesc/index.js.flow b/src/compareDesc/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/compareDesc/index.js.flow +++ b/src/compareDesc/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/compareDesc/test.js b/src/compareDesc/test.js index e98432f062..daed9afc8c 100644 --- a/src/compareDesc/test.js +++ b/src/compareDesc/test.js @@ -62,4 +62,39 @@ describe('compareDesc', function () { ) assert(result === 1) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = compareDesc( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = compareDesc( + new Date(1989, 6 /* Jul */, 10), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = compareDesc( + new Date(1989, 6 /* Jul */, 10), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = compareDesc.bind( + null, + new Date(1989, 6 /* Jul */, 10), + new Date(1989, 6 /* Jul */, 10), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInCalendarDays/index.js b/src/differenceInCalendarDays/index.js index da530ba239..72644628f8 100644 --- a/src/differenceInCalendarDays/index.js +++ b/src/differenceInCalendarDays/index.js @@ -14,7 +14,9 @@ var MILLISECONDS_IN_DAY = 86400000 * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of calendar days + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many calendar days are between diff --git a/src/differenceInCalendarDays/index.js.flow b/src/differenceInCalendarDays/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInCalendarDays/index.js.flow +++ b/src/differenceInCalendarDays/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInCalendarDays/test.js b/src/differenceInCalendarDays/test.js index 26ff3ec30b..9b6c4c7151 100644 --- a/src/differenceInCalendarDays/test.js +++ b/src/differenceInCalendarDays/test.js @@ -70,4 +70,39 @@ describe('differenceInCalendarDays', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInCalendarDays( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInCalendarDays( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInCalendarDays( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInCalendarDays.bind( + null, + new Date(2011, 6 /* Jul */, 2, 6, 0), + new Date(2012, 6 /* Jul */, 2, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInCalendarISOWeeks/index.js b/src/differenceInCalendarISOWeeks/index.js index 9bffca2d48..8a51747cbc 100644 --- a/src/differenceInCalendarISOWeeks/index.js +++ b/src/differenceInCalendarISOWeeks/index.js @@ -16,7 +16,9 @@ var MILLISECONDS_IN_WEEK = 604800000 * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of calendar ISO weeks + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many calendar ISO weeks are between 6 July 2014 and 21 July 2014? diff --git a/src/differenceInCalendarISOWeeks/index.js.flow b/src/differenceInCalendarISOWeeks/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInCalendarISOWeeks/index.js.flow +++ b/src/differenceInCalendarISOWeeks/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInCalendarISOWeeks/test.js b/src/differenceInCalendarISOWeeks/test.js index 140a6ad7b1..514b65e7de 100644 --- a/src/differenceInCalendarISOWeeks/test.js +++ b/src/differenceInCalendarISOWeeks/test.js @@ -70,4 +70,39 @@ describe('differenceInCalendarISOWeeks', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInCalendarISOWeeks( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInCalendarISOWeeks( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInCalendarISOWeeks( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInCalendarISOWeeks.bind( + null, + new Date(2014, 5 /* Jun */, 29, 6, 0), + new Date(2014, 6 /* Jul */, 8, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInCalendarISOYears/index.js b/src/differenceInCalendarISOYears/index.js index a77eead492..818b691fbe 100644 --- a/src/differenceInCalendarISOYears/index.js +++ b/src/differenceInCalendarISOYears/index.js @@ -13,7 +13,9 @@ import getISOYear from '../getISOYear/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of calendar ISO week-numbering years + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many calendar ISO week-numbering years are 1 January 2010 and 1 January 2012? diff --git a/src/differenceInCalendarISOYears/index.js.flow b/src/differenceInCalendarISOYears/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInCalendarISOYears/index.js.flow +++ b/src/differenceInCalendarISOYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInCalendarISOYears/test.js b/src/differenceInCalendarISOYears/test.js index 394935e1b3..3057320034 100644 --- a/src/differenceInCalendarISOYears/test.js +++ b/src/differenceInCalendarISOYears/test.js @@ -81,4 +81,39 @@ describe('differenceInCalendarISOYears', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInCalendarISOYears( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInCalendarISOYears( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInCalendarISOYears( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInCalendarISOYears.bind( + null, + new Date(2011, 6 /* Jul */, 2, 6, 0), + new Date(2012, 6 /* Jul */, 2, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInCalendarMonths/index.js b/src/differenceInCalendarMonths/index.js index e0f0201938..812adc5258 100644 --- a/src/differenceInCalendarMonths/index.js +++ b/src/differenceInCalendarMonths/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of calendar months + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many calendar months are between 31 January 2014 and 1 September 2014? diff --git a/src/differenceInCalendarMonths/index.js.flow b/src/differenceInCalendarMonths/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInCalendarMonths/index.js.flow +++ b/src/differenceInCalendarMonths/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInCalendarMonths/test.js b/src/differenceInCalendarMonths/test.js index 2270558472..b76ec8147f 100644 --- a/src/differenceInCalendarMonths/test.js +++ b/src/differenceInCalendarMonths/test.js @@ -70,4 +70,39 @@ describe('differenceInCalendarMonths', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInCalendarMonths( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInCalendarMonths( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInCalendarMonths( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInCalendarMonths.bind( + null, + new Date(2011, 6 /* Jul */, 2, 6, 0), + new Date(2012, 6 /* Jul */, 2, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInCalendarQuarters/index.js b/src/differenceInCalendarQuarters/index.js index 4e21704cee..c4518fe017 100644 --- a/src/differenceInCalendarQuarters/index.js +++ b/src/differenceInCalendarQuarters/index.js @@ -12,7 +12,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of calendar quarters + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many calendar quarters are between 31 December 2013 and 2 July 2014? diff --git a/src/differenceInCalendarQuarters/index.js.flow b/src/differenceInCalendarQuarters/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInCalendarQuarters/index.js.flow +++ b/src/differenceInCalendarQuarters/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInCalendarQuarters/test.js b/src/differenceInCalendarQuarters/test.js index 60cf80d501..6c42688ca8 100644 --- a/src/differenceInCalendarQuarters/test.js +++ b/src/differenceInCalendarQuarters/test.js @@ -70,4 +70,39 @@ describe('differenceInCalendarQuarters', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInCalendarQuarters( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInCalendarQuarters( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInCalendarQuarters( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInCalendarQuarters.bind( + null, + new Date(2011, 6 /* Jul */, 2, 6, 0), + new Date(2012, 6 /* Jul */, 2, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInCalendarWeeks/index.js b/src/differenceInCalendarWeeks/index.js index d39bb19021..491d13983b 100644 --- a/src/differenceInCalendarWeeks/index.js +++ b/src/differenceInCalendarWeeks/index.js @@ -14,8 +14,11 @@ var MILLISECONDS_IN_WEEK = 604800000 * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} - * @param {Number} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} + * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) * @returns {Number} the number of calendar weeks + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6 * * @example * // How many calendar weeks are between 5 July 2014 and 20 July 2014? diff --git a/src/differenceInCalendarWeeks/index.js.flow b/src/differenceInCalendarWeeks/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInCalendarWeeks/index.js.flow +++ b/src/differenceInCalendarWeeks/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInCalendarWeeks/test.js b/src/differenceInCalendarWeeks/test.js index b87e4076cc..058004162a 100644 --- a/src/differenceInCalendarWeeks/test.js +++ b/src/differenceInCalendarWeeks/test.js @@ -89,4 +89,50 @@ describe('differenceInCalendarWeeks', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInCalendarWeeks( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInCalendarWeeks( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInCalendarWeeks( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.weekStartsOn` is not convertable to 0, 1, ..., 6 or undefined', function () { + var block = differenceInCalendarWeeks.bind( + null, + new Date(2014, 6 /* Jul */, 8, 18, 0), + new Date(2014, 5 /* Jun */, 29, 6, 0), + // $ExpectedMistake + {weekStartsOn: NaN} + ) + assert.throws(block, RangeError) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInCalendarWeeks.bind( + null, + new Date(2014, 5 /* Jun */, 29, 6, 0), + new Date(2014, 6 /* Jul */, 8, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInCalendarYears/index.js b/src/differenceInCalendarYears/index.js index ccf90bf4c5..a4fd475e3c 100644 --- a/src/differenceInCalendarYears/index.js +++ b/src/differenceInCalendarYears/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of calendar years + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many calendar years are between 31 December 2013 and 11 February 2015? diff --git a/src/differenceInCalendarYears/index.js.flow b/src/differenceInCalendarYears/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInCalendarYears/index.js.flow +++ b/src/differenceInCalendarYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInCalendarYears/test.js b/src/differenceInCalendarYears/test.js index 305492e94c..4fd7a5c17d 100644 --- a/src/differenceInCalendarYears/test.js +++ b/src/differenceInCalendarYears/test.js @@ -70,4 +70,39 @@ describe('differenceInCalendarYears', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInCalendarYears( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInCalendarYears( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInCalendarYears( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInCalendarYears.bind( + null, + new Date(2011, 6 /* Jul */, 2, 6, 0), + new Date(2012, 6 /* Jul */, 2, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInDays/index.js b/src/differenceInDays/index.js index aef7ef180c..5838875b15 100644 --- a/src/differenceInDays/index.js +++ b/src/differenceInDays/index.js @@ -13,7 +13,9 @@ import compareDesc from '../compareDesc/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of full days + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many full days are between diff --git a/src/differenceInDays/index.js.flow b/src/differenceInDays/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInDays/index.js.flow +++ b/src/differenceInDays/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInDays/test.js b/src/differenceInDays/test.js index 7f61f0a85a..115454d293 100644 --- a/src/differenceInDays/test.js +++ b/src/differenceInDays/test.js @@ -70,4 +70,39 @@ describe('differenceInDays', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInDays( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInDays( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInDays( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInDays.bind( + this, + new Date(2011, 6 /* Jul */, 2, 6, 0), + new Date(2012, 6 /* Jul */, 2, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInHours/index.js b/src/differenceInHours/index.js index 1784951a16..b7f6ea697b 100644 --- a/src/differenceInHours/index.js +++ b/src/differenceInHours/index.js @@ -13,7 +13,9 @@ var MILLISECONDS_IN_HOUR = 3600000 * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of hours + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00? diff --git a/src/differenceInHours/index.js.flow b/src/differenceInHours/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInHours/index.js.flow +++ b/src/differenceInHours/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInHours/test.js b/src/differenceInHours/test.js index 4ef640a4dc..4935110e33 100644 --- a/src/differenceInHours/test.js +++ b/src/differenceInHours/test.js @@ -70,4 +70,39 @@ describe('differenceInHours', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInHours( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInHours( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInHours( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInHours.bind( + this, + new Date(2014, 6 /* Jul */, 2, 6, 0), + new Date(2014, 6 /* Jul */, 2, 20, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInISOYears/index.js b/src/differenceInISOYears/index.js index e5b333264c..9637835ddf 100644 --- a/src/differenceInISOYears/index.js +++ b/src/differenceInISOYears/index.js @@ -16,7 +16,9 @@ import subISOYears from '../subISOYears/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of full ISO week-numbering years + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many full ISO week-numbering years are between 1 January 2010 and 1 January 2012? diff --git a/src/differenceInISOYears/index.js.flow b/src/differenceInISOYears/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInISOYears/index.js.flow +++ b/src/differenceInISOYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInISOYears/test.js b/src/differenceInISOYears/test.js index f9ae9c28c4..e0cb186570 100644 --- a/src/differenceInISOYears/test.js +++ b/src/differenceInISOYears/test.js @@ -81,4 +81,39 @@ describe('differenceInISOYears', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInISOYears( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInISOYears( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInISOYears( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInISOYears.bind( + this, + new Date(2011, 6 /* Jul */, 2, 6, 0), + new Date(2012, 6 /* Jul */, 2, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInMilliseconds/index.js b/src/differenceInMilliseconds/index.js index c1a9948396..87e604a2ad 100644 --- a/src/differenceInMilliseconds/index.js +++ b/src/differenceInMilliseconds/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of milliseconds + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many milliseconds are between diff --git a/src/differenceInMilliseconds/index.js.flow b/src/differenceInMilliseconds/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInMilliseconds/index.js.flow +++ b/src/differenceInMilliseconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInMilliseconds/test.js b/src/differenceInMilliseconds/test.js index d36449e059..03759adf4e 100644 --- a/src/differenceInMilliseconds/test.js +++ b/src/differenceInMilliseconds/test.js @@ -36,4 +36,39 @@ describe('differenceInMilliseconds', function () { ) assert(result === 0) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInMilliseconds( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInMilliseconds( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInMilliseconds( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInMilliseconds.bind( + this, + new Date(2014, 6 /* Jul */, 2, 12, 30, 20, 600), + new Date(2014, 6 /* Jul */, 2, 12, 30, 20, 700), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInMinutes/index.js b/src/differenceInMinutes/index.js index 1e50d7b8e5..8e580a7756 100644 --- a/src/differenceInMinutes/index.js +++ b/src/differenceInMinutes/index.js @@ -13,7 +13,9 @@ var MILLISECONDS_IN_MINUTE = 60000 * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of minutes + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00? diff --git a/src/differenceInMinutes/index.js.flow b/src/differenceInMinutes/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInMinutes/index.js.flow +++ b/src/differenceInMinutes/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInMinutes/test.js b/src/differenceInMinutes/test.js index 60fd17c88f..d7aebbd6be 100644 --- a/src/differenceInMinutes/test.js +++ b/src/differenceInMinutes/test.js @@ -70,4 +70,39 @@ describe('differenceInMinutes', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInMinutes( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInMinutes( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInMinutes( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInMinutes.bind( + this, + new Date(2014, 6 /* Jul */, 2, 12, 6), + new Date(2014, 6 /* Jul */, 2, 12, 20), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInMonths/index.js b/src/differenceInMonths/index.js index e97e2013b1..aeb6de36e1 100644 --- a/src/differenceInMonths/index.js +++ b/src/differenceInMonths/index.js @@ -13,7 +13,9 @@ import compareDesc from '../compareDesc/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of full months + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many full months are between 31 January 2014 and 1 September 2014? diff --git a/src/differenceInMonths/index.js.flow b/src/differenceInMonths/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInMonths/index.js.flow +++ b/src/differenceInMonths/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInMonths/test.js b/src/differenceInMonths/test.js index b4358799cb..f94aaff675 100644 --- a/src/differenceInMonths/test.js +++ b/src/differenceInMonths/test.js @@ -70,4 +70,39 @@ describe('differenceInMonths', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInMonths( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInMonths( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInMonths( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInMonths.bind( + this, + new Date(2011, 6 /* Jul */, 2, 6, 0), + new Date(2012, 6 /* Jul */, 2, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInQuarters/index.js b/src/differenceInQuarters/index.js index cf42778835..be7ce83bb0 100644 --- a/src/differenceInQuarters/index.js +++ b/src/differenceInQuarters/index.js @@ -11,7 +11,9 @@ import differenceInMonths from '../differenceInMonths/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of full quarters + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many full quarters are between 31 December 2013 and 2 July 2014? diff --git a/src/differenceInQuarters/index.js.flow b/src/differenceInQuarters/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInQuarters/index.js.flow +++ b/src/differenceInQuarters/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInQuarters/test.js b/src/differenceInQuarters/test.js index cba87cb5b0..d38ea2a383 100644 --- a/src/differenceInQuarters/test.js +++ b/src/differenceInQuarters/test.js @@ -70,4 +70,39 @@ describe('differenceInQuarters', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInQuarters( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInQuarters( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInQuarters( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInQuarters.bind( + this, + new Date(2011, 6 /* Jul */, 2, 6, 0), + new Date(2012, 6 /* Jul */, 2, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInSeconds/index.js b/src/differenceInSeconds/index.js index 3d277c42c6..afed3338b5 100644 --- a/src/differenceInSeconds/index.js +++ b/src/differenceInSeconds/index.js @@ -11,7 +11,9 @@ import differenceInMilliseconds from '../differenceInMilliseconds/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of seconds + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many seconds are between diff --git a/src/differenceInSeconds/index.js.flow b/src/differenceInSeconds/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInSeconds/index.js.flow +++ b/src/differenceInSeconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInSeconds/test.js b/src/differenceInSeconds/test.js index a5f9bfa990..ee18df659f 100644 --- a/src/differenceInSeconds/test.js +++ b/src/differenceInSeconds/test.js @@ -70,4 +70,39 @@ describe('differenceInSeconds', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInSeconds( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInSeconds( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInSeconds( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInSeconds.bind( + this, + new Date(2014, 6 /* Jul */, 2, 12, 30, 6), + new Date(2014, 6 /* Jul */, 2, 12, 30, 20), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInWeeks/index.js b/src/differenceInWeeks/index.js index fd0c30ccfd..928fee2b16 100644 --- a/src/differenceInWeeks/index.js +++ b/src/differenceInWeeks/index.js @@ -11,7 +11,9 @@ import differenceInDays from '../differenceInDays/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of full weeks + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many full weeks are between 5 July 2014 and 20 July 2014? diff --git a/src/differenceInWeeks/index.js.flow b/src/differenceInWeeks/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInWeeks/index.js.flow +++ b/src/differenceInWeeks/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInWeeks/test.js b/src/differenceInWeeks/test.js index 28021afb9a..6223761225 100644 --- a/src/differenceInWeeks/test.js +++ b/src/differenceInWeeks/test.js @@ -70,4 +70,39 @@ describe('differenceInWeeks', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInWeeks( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInWeeks( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInWeeks( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInWeeks.bind( + this, + new Date(2014, 5 /* Jun */, 29, 6, 0), + new Date(2014, 6 /* Jul */, 8, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/differenceInYears/index.js b/src/differenceInYears/index.js index 9259d7d56d..75ad3b6fa5 100644 --- a/src/differenceInYears/index.js +++ b/src/differenceInYears/index.js @@ -13,7 +13,9 @@ import compareDesc from '../compareDesc/index.js' * @param {Date|String|Number} dateLeft - the earlier date * @param {Date|String|Number} dateRight - the later date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of full years + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many full years are between 31 December 2013 and 11 February 2015? diff --git a/src/differenceInYears/index.js.flow b/src/differenceInYears/index.js.flow index 6b9ba97596..a94a39f3bf 100644 --- a/src/differenceInYears/index.js.flow +++ b/src/differenceInYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/differenceInYears/test.js b/src/differenceInYears/test.js index 212abb84d0..5052489d1c 100644 --- a/src/differenceInYears/test.js +++ b/src/differenceInYears/test.js @@ -70,4 +70,39 @@ describe('differenceInYears', function () { assert(result === 0) }) }) + + it('returns NaN if the first date is `Invalid Date`', function () { + var result = differenceInYears( + new Date(NaN), + new Date(2017, 0 /* Jan */, 1) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the second date is `Invalid Date`', function () { + var result = differenceInYears( + new Date(2017, 0 /* Jan */, 1), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('returns NaN if the both dates are `Invalid Date`', function () { + var result = differenceInYears( + new Date(NaN), + new Date(NaN) + ) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = differenceInYears.bind( + this, + new Date(2011, 6 /* Jul */, 2, 6, 0), + new Date(2012, 6 /* Jul */, 2, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/distanceInWords/index.js b/src/distanceInWords/index.js index e870f694d4..121a8ffbcc 100644 --- a/src/distanceInWords/index.js +++ b/src/distanceInWords/index.js @@ -49,10 +49,12 @@ var MINUTES_IN_TWO_MONTHS = 86400 * @param {Date|String|Number} dateToCompare - the date to compare with * @param {Date|String|Number} date - the other date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @param {Boolean} [options.includeSeconds=false] - distances less than a minute are more detailed * @param {Boolean} [options.addSuffix=false] - result indicates if the second date is earlier or later than the first * @param {Locale} [options.locale=enLocale] - the locale object. See [Locale]{@link docs/Locale} * @returns {String} the distance in words + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // What is the distance between 2 July 2014 and 1 January 2015? @@ -97,6 +99,10 @@ export default function distanceInWords (dirtyDateToCompare, dirtyDate, dirtyOpt var comparison = compareDesc(dirtyDateToCompare, dirtyDate, options) + if (isNaN(comparison)) { + return 'Invalid Date' + } + var locale = options.locale var localize = enLocale.distanceInWords.localize if (locale && locale.distanceInWords && locale.distanceInWords.localize) { diff --git a/src/distanceInWords/index.js.flow b/src/distanceInWords/index.js.flow index eeb8b57a97..f186cdb318 100644 --- a/src/distanceInWords/index.js.flow +++ b/src/distanceInWords/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/distanceInWords/test.js b/src/distanceInWords/test.js index 7dabd972f6..d02535d315 100644 --- a/src/distanceInWords/test.js +++ b/src/distanceInWords/test.js @@ -292,4 +292,39 @@ describe('distanceInWords', function () { }) }) }) + + it("returns String('Invalid Date') if the first date is `Invalid Date`", function () { + var result = distanceInWords( + new Date(NaN), + new Date(1986, 3, 7, 10, 32, 0) + ) + assert(result === 'Invalid Date') + }) + + it("returns String('Invalid Date') if the second date is `Invalid Date`", function () { + var result = distanceInWords( + new Date(1986, 3, 4, 10, 32, 0), + new Date(NaN) + ) + assert(result === 'Invalid Date') + }) + + it("returns String('Invalid Date') if the both dates are `Invalid Date`", function () { + var result = distanceInWords( + new Date(NaN), + new Date(NaN) + ) + assert(result === 'Invalid Date') + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = distanceInWords.bind( + this, + new Date(1986, 3, 4, 10, 32, 0), + new Date(1986, 3, 4, 10, 32, 3), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/distanceInWordsStrict/index.js b/src/distanceInWordsStrict/index.js index 1baecae9eb..3ea9e47f7b 100644 --- a/src/distanceInWordsStrict/index.js +++ b/src/distanceInWordsStrict/index.js @@ -29,11 +29,15 @@ var MINUTES_IN_YEAR = 525600 * @param {Date|String|Number} dateToCompare - the date to compare with * @param {Date|String|Number} date - the other date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @param {Boolean} [options.addSuffix=false] - result indicates if the second date is earlier or later than the first * @param {'s'|'m'|'h'|'d'|'M'|'Y'} [options.unit] - if specified, will force a unit - * @param {'floor'|'ceil'|'round'} [options.partialMethod='floor'] - which way to round partial units + * @param {'floor'|'ceil'|'round'} [options.roundingMethod='floor'] - which way to round partial units * @param {Locale} [options.locale=enLocale] - the locale object. See [Locale]{@link docs/Locale} * @returns {String} the distance in words + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} `options.roundingMethod` must be 'floor', 'ceil' or 'round' + * @throws {RangeError} `options.unit` must be 's', 'm', 'h', 'd', 'M' or 'Y' * * @example * // What is the distance between 2 July 2014 and 1 January 2015? @@ -78,7 +82,7 @@ var MINUTES_IN_YEAR = 525600 * var result = distanceInWordsStrict( * new Date(2015, 0, 28), * new Date(2015, 0, 1), - * {unit: 'M', partialMethod: 'ceil'} + * {unit: 'M', roundingMethod: 'ceil'} * ) * //=> '1 month' * @@ -97,6 +101,10 @@ export default function distanceInWordsStrict (dirtyDateToCompare, dirtyDate, di var comparison = compareDesc(dirtyDateToCompare, dirtyDate, options) + if (isNaN(comparison)) { + return 'Invalid Date' + } + var locale = options.locale var localize = enLocale.distanceInWords.localize if (locale && locale.distanceInWords && locale.distanceInWords.localize) { @@ -117,16 +125,25 @@ export default function distanceInWordsStrict (dirtyDateToCompare, dirtyDate, di dateRight = toDate(dirtyDateToCompare, options) } - var unit - var mathPartial = Math[options.partialMethod ? String(options.partialMethod) : 'floor'] + var roundingMethod = options.roundingMethod === undefined ? 'floor' : String(options.roundingMethod) + var roundingMethodFn + + if (roundingMethod === 'floor') { + roundingMethodFn = Math.floor + } else if (roundingMethod === 'ceil') { + roundingMethodFn = Math.ceil + } else if (roundingMethod === 'round') { + roundingMethodFn = Math.round + } else { + throw new RangeError("roundingMethod must be 'floor', 'ceil' or 'round'") + } + var seconds = differenceInSeconds(dateLeft, dateRight, dirtyOptions) var offset = dateRight.getTimezoneOffset() - dateLeft.getTimezoneOffset() - var minutes = mathPartial(seconds / 60) - offset - var hours, days, months, years + var minutes = roundingMethodFn(seconds / 60) - offset - if (options.unit) { - unit = String(options.unit) - } else { + var unit + if (options.unit === undefined) { if (minutes < 1) { unit = 's' } else if (minutes < 60) { @@ -140,6 +157,8 @@ export default function distanceInWordsStrict (dirtyDateToCompare, dirtyDate, di } else { unit = 'Y' } + } else { + unit = String(options.unit) } // 0 up to 60 seconds @@ -152,24 +171,24 @@ export default function distanceInWordsStrict (dirtyDateToCompare, dirtyDate, di // 1 up to 24 hours } else if (unit === 'h') { - hours = mathPartial(minutes / 60) + var hours = roundingMethodFn(minutes / 60) return localize('xHours', hours, localizeOptions) // 1 up to 30 days } else if (unit === 'd') { - days = mathPartial(minutes / MINUTES_IN_DAY) + var days = roundingMethodFn(minutes / MINUTES_IN_DAY) return localize('xDays', days, localizeOptions) // 1 up to 12 months } else if (unit === 'M') { - months = mathPartial(minutes / MINUTES_IN_MONTH) + var months = roundingMethodFn(minutes / MINUTES_IN_MONTH) return localize('xMonths', months, localizeOptions) // 1 year up to max Date } else if (unit === 'Y') { - years = mathPartial(minutes / MINUTES_IN_YEAR) + var years = roundingMethodFn(minutes / MINUTES_IN_YEAR) return localize('xYears', years, localizeOptions) } - throw new Error('Unknown unit: ' + unit) + throw new RangeError("unit must be 's', 'm', 'h', 'd', 'M' or 'Y'") } diff --git a/src/distanceInWordsStrict/index.js.flow b/src/distanceInWordsStrict/index.js.flow index eeb8b57a97..f186cdb318 100644 --- a/src/distanceInWordsStrict/index.js.flow +++ b/src/distanceInWordsStrict/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/distanceInWordsStrict/test.js b/src/distanceInWordsStrict/test.js index d1d56a2bcc..6e92e7c397 100644 --- a/src/distanceInWordsStrict/test.js +++ b/src/distanceInWordsStrict/test.js @@ -314,7 +314,7 @@ describe('distanceInWordsStrict', function () { }) }) - describe('when the partialMethod option is supplied', function () { + describe('when the roundingMethod option is supplied', function () { it('default is "floor"', function () { var result = distanceInWordsStrict( new Date(1986, 3, 4, 10, 32, 0), @@ -327,7 +327,7 @@ describe('distanceInWordsStrict', function () { var result = distanceInWordsStrict( new Date(1986, 3, 4, 10, 32, 0), new Date(1986, 3, 4, 10, 33, 59), - {partialMethod: 'floor'} + {roundingMethod: 'floor'} ) assert(result === '1 minute') }) @@ -336,7 +336,7 @@ describe('distanceInWordsStrict', function () { var result = distanceInWordsStrict( new Date(1986, 3, 4, 10, 32, 0), new Date(1986, 3, 4, 10, 33, 1), - {partialMethod: 'ceil'} + {roundingMethod: 'ceil'} ) assert(result === '2 minutes') }) @@ -345,7 +345,7 @@ describe('distanceInWordsStrict', function () { var result = distanceInWordsStrict( new Date(1986, 3, 4, 10, 32, 0), new Date(1986, 3, 4, 10, 33, 29), - {partialMethod: 'round'} + {roundingMethod: 'round'} ) assert(result === '1 minute') }) @@ -354,7 +354,7 @@ describe('distanceInWordsStrict', function () { var result = distanceInWordsStrict( new Date(1986, 3, 4, 10, 32, 0), new Date(1986, 3, 4, 10, 33, 30), - {partialMethod: 'round'} + {roundingMethod: 'round'} ) assert(result === '2 minutes') }) @@ -386,13 +386,13 @@ describe('distanceInWordsStrict', function () { it('`options.ceil`', function () { // eslint-disable-next-line no-new-wrappers - var partialMethod = new String('ceil') + var roundingMethod = new String('ceil') var result = distanceInWordsStrict( new Date(1986, 3, 4, 10, 32, 0), new Date(1986, 3, 4, 10, 33, 1), // $ExpectedMistake - {partialMethod: partialMethod} + {roundingMethod: roundingMethod} ) assert(result === '2 minutes') }) @@ -447,4 +447,61 @@ describe('distanceInWordsStrict', function () { }) }) }) + + it("returns String('Invalid Date') if the first date is `Invalid Date`", function () { + var result = distanceInWordsStrict( + new Date(NaN), + new Date(1986, 3, 7, 10, 32, 0) + ) + assert(result === 'Invalid Date') + }) + + it("returns String('Invalid Date') if the second date is `Invalid Date`", function () { + var result = distanceInWordsStrict( + new Date(1986, 3, 4, 10, 32, 0), + new Date(NaN) + ) + assert(result === 'Invalid Date') + }) + + it("returns String('Invalid Date') if the both dates are `Invalid Date`", function () { + var result = distanceInWordsStrict( + new Date(NaN), + new Date(NaN) + ) + assert(result === 'Invalid Date') + }) + + it("throws `RangeError` if `options.roundingMethod` is not 'floor', 'ceil', 'round' or undefined", function () { + var block = distanceInWordsStrict.bind( + null, + new Date(1986, 3, 4, 10, 32, 0), + new Date(1986, 3, 4, 10, 33, 29), + // $ExpectedMistake + {roundingMethod: 'foobar'} + ) + assert.throws(block, RangeError) + }) + + it("throws `RangeError` if `options.unit` is not 's', 'm', 'h', 'd', 'M', 'Y' or undefined", function () { + var block = distanceInWordsStrict.bind( + null, + new Date(1986, 3, 4, 10, 32, 0), + new Date(1986, 3, 4, 10, 33, 29), + // $ExpectedMistake + {unit: 'foobar'} + ) + assert.throws(block, RangeError) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = distanceInWordsStrict.bind( + this, + new Date(1986, 3, 4, 10, 32, 5), + new Date(1986, 3, 4, 10, 32, 5), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/eachDayOfInterval/index.js b/src/eachDayOfInterval/index.js index f1e5d1f5aa..557e9951c5 100644 --- a/src/eachDayOfInterval/index.js +++ b/src/eachDayOfInterval/index.js @@ -10,8 +10,11 @@ import toDate from '../toDate/index.js' * * @param {Interval} interval - the interval. See [Interval]{@link docs/types/Interval} * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date[]} the array with starts of days from the day of the interval start to the day of the interval end - * @throws {Error} The start of an interval cannot be after its end + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} The start of an interval cannot be after its end + * @throws {RangeError} Date in interval cannot be `Invalid Date` * * @example * // Each day between 6 October 2014 and 10 October 2014: @@ -33,8 +36,9 @@ export default function eachDayOfInterval (dirtyInterval, dirtyOptions) { var endTime = endDate.getTime() - if (startDate.getTime() > endTime) { - throw new Error('The start of an interval cannot be after its end') + // Throw an exception if start date is after end date or if any date is `Invalid Date` + if (!(startDate.getTime() <= endTime)) { + throw new RangeError('Invalid interval') } var dates = [] diff --git a/src/eachDayOfInterval/index.js.flow b/src/eachDayOfInterval/index.js.flow index ca7f1f7048..0a9809c197 100644 --- a/src/eachDayOfInterval/index.js.flow +++ b/src/eachDayOfInterval/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/eachDayOfInterval/test.js b/src/eachDayOfInterval/test.js index 3cb2ffb72f..200f74bf2b 100644 --- a/src/eachDayOfInterval/test.js +++ b/src/eachDayOfInterval/test.js @@ -97,6 +97,37 @@ describe('eachDayOfInterval', function () { end: new Date(2014, 9 /* Oct */, 6) } ) - assert.throws(block) + assert.throws(block, RangeError) + }) + + it('throws an exception if the start date is `Invalid Date`', function () { + var block = eachDayOfInterval.bind( + null, + { + start: new Date(NaN), + end: new Date(2014, 9 /* Oct */, 6) + } + ) + assert.throws(block, RangeError) + }) + + it('throws an exception if the end date is `Invalid Date`', function () { + var block = eachDayOfInterval.bind( + null, + { + start: new Date(2014, 9 /* Oct */, 12), + end: new Date(NaN) + } + ) + assert.throws(block, RangeError) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = eachDayOfInterval.bind(this, { + start: new Date(2014, 9 /* Oct */, 6), + end: new Date(2014, 9 /* Oct */, 12) + // $ExpectedMistake + }, {additionalDigits: NaN}) + assert.throws(block, RangeError) }) }) diff --git a/src/endOfDay/index.js b/src/endOfDay/index.js index 0b7e7b9524..e57b63cc5d 100644 --- a/src/endOfDay/index.js +++ b/src/endOfDay/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the end of a day + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The end of a day for 2 September 2014 11:55:00: diff --git a/src/endOfDay/index.js.flow b/src/endOfDay/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/endOfDay/index.js.flow +++ b/src/endOfDay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/endOfDay/test.js b/src/endOfDay/test.js index de9229e457..e1db045dde 100644 --- a/src/endOfDay/test.js +++ b/src/endOfDay/test.js @@ -34,4 +34,16 @@ describe('endOfDay', function () { endOfDay(date) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = endOfDay(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = endOfDay.bind(this, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/endOfHour/index.js b/src/endOfHour/index.js index 364b37bd7e..7be614ce1c 100644 --- a/src/endOfHour/index.js +++ b/src/endOfHour/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the end of an hour + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The end of an hour for 2 September 2014 11:55:00: diff --git a/src/endOfHour/index.js.flow b/src/endOfHour/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/endOfHour/index.js.flow +++ b/src/endOfHour/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/endOfHour/test.js b/src/endOfHour/test.js index b414bc0f68..ae3307c8fe 100644 --- a/src/endOfHour/test.js +++ b/src/endOfHour/test.js @@ -27,4 +27,16 @@ describe('endOfHour', function () { endOfHour(date) assert.deepEqual(date, new Date(2014, 11, 1, 22, 15)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = endOfHour(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var date = new Date(2014, 11, 1, 22, 15) + // $ExpectedMistake + var block = endOfHour.bind(this, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/endOfISOWeek/index.js b/src/endOfISOWeek/index.js index fd4fd3d269..130ac85244 100644 --- a/src/endOfISOWeek/index.js +++ b/src/endOfISOWeek/index.js @@ -14,7 +14,9 @@ import cloneObject from '../_lib/cloneObject/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the end of an ISO week + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The end of an ISO week for 2 September 2014 11:55:00: diff --git a/src/endOfISOWeek/index.js.flow b/src/endOfISOWeek/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/endOfISOWeek/index.js.flow +++ b/src/endOfISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/endOfISOWeek/test.js b/src/endOfISOWeek/test.js index 0cba8840f8..d2b43092de 100644 --- a/src/endOfISOWeek/test.js +++ b/src/endOfISOWeek/test.js @@ -34,4 +34,16 @@ describe('endOfISOWeek', function () { endOfISOWeek(date) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = endOfISOWeek(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = endOfISOWeek.bind(this, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/endOfISOYear/index.js b/src/endOfISOYear/index.js index 8d5aa3d2a6..3e203ca929 100644 --- a/src/endOfISOYear/index.js +++ b/src/endOfISOYear/index.js @@ -15,7 +15,9 @@ import startOfISOWeek from '../startOfISOWeek/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the end of an ISO week-numbering year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The end of an ISO week-numbering year for 2 July 2005: diff --git a/src/endOfISOYear/index.js.flow b/src/endOfISOYear/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/endOfISOYear/index.js.flow +++ b/src/endOfISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/endOfISOYear/test.js b/src/endOfISOYear/test.js index b3c12f5180..273369278c 100644 --- a/src/endOfISOYear/test.js +++ b/src/endOfISOYear/test.js @@ -36,4 +36,15 @@ describe('endOfISOYear', function () { var result = endOfISOYear(initialDate) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = endOfISOYear(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = endOfISOYear.bind(this, new Date(2009, 0 /* Jan */, 1, 16, 0), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/endOfMinute/index.js b/src/endOfMinute/index.js index a701b9ab15..d3c6c75dd9 100644 --- a/src/endOfMinute/index.js +++ b/src/endOfMinute/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the end of a minute + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The end of a minute for 1 December 2014 22:15:45.400: diff --git a/src/endOfMinute/index.js.flow b/src/endOfMinute/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/endOfMinute/index.js.flow +++ b/src/endOfMinute/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/endOfMinute/test.js b/src/endOfMinute/test.js index a3cd7291ca..8eddba92b7 100644 --- a/src/endOfMinute/test.js +++ b/src/endOfMinute/test.js @@ -26,4 +26,16 @@ describe('endOfMinute', function () { endOfMinute(date) assert.deepEqual(date, new Date(2014, 11, 1, 22, 15)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = endOfMinute(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var date = new Date(2014, 11, 1, 22, 15) + // $ExpectedMistake + var block = endOfMinute.bind(this, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/endOfMonth/index.js b/src/endOfMonth/index.js index fcc9080090..2c42e5aef6 100644 --- a/src/endOfMonth/index.js +++ b/src/endOfMonth/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the end of a month + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The end of a month for 2 September 2014 11:55:00: diff --git a/src/endOfMonth/index.js.flow b/src/endOfMonth/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/endOfMonth/index.js.flow +++ b/src/endOfMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/endOfMonth/test.js b/src/endOfMonth/test.js index 0d76bd1836..1fe138d0e1 100644 --- a/src/endOfMonth/test.js +++ b/src/endOfMonth/test.js @@ -52,4 +52,16 @@ describe('endOfMonth', function () { ) }) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = endOfMonth(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = endOfMonth.bind(this, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/endOfQuarter/index.js b/src/endOfQuarter/index.js index 3e179f7a74..d922a8c381 100644 --- a/src/endOfQuarter/index.js +++ b/src/endOfQuarter/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the end of a quarter + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The end of a quarter for 2 September 2014 11:55:00: diff --git a/src/endOfQuarter/index.js.flow b/src/endOfQuarter/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/endOfQuarter/index.js.flow +++ b/src/endOfQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/endOfQuarter/test.js b/src/endOfQuarter/test.js index 782da15fd0..1f05168b05 100644 --- a/src/endOfQuarter/test.js +++ b/src/endOfQuarter/test.js @@ -28,4 +28,16 @@ describe('endOfQuarter', function () { endOfQuarter(date) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = endOfQuarter(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = endOfQuarter.bind(this, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/endOfSecond/index.js b/src/endOfSecond/index.js index 995067395d..3761af3876 100644 --- a/src/endOfSecond/index.js +++ b/src/endOfSecond/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the end of a second + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The end of a second for 1 December 2014 22:15:45.400: diff --git a/src/endOfSecond/index.js.flow b/src/endOfSecond/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/endOfSecond/index.js.flow +++ b/src/endOfSecond/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/endOfSecond/test.js b/src/endOfSecond/test.js index ac1d24a117..3ce3978461 100644 --- a/src/endOfSecond/test.js +++ b/src/endOfSecond/test.js @@ -26,4 +26,16 @@ describe('endOfSecond', function () { endOfSecond(date) assert.deepEqual(date, new Date(2014, 11, 1, 22, 15, 15, 300)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = endOfSecond(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var date = new Date(2014, 11, 1, 22, 15, 30) + // $ExpectedMistake + var block = endOfSecond.bind(this, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/endOfWeek/index.js b/src/endOfWeek/index.js index ef2b1b23f4..e2ba089f19 100644 --- a/src/endOfWeek/index.js +++ b/src/endOfWeek/index.js @@ -11,8 +11,11 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} - * @param {Number} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} + * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) * @returns {Date} the end of a week + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6 * * @example * // The end of a week for 2 September 2014 11:55:00: @@ -25,9 +28,15 @@ import toDate from '../toDate/index.js' * //=> Sun Sep 07 2014 23:59:59.999 */ export default function endOfWeek (dirtyDate, dirtyOptions) { - var weekStartsOn = dirtyOptions ? (Number(dirtyOptions.weekStartsOn) || 0) : 0 + var options = dirtyOptions || {} + var weekStartsOn = options.weekStartsOn === undefined ? 0 : Number(options.weekStartsOn) - var date = toDate(dirtyDate, dirtyOptions) + // Test if weekStartsOn is between 0 and 6 _and_ is not NaN + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError('weekStartsOn must be between 0 and 6 inclusively') + } + + var date = toDate(dirtyDate, options) var day = date.getDay() var diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn) diff --git a/src/endOfWeek/index.js.flow b/src/endOfWeek/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/endOfWeek/index.js.flow +++ b/src/endOfWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/endOfWeek/test.js b/src/endOfWeek/test.js index 94763b3e43..385c03d69b 100644 --- a/src/endOfWeek/test.js +++ b/src/endOfWeek/test.js @@ -83,4 +83,22 @@ describe('endOfWeek', function () { assert.deepEqual(result, new Date(2015, 0 /* Jan */, 1, 23, 59, 59, 999)) }) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = endOfWeek(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.weekStartsOn` is not convertable to 0, 1, ..., 6 or undefined', function () { + // $ExpectedMistake + var block = endOfWeek.bind(null, new Date(2014, 8 /* Sep */, 2, 11, 55, 0), {weekStartsOn: NaN}) + assert.throws(block, RangeError) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = endOfWeek.bind(this, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/endOfYear/index.js b/src/endOfYear/index.js index 375e782da8..6d43d6900b 100644 --- a/src/endOfYear/index.js +++ b/src/endOfYear/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the end of a year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The end of a year for 2 September 2014 11:55:00: diff --git a/src/endOfYear/index.js.flow b/src/endOfYear/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/endOfYear/index.js.flow +++ b/src/endOfYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/endOfYear/test.js b/src/endOfYear/test.js index 4d8a97d63a..aadea5f9b0 100644 --- a/src/endOfYear/test.js +++ b/src/endOfYear/test.js @@ -34,4 +34,16 @@ describe('endOfMonth', function () { endOfYear(date) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = endOfYear(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = endOfYear.bind(this, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/format/index.js b/src/format/index.js index 47a3a63bd4..8d15df7ce8 100644 --- a/src/format/index.js +++ b/src/format/index.js @@ -70,8 +70,10 @@ import getUTCISOYear from './_lib/getUTCISOYear/index.js' * @param {Date|String|Number} date - the original date * @param {String} format - the string of tokens * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @param {Locale} [options.locale=enLocale] - the locale object. See [Locale]{@link docs/Locale} * @returns {String} the formatted date string + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Represent 11 February 2014 in middle-endian format: diff --git a/src/format/index.js.flow b/src/format/index.js.flow index 75c1984b2f..3a16ac9737 100644 --- a/src/format/index.js.flow +++ b/src/format/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/format/test.js b/src/format/test.js index c15a94eb38..caac26d5b2 100644 --- a/src/format/test.js +++ b/src/format/test.js @@ -399,4 +399,10 @@ describe('format', function () { }) }) }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = format.bind(this, date, 'Do of t[h][e] Mo in YYYY', {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/fp/addDays/index.js.flow b/src/fp/addDays/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/addDays/index.js.flow +++ b/src/fp/addDays/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addDaysWithOptions/index.js.flow b/src/fp/addDaysWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/addDaysWithOptions/index.js.flow +++ b/src/fp/addDaysWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addHours/index.js.flow b/src/fp/addHours/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/addHours/index.js.flow +++ b/src/fp/addHours/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addHoursWithOptions/index.js.flow b/src/fp/addHoursWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/addHoursWithOptions/index.js.flow +++ b/src/fp/addHoursWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addISOYears/index.js.flow b/src/fp/addISOYears/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/addISOYears/index.js.flow +++ b/src/fp/addISOYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addISOYearsWithOptions/index.js.flow b/src/fp/addISOYearsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/addISOYearsWithOptions/index.js.flow +++ b/src/fp/addISOYearsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addMilliseconds/index.js.flow b/src/fp/addMilliseconds/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/addMilliseconds/index.js.flow +++ b/src/fp/addMilliseconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addMillisecondsWithOptions/index.js.flow b/src/fp/addMillisecondsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/addMillisecondsWithOptions/index.js.flow +++ b/src/fp/addMillisecondsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addMinutes/index.js.flow b/src/fp/addMinutes/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/addMinutes/index.js.flow +++ b/src/fp/addMinutes/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addMinutesWithOptions/index.js.flow b/src/fp/addMinutesWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/addMinutesWithOptions/index.js.flow +++ b/src/fp/addMinutesWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addMonths/index.js.flow b/src/fp/addMonths/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/addMonths/index.js.flow +++ b/src/fp/addMonths/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addMonthsWithOptions/index.js.flow b/src/fp/addMonthsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/addMonthsWithOptions/index.js.flow +++ b/src/fp/addMonthsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addQuarters/index.js.flow b/src/fp/addQuarters/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/addQuarters/index.js.flow +++ b/src/fp/addQuarters/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addQuartersWithOptions/index.js.flow b/src/fp/addQuartersWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/addQuartersWithOptions/index.js.flow +++ b/src/fp/addQuartersWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addSeconds/index.js.flow b/src/fp/addSeconds/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/addSeconds/index.js.flow +++ b/src/fp/addSeconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addSecondsWithOptions/index.js.flow b/src/fp/addSecondsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/addSecondsWithOptions/index.js.flow +++ b/src/fp/addSecondsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addWeeks/index.js.flow b/src/fp/addWeeks/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/addWeeks/index.js.flow +++ b/src/fp/addWeeks/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addWeeksWithOptions/index.js.flow b/src/fp/addWeeksWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/addWeeksWithOptions/index.js.flow +++ b/src/fp/addWeeksWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addYears/index.js.flow b/src/fp/addYears/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/addYears/index.js.flow +++ b/src/fp/addYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/addYearsWithOptions/index.js.flow b/src/fp/addYearsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/addYearsWithOptions/index.js.flow +++ b/src/fp/addYearsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/areIntervalsOverlapping/index.js.flow b/src/fp/areIntervalsOverlapping/index.js.flow index 42e3c41073..5fccc348cb 100644 --- a/src/fp/areIntervalsOverlapping/index.js.flow +++ b/src/fp/areIntervalsOverlapping/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/areIntervalsOverlappingWithOptions/index.js.flow b/src/fp/areIntervalsOverlappingWithOptions/index.js.flow index 63a317d01d..f02d2eccfb 100644 --- a/src/fp/areIntervalsOverlappingWithOptions/index.js.flow +++ b/src/fp/areIntervalsOverlappingWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/closestIndexTo/index.js.flow b/src/fp/closestIndexTo/index.js.flow index 2af714e4e2..192ea34844 100644 --- a/src/fp/closestIndexTo/index.js.flow +++ b/src/fp/closestIndexTo/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/closestIndexToWithOptions/index.js.flow b/src/fp/closestIndexToWithOptions/index.js.flow index f79fde1bd3..c055a9d984 100644 --- a/src/fp/closestIndexToWithOptions/index.js.flow +++ b/src/fp/closestIndexToWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/closestTo/index.js.flow b/src/fp/closestTo/index.js.flow index 5322d83e06..579485e028 100644 --- a/src/fp/closestTo/index.js.flow +++ b/src/fp/closestTo/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/closestToWithOptions/index.js.flow b/src/fp/closestToWithOptions/index.js.flow index e9344cdb25..1f96498024 100644 --- a/src/fp/closestToWithOptions/index.js.flow +++ b/src/fp/closestToWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/compareAsc/index.js.flow b/src/fp/compareAsc/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/compareAsc/index.js.flow +++ b/src/fp/compareAsc/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/compareAscWithOptions/index.js.flow b/src/fp/compareAscWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/compareAscWithOptions/index.js.flow +++ b/src/fp/compareAscWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/compareDesc/index.js.flow b/src/fp/compareDesc/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/compareDesc/index.js.flow +++ b/src/fp/compareDesc/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/compareDescWithOptions/index.js.flow b/src/fp/compareDescWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/compareDescWithOptions/index.js.flow +++ b/src/fp/compareDescWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarDays/index.js.flow b/src/fp/differenceInCalendarDays/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInCalendarDays/index.js.flow +++ b/src/fp/differenceInCalendarDays/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarDaysWithOptions/index.js.flow b/src/fp/differenceInCalendarDaysWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInCalendarDaysWithOptions/index.js.flow +++ b/src/fp/differenceInCalendarDaysWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarISOWeeks/index.js.flow b/src/fp/differenceInCalendarISOWeeks/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInCalendarISOWeeks/index.js.flow +++ b/src/fp/differenceInCalendarISOWeeks/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarISOWeeksWithOptions/index.js.flow b/src/fp/differenceInCalendarISOWeeksWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInCalendarISOWeeksWithOptions/index.js.flow +++ b/src/fp/differenceInCalendarISOWeeksWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarISOYears/index.js.flow b/src/fp/differenceInCalendarISOYears/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInCalendarISOYears/index.js.flow +++ b/src/fp/differenceInCalendarISOYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarISOYearsWithOptions/index.js.flow b/src/fp/differenceInCalendarISOYearsWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInCalendarISOYearsWithOptions/index.js.flow +++ b/src/fp/differenceInCalendarISOYearsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarMonths/index.js.flow b/src/fp/differenceInCalendarMonths/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInCalendarMonths/index.js.flow +++ b/src/fp/differenceInCalendarMonths/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarMonthsWithOptions/index.js.flow b/src/fp/differenceInCalendarMonthsWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInCalendarMonthsWithOptions/index.js.flow +++ b/src/fp/differenceInCalendarMonthsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarQuarters/index.js.flow b/src/fp/differenceInCalendarQuarters/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInCalendarQuarters/index.js.flow +++ b/src/fp/differenceInCalendarQuarters/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarQuartersWithOptions/index.js.flow b/src/fp/differenceInCalendarQuartersWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInCalendarQuartersWithOptions/index.js.flow +++ b/src/fp/differenceInCalendarQuartersWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarWeeks/index.js.flow b/src/fp/differenceInCalendarWeeks/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInCalendarWeeks/index.js.flow +++ b/src/fp/differenceInCalendarWeeks/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarWeeksWithOptions/index.js.flow b/src/fp/differenceInCalendarWeeksWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInCalendarWeeksWithOptions/index.js.flow +++ b/src/fp/differenceInCalendarWeeksWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarYears/index.js.flow b/src/fp/differenceInCalendarYears/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInCalendarYears/index.js.flow +++ b/src/fp/differenceInCalendarYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInCalendarYearsWithOptions/index.js.flow b/src/fp/differenceInCalendarYearsWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInCalendarYearsWithOptions/index.js.flow +++ b/src/fp/differenceInCalendarYearsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInDays/index.js.flow b/src/fp/differenceInDays/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInDays/index.js.flow +++ b/src/fp/differenceInDays/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInDaysWithOptions/index.js.flow b/src/fp/differenceInDaysWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInDaysWithOptions/index.js.flow +++ b/src/fp/differenceInDaysWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInHours/index.js.flow b/src/fp/differenceInHours/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInHours/index.js.flow +++ b/src/fp/differenceInHours/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInHoursWithOptions/index.js.flow b/src/fp/differenceInHoursWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInHoursWithOptions/index.js.flow +++ b/src/fp/differenceInHoursWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInISOYears/index.js.flow b/src/fp/differenceInISOYears/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInISOYears/index.js.flow +++ b/src/fp/differenceInISOYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInISOYearsWithOptions/index.js.flow b/src/fp/differenceInISOYearsWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInISOYearsWithOptions/index.js.flow +++ b/src/fp/differenceInISOYearsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInMilliseconds/index.js.flow b/src/fp/differenceInMilliseconds/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInMilliseconds/index.js.flow +++ b/src/fp/differenceInMilliseconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInMillisecondsWithOptions/index.js.flow b/src/fp/differenceInMillisecondsWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInMillisecondsWithOptions/index.js.flow +++ b/src/fp/differenceInMillisecondsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInMinutes/index.js.flow b/src/fp/differenceInMinutes/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInMinutes/index.js.flow +++ b/src/fp/differenceInMinutes/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInMinutesWithOptions/index.js.flow b/src/fp/differenceInMinutesWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInMinutesWithOptions/index.js.flow +++ b/src/fp/differenceInMinutesWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInMonths/index.js.flow b/src/fp/differenceInMonths/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInMonths/index.js.flow +++ b/src/fp/differenceInMonths/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInMonthsWithOptions/index.js.flow b/src/fp/differenceInMonthsWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInMonthsWithOptions/index.js.flow +++ b/src/fp/differenceInMonthsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInQuarters/index.js.flow b/src/fp/differenceInQuarters/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInQuarters/index.js.flow +++ b/src/fp/differenceInQuarters/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInQuartersWithOptions/index.js.flow b/src/fp/differenceInQuartersWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInQuartersWithOptions/index.js.flow +++ b/src/fp/differenceInQuartersWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInSeconds/index.js.flow b/src/fp/differenceInSeconds/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInSeconds/index.js.flow +++ b/src/fp/differenceInSeconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInSecondsWithOptions/index.js.flow b/src/fp/differenceInSecondsWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInSecondsWithOptions/index.js.flow +++ b/src/fp/differenceInSecondsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInWeeks/index.js.flow b/src/fp/differenceInWeeks/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInWeeks/index.js.flow +++ b/src/fp/differenceInWeeks/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInWeeksWithOptions/index.js.flow b/src/fp/differenceInWeeksWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInWeeksWithOptions/index.js.flow +++ b/src/fp/differenceInWeeksWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInYears/index.js.flow b/src/fp/differenceInYears/index.js.flow index b022ca22db..ecc1a53a03 100644 --- a/src/fp/differenceInYears/index.js.flow +++ b/src/fp/differenceInYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/differenceInYearsWithOptions/index.js.flow b/src/fp/differenceInYearsWithOptions/index.js.flow index 674ae4e95b..fc07281766 100644 --- a/src/fp/differenceInYearsWithOptions/index.js.flow +++ b/src/fp/differenceInYearsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/distanceInWords/index.js.flow b/src/fp/distanceInWords/index.js.flow index bb454020e2..dfd0d3cc52 100644 --- a/src/fp/distanceInWords/index.js.flow +++ b/src/fp/distanceInWords/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/distanceInWordsStrict/index.js.flow b/src/fp/distanceInWordsStrict/index.js.flow index bb454020e2..dfd0d3cc52 100644 --- a/src/fp/distanceInWordsStrict/index.js.flow +++ b/src/fp/distanceInWordsStrict/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/distanceInWordsStrictWithOptions/index.js.flow b/src/fp/distanceInWordsStrictWithOptions/index.js.flow index 76cb490569..a3c2707aaa 100644 --- a/src/fp/distanceInWordsStrictWithOptions/index.js.flow +++ b/src/fp/distanceInWordsStrictWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/distanceInWordsWithOptions/index.js.flow b/src/fp/distanceInWordsWithOptions/index.js.flow index 76cb490569..a3c2707aaa 100644 --- a/src/fp/distanceInWordsWithOptions/index.js.flow +++ b/src/fp/distanceInWordsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/eachDayOfInterval/index.js.flow b/src/fp/eachDayOfInterval/index.js.flow index 9227e593b0..1bc2702a39 100644 --- a/src/fp/eachDayOfInterval/index.js.flow +++ b/src/fp/eachDayOfInterval/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/eachDayOfIntervalWithOptions/index.js.flow b/src/fp/eachDayOfIntervalWithOptions/index.js.flow index 725b7cfa12..1b8a93eb2e 100644 --- a/src/fp/eachDayOfIntervalWithOptions/index.js.flow +++ b/src/fp/eachDayOfIntervalWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfDay/index.js.flow b/src/fp/endOfDay/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/endOfDay/index.js.flow +++ b/src/fp/endOfDay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfDayWithOptions/index.js.flow b/src/fp/endOfDayWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/endOfDayWithOptions/index.js.flow +++ b/src/fp/endOfDayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfHour/index.js.flow b/src/fp/endOfHour/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/endOfHour/index.js.flow +++ b/src/fp/endOfHour/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfHourWithOptions/index.js.flow b/src/fp/endOfHourWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/endOfHourWithOptions/index.js.flow +++ b/src/fp/endOfHourWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfISOWeek/index.js.flow b/src/fp/endOfISOWeek/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/endOfISOWeek/index.js.flow +++ b/src/fp/endOfISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfISOWeekWithOptions/index.js.flow b/src/fp/endOfISOWeekWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/endOfISOWeekWithOptions/index.js.flow +++ b/src/fp/endOfISOWeekWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfISOYear/index.js.flow b/src/fp/endOfISOYear/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/endOfISOYear/index.js.flow +++ b/src/fp/endOfISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfISOYearWithOptions/index.js.flow b/src/fp/endOfISOYearWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/endOfISOYearWithOptions/index.js.flow +++ b/src/fp/endOfISOYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfMinute/index.js.flow b/src/fp/endOfMinute/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/endOfMinute/index.js.flow +++ b/src/fp/endOfMinute/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfMinuteWithOptions/index.js.flow b/src/fp/endOfMinuteWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/endOfMinuteWithOptions/index.js.flow +++ b/src/fp/endOfMinuteWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfMonth/index.js.flow b/src/fp/endOfMonth/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/endOfMonth/index.js.flow +++ b/src/fp/endOfMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfMonthWithOptions/index.js.flow b/src/fp/endOfMonthWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/endOfMonthWithOptions/index.js.flow +++ b/src/fp/endOfMonthWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfQuarter/index.js.flow b/src/fp/endOfQuarter/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/endOfQuarter/index.js.flow +++ b/src/fp/endOfQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfQuarterWithOptions/index.js.flow b/src/fp/endOfQuarterWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/endOfQuarterWithOptions/index.js.flow +++ b/src/fp/endOfQuarterWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfSecond/index.js.flow b/src/fp/endOfSecond/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/endOfSecond/index.js.flow +++ b/src/fp/endOfSecond/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfSecondWithOptions/index.js.flow b/src/fp/endOfSecondWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/endOfSecondWithOptions/index.js.flow +++ b/src/fp/endOfSecondWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfWeek/index.js.flow b/src/fp/endOfWeek/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/endOfWeek/index.js.flow +++ b/src/fp/endOfWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfWeekWithOptions/index.js.flow b/src/fp/endOfWeekWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/endOfWeekWithOptions/index.js.flow +++ b/src/fp/endOfWeekWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfYear/index.js.flow b/src/fp/endOfYear/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/endOfYear/index.js.flow +++ b/src/fp/endOfYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/endOfYearWithOptions/index.js.flow b/src/fp/endOfYearWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/endOfYearWithOptions/index.js.flow +++ b/src/fp/endOfYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/format/index.js.flow b/src/fp/format/index.js.flow index 13dfc8dbd2..9a564e5f8b 100644 --- a/src/fp/format/index.js.flow +++ b/src/fp/format/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/formatWithOptions/index.js.flow b/src/fp/formatWithOptions/index.js.flow index 4ff39ce0de..632e937adf 100644 --- a/src/fp/formatWithOptions/index.js.flow +++ b/src/fp/formatWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getDate/index.js.flow b/src/fp/getDate/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getDate/index.js.flow +++ b/src/fp/getDate/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getDateWithOptions/index.js.flow b/src/fp/getDateWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getDateWithOptions/index.js.flow +++ b/src/fp/getDateWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getDay/index.js.flow b/src/fp/getDay/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getDay/index.js.flow +++ b/src/fp/getDay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getDayOfYear/index.js.flow b/src/fp/getDayOfYear/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getDayOfYear/index.js.flow +++ b/src/fp/getDayOfYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getDayOfYearWithOptions/index.js.flow b/src/fp/getDayOfYearWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getDayOfYearWithOptions/index.js.flow +++ b/src/fp/getDayOfYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getDayWithOptions/index.js.flow b/src/fp/getDayWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getDayWithOptions/index.js.flow +++ b/src/fp/getDayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getDaysInMonth/index.js.flow b/src/fp/getDaysInMonth/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getDaysInMonth/index.js.flow +++ b/src/fp/getDaysInMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getDaysInMonthWithOptions/index.js.flow b/src/fp/getDaysInMonthWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getDaysInMonthWithOptions/index.js.flow +++ b/src/fp/getDaysInMonthWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getDaysInYear/index.js.flow b/src/fp/getDaysInYear/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getDaysInYear/index.js.flow +++ b/src/fp/getDaysInYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getDaysInYearWithOptions/index.js.flow b/src/fp/getDaysInYearWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getDaysInYearWithOptions/index.js.flow +++ b/src/fp/getDaysInYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getHours/index.js.flow b/src/fp/getHours/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getHours/index.js.flow +++ b/src/fp/getHours/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getHoursWithOptions/index.js.flow b/src/fp/getHoursWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getHoursWithOptions/index.js.flow +++ b/src/fp/getHoursWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getISODay/index.js.flow b/src/fp/getISODay/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getISODay/index.js.flow +++ b/src/fp/getISODay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getISODayWithOptions/index.js.flow b/src/fp/getISODayWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getISODayWithOptions/index.js.flow +++ b/src/fp/getISODayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getISOWeek/index.js.flow b/src/fp/getISOWeek/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getISOWeek/index.js.flow +++ b/src/fp/getISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getISOWeekWithOptions/index.js.flow b/src/fp/getISOWeekWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getISOWeekWithOptions/index.js.flow +++ b/src/fp/getISOWeekWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getISOWeeksInYear/index.js.flow b/src/fp/getISOWeeksInYear/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getISOWeeksInYear/index.js.flow +++ b/src/fp/getISOWeeksInYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getISOWeeksInYearWithOptions/index.js.flow b/src/fp/getISOWeeksInYearWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getISOWeeksInYearWithOptions/index.js.flow +++ b/src/fp/getISOWeeksInYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getISOYear/index.js.flow b/src/fp/getISOYear/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getISOYear/index.js.flow +++ b/src/fp/getISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getISOYearWithOptions/index.js.flow b/src/fp/getISOYearWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getISOYearWithOptions/index.js.flow +++ b/src/fp/getISOYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getMilliseconds/index.js.flow b/src/fp/getMilliseconds/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getMilliseconds/index.js.flow +++ b/src/fp/getMilliseconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getMillisecondsWithOptions/index.js.flow b/src/fp/getMillisecondsWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getMillisecondsWithOptions/index.js.flow +++ b/src/fp/getMillisecondsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getMinutes/index.js.flow b/src/fp/getMinutes/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getMinutes/index.js.flow +++ b/src/fp/getMinutes/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getMinutesWithOptions/index.js.flow b/src/fp/getMinutesWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getMinutesWithOptions/index.js.flow +++ b/src/fp/getMinutesWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getMonth/index.js.flow b/src/fp/getMonth/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getMonth/index.js.flow +++ b/src/fp/getMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getMonthWithOptions/index.js.flow b/src/fp/getMonthWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getMonthWithOptions/index.js.flow +++ b/src/fp/getMonthWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getOverlappingDaysInIntervals/index.js.flow b/src/fp/getOverlappingDaysInIntervals/index.js.flow index 14ba1f2d9a..eb7f9fac7f 100644 --- a/src/fp/getOverlappingDaysInIntervals/index.js.flow +++ b/src/fp/getOverlappingDaysInIntervals/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getOverlappingDaysInIntervalsWithOptions/index.js.flow b/src/fp/getOverlappingDaysInIntervalsWithOptions/index.js.flow index 282e6eb35f..a4f921b3e9 100644 --- a/src/fp/getOverlappingDaysInIntervalsWithOptions/index.js.flow +++ b/src/fp/getOverlappingDaysInIntervalsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getQuarter/index.js.flow b/src/fp/getQuarter/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getQuarter/index.js.flow +++ b/src/fp/getQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getQuarterWithOptions/index.js.flow b/src/fp/getQuarterWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getQuarterWithOptions/index.js.flow +++ b/src/fp/getQuarterWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getSeconds/index.js.flow b/src/fp/getSeconds/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getSeconds/index.js.flow +++ b/src/fp/getSeconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getSecondsWithOptions/index.js.flow b/src/fp/getSecondsWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getSecondsWithOptions/index.js.flow +++ b/src/fp/getSecondsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getTime/index.js.flow b/src/fp/getTime/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getTime/index.js.flow +++ b/src/fp/getTime/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getTimeWithOptions/index.js.flow b/src/fp/getTimeWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getTimeWithOptions/index.js.flow +++ b/src/fp/getTimeWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getYear/index.js.flow b/src/fp/getYear/index.js.flow index 4f8808a755..eb92a7bbfc 100644 --- a/src/fp/getYear/index.js.flow +++ b/src/fp/getYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/getYearWithOptions/index.js.flow b/src/fp/getYearWithOptions/index.js.flow index 7b7451c0ff..c3bfdaba4c 100644 --- a/src/fp/getYearWithOptions/index.js.flow +++ b/src/fp/getYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isAfter/index.js.flow b/src/fp/isAfter/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isAfter/index.js.flow +++ b/src/fp/isAfter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isAfterWithOptions/index.js.flow b/src/fp/isAfterWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isAfterWithOptions/index.js.flow +++ b/src/fp/isAfterWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isBefore/index.js.flow b/src/fp/isBefore/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isBefore/index.js.flow +++ b/src/fp/isBefore/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isBeforeWithOptions/index.js.flow b/src/fp/isBeforeWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isBeforeWithOptions/index.js.flow +++ b/src/fp/isBeforeWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isDate/index.js.flow b/src/fp/isDate/index.js.flow index 4434f50c4d..25cc3c3d1c 100644 --- a/src/fp/isDate/index.js.flow +++ b/src/fp/isDate/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isDateWithOptions/index.js.flow b/src/fp/isDateWithOptions/index.js.flow index fa42f18b92..a2e245a03e 100644 --- a/src/fp/isDateWithOptions/index.js.flow +++ b/src/fp/isDateWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isEqual/index.js.flow b/src/fp/isEqual/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isEqual/index.js.flow +++ b/src/fp/isEqual/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isEqualWithOptions/index.js.flow b/src/fp/isEqualWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isEqualWithOptions/index.js.flow +++ b/src/fp/isEqualWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isFirstDayOfMonth/index.js.flow b/src/fp/isFirstDayOfMonth/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isFirstDayOfMonth/index.js.flow +++ b/src/fp/isFirstDayOfMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isFirstDayOfMonthWithOptions/index.js.flow b/src/fp/isFirstDayOfMonthWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isFirstDayOfMonthWithOptions/index.js.flow +++ b/src/fp/isFirstDayOfMonthWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isFriday/index.js.flow b/src/fp/isFriday/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isFriday/index.js.flow +++ b/src/fp/isFriday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isFridayWithOptions/index.js.flow b/src/fp/isFridayWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isFridayWithOptions/index.js.flow +++ b/src/fp/isFridayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isLastDayOfMonth/index.js.flow b/src/fp/isLastDayOfMonth/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isLastDayOfMonth/index.js.flow +++ b/src/fp/isLastDayOfMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isLastDayOfMonthWithOptions/index.js.flow b/src/fp/isLastDayOfMonthWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isLastDayOfMonthWithOptions/index.js.flow +++ b/src/fp/isLastDayOfMonthWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isLeapYear/index.js.flow b/src/fp/isLeapYear/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isLeapYear/index.js.flow +++ b/src/fp/isLeapYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isLeapYearWithOptions/index.js.flow b/src/fp/isLeapYearWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isLeapYearWithOptions/index.js.flow +++ b/src/fp/isLeapYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isMonday/index.js.flow b/src/fp/isMonday/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isMonday/index.js.flow +++ b/src/fp/isMonday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isMondayWithOptions/index.js.flow b/src/fp/isMondayWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isMondayWithOptions/index.js.flow +++ b/src/fp/isMondayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameDay/index.js.flow b/src/fp/isSameDay/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isSameDay/index.js.flow +++ b/src/fp/isSameDay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameDayWithOptions/index.js.flow b/src/fp/isSameDayWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isSameDayWithOptions/index.js.flow +++ b/src/fp/isSameDayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameHour/index.js.flow b/src/fp/isSameHour/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isSameHour/index.js.flow +++ b/src/fp/isSameHour/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameHourWithOptions/index.js.flow b/src/fp/isSameHourWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isSameHourWithOptions/index.js.flow +++ b/src/fp/isSameHourWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameISOWeek/index.js.flow b/src/fp/isSameISOWeek/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isSameISOWeek/index.js.flow +++ b/src/fp/isSameISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameISOWeekWithOptions/index.js.flow b/src/fp/isSameISOWeekWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isSameISOWeekWithOptions/index.js.flow +++ b/src/fp/isSameISOWeekWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameISOYear/index.js.flow b/src/fp/isSameISOYear/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isSameISOYear/index.js.flow +++ b/src/fp/isSameISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameISOYearWithOptions/index.js.flow b/src/fp/isSameISOYearWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isSameISOYearWithOptions/index.js.flow +++ b/src/fp/isSameISOYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameMinute/index.js.flow b/src/fp/isSameMinute/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isSameMinute/index.js.flow +++ b/src/fp/isSameMinute/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameMinuteWithOptions/index.js.flow b/src/fp/isSameMinuteWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isSameMinuteWithOptions/index.js.flow +++ b/src/fp/isSameMinuteWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameMonth/index.js.flow b/src/fp/isSameMonth/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isSameMonth/index.js.flow +++ b/src/fp/isSameMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameMonthWithOptions/index.js.flow b/src/fp/isSameMonthWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isSameMonthWithOptions/index.js.flow +++ b/src/fp/isSameMonthWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameQuarter/index.js.flow b/src/fp/isSameQuarter/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isSameQuarter/index.js.flow +++ b/src/fp/isSameQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameQuarterWithOptions/index.js.flow b/src/fp/isSameQuarterWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isSameQuarterWithOptions/index.js.flow +++ b/src/fp/isSameQuarterWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameSecond/index.js.flow b/src/fp/isSameSecond/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isSameSecond/index.js.flow +++ b/src/fp/isSameSecond/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameSecondWithOptions/index.js.flow b/src/fp/isSameSecondWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isSameSecondWithOptions/index.js.flow +++ b/src/fp/isSameSecondWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameWeek/index.js.flow b/src/fp/isSameWeek/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isSameWeek/index.js.flow +++ b/src/fp/isSameWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameWeekWithOptions/index.js.flow b/src/fp/isSameWeekWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isSameWeekWithOptions/index.js.flow +++ b/src/fp/isSameWeekWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameYear/index.js.flow b/src/fp/isSameYear/index.js.flow index cdb04cbe59..e1e9fbdf6f 100644 --- a/src/fp/isSameYear/index.js.flow +++ b/src/fp/isSameYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSameYearWithOptions/index.js.flow b/src/fp/isSameYearWithOptions/index.js.flow index b6750b62a4..6951c5aad6 100644 --- a/src/fp/isSameYearWithOptions/index.js.flow +++ b/src/fp/isSameYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSaturday/index.js.flow b/src/fp/isSaturday/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isSaturday/index.js.flow +++ b/src/fp/isSaturday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSaturdayWithOptions/index.js.flow b/src/fp/isSaturdayWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isSaturdayWithOptions/index.js.flow +++ b/src/fp/isSaturdayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSunday/index.js.flow b/src/fp/isSunday/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isSunday/index.js.flow +++ b/src/fp/isSunday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isSundayWithOptions/index.js.flow b/src/fp/isSundayWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isSundayWithOptions/index.js.flow +++ b/src/fp/isSundayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isThursday/index.js.flow b/src/fp/isThursday/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isThursday/index.js.flow +++ b/src/fp/isThursday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isThursdayWithOptions/index.js.flow b/src/fp/isThursdayWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isThursdayWithOptions/index.js.flow +++ b/src/fp/isThursdayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isTuesday/index.js.flow b/src/fp/isTuesday/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isTuesday/index.js.flow +++ b/src/fp/isTuesday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isTuesdayWithOptions/index.js.flow b/src/fp/isTuesdayWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isTuesdayWithOptions/index.js.flow +++ b/src/fp/isTuesdayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isValid/index.js.flow b/src/fp/isValid/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isValid/index.js.flow +++ b/src/fp/isValid/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isValidWithOptions/index.js.flow b/src/fp/isValidWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isValidWithOptions/index.js.flow +++ b/src/fp/isValidWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isWednesday/index.js.flow b/src/fp/isWednesday/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isWednesday/index.js.flow +++ b/src/fp/isWednesday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isWednesdayWithOptions/index.js.flow b/src/fp/isWednesdayWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isWednesdayWithOptions/index.js.flow +++ b/src/fp/isWednesdayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isWeekend/index.js.flow b/src/fp/isWeekend/index.js.flow index 39ada5eb51..e103fbbe38 100644 --- a/src/fp/isWeekend/index.js.flow +++ b/src/fp/isWeekend/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isWeekendWithOptions/index.js.flow b/src/fp/isWeekendWithOptions/index.js.flow index 2f4fc7040d..a7cde0b95f 100644 --- a/src/fp/isWeekendWithOptions/index.js.flow +++ b/src/fp/isWeekendWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isWithinInterval/index.js.flow b/src/fp/isWithinInterval/index.js.flow index 3f2728fb50..d146fbcacd 100644 --- a/src/fp/isWithinInterval/index.js.flow +++ b/src/fp/isWithinInterval/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/isWithinIntervalWithOptions/index.js.flow b/src/fp/isWithinIntervalWithOptions/index.js.flow index 0689232937..7a7157c098 100644 --- a/src/fp/isWithinIntervalWithOptions/index.js.flow +++ b/src/fp/isWithinIntervalWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfISOWeek/index.js.flow b/src/fp/lastDayOfISOWeek/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/lastDayOfISOWeek/index.js.flow +++ b/src/fp/lastDayOfISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfISOWeekWithOptions/index.js.flow b/src/fp/lastDayOfISOWeekWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/lastDayOfISOWeekWithOptions/index.js.flow +++ b/src/fp/lastDayOfISOWeekWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfISOYear/index.js.flow b/src/fp/lastDayOfISOYear/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/lastDayOfISOYear/index.js.flow +++ b/src/fp/lastDayOfISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfISOYearWithOptions/index.js.flow b/src/fp/lastDayOfISOYearWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/lastDayOfISOYearWithOptions/index.js.flow +++ b/src/fp/lastDayOfISOYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfMonth/index.js.flow b/src/fp/lastDayOfMonth/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/lastDayOfMonth/index.js.flow +++ b/src/fp/lastDayOfMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfMonthWithOptions/index.js.flow b/src/fp/lastDayOfMonthWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/lastDayOfMonthWithOptions/index.js.flow +++ b/src/fp/lastDayOfMonthWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfQuarter/index.js.flow b/src/fp/lastDayOfQuarter/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/lastDayOfQuarter/index.js.flow +++ b/src/fp/lastDayOfQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfQuarterWithOptions/index.js.flow b/src/fp/lastDayOfQuarterWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/lastDayOfQuarterWithOptions/index.js.flow +++ b/src/fp/lastDayOfQuarterWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfWeek/index.js.flow b/src/fp/lastDayOfWeek/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/lastDayOfWeek/index.js.flow +++ b/src/fp/lastDayOfWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfWeekWithOptions/index.js.flow b/src/fp/lastDayOfWeekWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/lastDayOfWeekWithOptions/index.js.flow +++ b/src/fp/lastDayOfWeekWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfYear/index.js.flow b/src/fp/lastDayOfYear/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/lastDayOfYear/index.js.flow +++ b/src/fp/lastDayOfYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/lastDayOfYearWithOptions/index.js.flow b/src/fp/lastDayOfYearWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/lastDayOfYearWithOptions/index.js.flow +++ b/src/fp/lastDayOfYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/max/index.js.flow b/src/fp/max/index.js.flow index 3764c39a86..47b4c559ba 100644 --- a/src/fp/max/index.js.flow +++ b/src/fp/max/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/maxWithOptions/index.js.flow b/src/fp/maxWithOptions/index.js.flow index 2285dcdf70..26aadd6b7b 100644 --- a/src/fp/maxWithOptions/index.js.flow +++ b/src/fp/maxWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/min/index.js.flow b/src/fp/min/index.js.flow index 3764c39a86..47b4c559ba 100644 --- a/src/fp/min/index.js.flow +++ b/src/fp/min/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/minWithOptions/index.js.flow b/src/fp/minWithOptions/index.js.flow index 2285dcdf70..26aadd6b7b 100644 --- a/src/fp/minWithOptions/index.js.flow +++ b/src/fp/minWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/parse/index.js.flow b/src/fp/parse/index.js.flow index 3a36d0266c..4636934dc6 100644 --- a/src/fp/parse/index.js.flow +++ b/src/fp/parse/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/parseWithOptions/index.js.flow b/src/fp/parseWithOptions/index.js.flow index 8bbe9b0dc4..3fa86c2758 100644 --- a/src/fp/parseWithOptions/index.js.flow +++ b/src/fp/parseWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setDate/index.js.flow b/src/fp/setDate/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setDate/index.js.flow +++ b/src/fp/setDate/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setDateWithOptions/index.js.flow b/src/fp/setDateWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setDateWithOptions/index.js.flow +++ b/src/fp/setDateWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setDay/index.js.flow b/src/fp/setDay/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setDay/index.js.flow +++ b/src/fp/setDay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setDayOfYear/index.js.flow b/src/fp/setDayOfYear/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setDayOfYear/index.js.flow +++ b/src/fp/setDayOfYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setDayOfYearWithOptions/index.js.flow b/src/fp/setDayOfYearWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setDayOfYearWithOptions/index.js.flow +++ b/src/fp/setDayOfYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setDayWithOptions/index.js.flow b/src/fp/setDayWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setDayWithOptions/index.js.flow +++ b/src/fp/setDayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setHours/index.js.flow b/src/fp/setHours/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setHours/index.js.flow +++ b/src/fp/setHours/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setHoursWithOptions/index.js.flow b/src/fp/setHoursWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setHoursWithOptions/index.js.flow +++ b/src/fp/setHoursWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setISODay/index.js.flow b/src/fp/setISODay/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setISODay/index.js.flow +++ b/src/fp/setISODay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setISODayWithOptions/index.js.flow b/src/fp/setISODayWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setISODayWithOptions/index.js.flow +++ b/src/fp/setISODayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setISOWeek/index.js.flow b/src/fp/setISOWeek/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setISOWeek/index.js.flow +++ b/src/fp/setISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setISOWeekWithOptions/index.js.flow b/src/fp/setISOWeekWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setISOWeekWithOptions/index.js.flow +++ b/src/fp/setISOWeekWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setISOYear/index.js.flow b/src/fp/setISOYear/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setISOYear/index.js.flow +++ b/src/fp/setISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setISOYearWithOptions/index.js.flow b/src/fp/setISOYearWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setISOYearWithOptions/index.js.flow +++ b/src/fp/setISOYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setMilliseconds/index.js.flow b/src/fp/setMilliseconds/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setMilliseconds/index.js.flow +++ b/src/fp/setMilliseconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setMillisecondsWithOptions/index.js.flow b/src/fp/setMillisecondsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setMillisecondsWithOptions/index.js.flow +++ b/src/fp/setMillisecondsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setMinutes/index.js.flow b/src/fp/setMinutes/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setMinutes/index.js.flow +++ b/src/fp/setMinutes/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setMinutesWithOptions/index.js.flow b/src/fp/setMinutesWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setMinutesWithOptions/index.js.flow +++ b/src/fp/setMinutesWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setMonth/index.js.flow b/src/fp/setMonth/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setMonth/index.js.flow +++ b/src/fp/setMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setMonthWithOptions/index.js.flow b/src/fp/setMonthWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setMonthWithOptions/index.js.flow +++ b/src/fp/setMonthWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setQuarter/index.js.flow b/src/fp/setQuarter/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setQuarter/index.js.flow +++ b/src/fp/setQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setQuarterWithOptions/index.js.flow b/src/fp/setQuarterWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setQuarterWithOptions/index.js.flow +++ b/src/fp/setQuarterWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setSeconds/index.js.flow b/src/fp/setSeconds/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setSeconds/index.js.flow +++ b/src/fp/setSeconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setSecondsWithOptions/index.js.flow b/src/fp/setSecondsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setSecondsWithOptions/index.js.flow +++ b/src/fp/setSecondsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setYear/index.js.flow b/src/fp/setYear/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/setYear/index.js.flow +++ b/src/fp/setYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/setYearWithOptions/index.js.flow b/src/fp/setYearWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/setYearWithOptions/index.js.flow +++ b/src/fp/setYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfDay/index.js.flow b/src/fp/startOfDay/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/startOfDay/index.js.flow +++ b/src/fp/startOfDay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfDayWithOptions/index.js.flow b/src/fp/startOfDayWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/startOfDayWithOptions/index.js.flow +++ b/src/fp/startOfDayWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfHour/index.js.flow b/src/fp/startOfHour/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/startOfHour/index.js.flow +++ b/src/fp/startOfHour/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfHourWithOptions/index.js.flow b/src/fp/startOfHourWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/startOfHourWithOptions/index.js.flow +++ b/src/fp/startOfHourWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfISOWeek/index.js.flow b/src/fp/startOfISOWeek/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/startOfISOWeek/index.js.flow +++ b/src/fp/startOfISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfISOWeekWithOptions/index.js.flow b/src/fp/startOfISOWeekWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/startOfISOWeekWithOptions/index.js.flow +++ b/src/fp/startOfISOWeekWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfISOYear/index.js.flow b/src/fp/startOfISOYear/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/startOfISOYear/index.js.flow +++ b/src/fp/startOfISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfISOYearWithOptions/index.js.flow b/src/fp/startOfISOYearWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/startOfISOYearWithOptions/index.js.flow +++ b/src/fp/startOfISOYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfMinute/index.js.flow b/src/fp/startOfMinute/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/startOfMinute/index.js.flow +++ b/src/fp/startOfMinute/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfMinuteWithOptions/index.js.flow b/src/fp/startOfMinuteWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/startOfMinuteWithOptions/index.js.flow +++ b/src/fp/startOfMinuteWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfMonth/index.js.flow b/src/fp/startOfMonth/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/startOfMonth/index.js.flow +++ b/src/fp/startOfMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfMonthWithOptions/index.js.flow b/src/fp/startOfMonthWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/startOfMonthWithOptions/index.js.flow +++ b/src/fp/startOfMonthWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfQuarter/index.js.flow b/src/fp/startOfQuarter/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/startOfQuarter/index.js.flow +++ b/src/fp/startOfQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfQuarterWithOptions/index.js.flow b/src/fp/startOfQuarterWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/startOfQuarterWithOptions/index.js.flow +++ b/src/fp/startOfQuarterWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfSecond/index.js.flow b/src/fp/startOfSecond/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/startOfSecond/index.js.flow +++ b/src/fp/startOfSecond/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfSecondWithOptions/index.js.flow b/src/fp/startOfSecondWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/startOfSecondWithOptions/index.js.flow +++ b/src/fp/startOfSecondWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfWeek/index.js.flow b/src/fp/startOfWeek/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/startOfWeek/index.js.flow +++ b/src/fp/startOfWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfWeekWithOptions/index.js.flow b/src/fp/startOfWeekWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/startOfWeekWithOptions/index.js.flow +++ b/src/fp/startOfWeekWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfYear/index.js.flow b/src/fp/startOfYear/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/startOfYear/index.js.flow +++ b/src/fp/startOfYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/startOfYearWithOptions/index.js.flow b/src/fp/startOfYearWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/startOfYearWithOptions/index.js.flow +++ b/src/fp/startOfYearWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subDays/index.js.flow b/src/fp/subDays/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/subDays/index.js.flow +++ b/src/fp/subDays/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subDaysWithOptions/index.js.flow b/src/fp/subDaysWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/subDaysWithOptions/index.js.flow +++ b/src/fp/subDaysWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subHours/index.js.flow b/src/fp/subHours/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/subHours/index.js.flow +++ b/src/fp/subHours/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subHoursWithOptions/index.js.flow b/src/fp/subHoursWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/subHoursWithOptions/index.js.flow +++ b/src/fp/subHoursWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subISOYears/index.js.flow b/src/fp/subISOYears/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/subISOYears/index.js.flow +++ b/src/fp/subISOYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subISOYearsWithOptions/index.js.flow b/src/fp/subISOYearsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/subISOYearsWithOptions/index.js.flow +++ b/src/fp/subISOYearsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subMilliseconds/index.js.flow b/src/fp/subMilliseconds/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/subMilliseconds/index.js.flow +++ b/src/fp/subMilliseconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subMillisecondsWithOptions/index.js.flow b/src/fp/subMillisecondsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/subMillisecondsWithOptions/index.js.flow +++ b/src/fp/subMillisecondsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subMinutes/index.js.flow b/src/fp/subMinutes/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/subMinutes/index.js.flow +++ b/src/fp/subMinutes/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subMinutesWithOptions/index.js.flow b/src/fp/subMinutesWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/subMinutesWithOptions/index.js.flow +++ b/src/fp/subMinutesWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subMonths/index.js.flow b/src/fp/subMonths/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/subMonths/index.js.flow +++ b/src/fp/subMonths/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subMonthsWithOptions/index.js.flow b/src/fp/subMonthsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/subMonthsWithOptions/index.js.flow +++ b/src/fp/subMonthsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subQuarters/index.js.flow b/src/fp/subQuarters/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/subQuarters/index.js.flow +++ b/src/fp/subQuarters/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subQuartersWithOptions/index.js.flow b/src/fp/subQuartersWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/subQuartersWithOptions/index.js.flow +++ b/src/fp/subQuartersWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subSeconds/index.js.flow b/src/fp/subSeconds/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/subSeconds/index.js.flow +++ b/src/fp/subSeconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subSecondsWithOptions/index.js.flow b/src/fp/subSecondsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/subSecondsWithOptions/index.js.flow +++ b/src/fp/subSecondsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subWeeks/index.js.flow b/src/fp/subWeeks/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/subWeeks/index.js.flow +++ b/src/fp/subWeeks/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subWeeksWithOptions/index.js.flow b/src/fp/subWeeksWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/subWeeksWithOptions/index.js.flow +++ b/src/fp/subWeeksWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subYears/index.js.flow b/src/fp/subYears/index.js.flow index 5b0fa88cd0..1f2d724072 100644 --- a/src/fp/subYears/index.js.flow +++ b/src/fp/subYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/subYearsWithOptions/index.js.flow b/src/fp/subYearsWithOptions/index.js.flow index ac4be4541f..ddb4b4588b 100644 --- a/src/fp/subYearsWithOptions/index.js.flow +++ b/src/fp/subYearsWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/toDate/index.js.flow b/src/fp/toDate/index.js.flow index f711744903..372cc3770b 100644 --- a/src/fp/toDate/index.js.flow +++ b/src/fp/toDate/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/fp/toDateWithOptions/index.js.flow b/src/fp/toDateWithOptions/index.js.flow index ace7fcf174..e5b67db47b 100644 --- a/src/fp/toDateWithOptions/index.js.flow +++ b/src/fp/toDateWithOptions/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getDate/index.js b/src/getDate/index.js index 6820318d7d..9bd7749ab4 100644 --- a/src/getDate/index.js +++ b/src/getDate/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the day of month + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which day of the month is 29 February 2012? diff --git a/src/getDate/index.js.flow b/src/getDate/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getDate/index.js.flow +++ b/src/getDate/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getDate/test.js b/src/getDate/test.js index 44b7c2149b..252d36d454 100644 --- a/src/getDate/test.js +++ b/src/getDate/test.js @@ -19,4 +19,15 @@ describe('getDate', function () { var result = getDate(new Date(2014, 11 /* Dec */, 31).getTime()) assert(result === 31) }) + + it('returns NaN if the given date is invalid', function () { + var result = getDate(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getDate.bind(null, new Date(2012, 1 /* Feb */, 29), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getDay/index.js b/src/getDay/index.js index b0ff7e87f8..248880c15d 100644 --- a/src/getDay/index.js +++ b/src/getDay/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the day of week + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which day of the week is 29 February 2012? diff --git a/src/getDay/index.js.flow b/src/getDay/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getDay/index.js.flow +++ b/src/getDay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getDay/test.js b/src/getDay/test.js index 9e091f5893..fd133e03b5 100644 --- a/src/getDay/test.js +++ b/src/getDay/test.js @@ -19,4 +19,15 @@ describe('getDay', function () { var result = getDay(new Date(2014, 5 /* Jun */, 1).getTime()) assert(result === 0) }) + + it('returns NaN if the given date is invalid', function () { + var result = getDay(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getDay.bind(null, new Date(2012, 1 /* Feb */, 29), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getDayOfYear/index.js b/src/getDayOfYear/index.js index 4e9c47882b..229b964ec3 100644 --- a/src/getDayOfYear/index.js +++ b/src/getDayOfYear/index.js @@ -12,7 +12,9 @@ import differenceInCalendarDays from '../differenceInCalendarDays/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the day of year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which day of the year is 2 July 2014? diff --git a/src/getDayOfYear/index.js.flow b/src/getDayOfYear/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getDayOfYear/index.js.flow +++ b/src/getDayOfYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getDayOfYear/test.js b/src/getDayOfYear/test.js index 81e5242087..2280e15f82 100644 --- a/src/getDayOfYear/test.js +++ b/src/getDayOfYear/test.js @@ -27,4 +27,15 @@ describe('getDayOfYear', function () { var result = getDayOfYear(initialDate) assert(result === 366) }) + + it('returns NaN if the given date is invalid', function () { + var result = getDayOfYear(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getDayOfYear.bind(null, new Date(2014, 6 /* Jul */, 2), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getDaysInMonth/index.js b/src/getDaysInMonth/index.js index 6971c27c69..5fe7a13450 100644 --- a/src/getDaysInMonth/index.js +++ b/src/getDaysInMonth/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of days in a month + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many days are in February 2000? diff --git a/src/getDaysInMonth/index.js.flow b/src/getDaysInMonth/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getDaysInMonth/index.js.flow +++ b/src/getDaysInMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getDaysInMonth/test.js b/src/getDaysInMonth/test.js index 008bb485e5..778541b5ad 100644 --- a/src/getDaysInMonth/test.js +++ b/src/getDaysInMonth/test.js @@ -34,4 +34,15 @@ describe('getDaysInMonth', function () { var result = getDaysInMonth(date) assert(result === 29) }) + + it('returns NaN if the given date is invalid', function () { + var result = getDaysInMonth(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getDaysInMonth.bind(null, new Date(2100, 1 /* Feb */, 11), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getDaysInYear/index.js b/src/getDaysInYear/index.js index e51d1afdeb..34cb19ac89 100644 --- a/src/getDaysInYear/index.js +++ b/src/getDaysInYear/index.js @@ -1,3 +1,4 @@ +import toDate from '../toDate/index.js' import isLeapYear from '../isLeapYear/index.js' /** @@ -10,7 +11,9 @@ import isLeapYear from '../isLeapYear/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of days in a year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many days are in 2012? @@ -18,5 +21,11 @@ import isLeapYear from '../isLeapYear/index.js' * //=> 366 */ export default function getDaysInYear (dirtyDate, dirtyOptions) { - return isLeapYear(dirtyDate, dirtyOptions) ? 366 : 365 + var date = toDate(dirtyDate, dirtyOptions) + + if (isNaN(date)) { + return NaN + } + + return isLeapYear(date, dirtyOptions) ? 366 : 365 } diff --git a/src/getDaysInYear/index.js.flow b/src/getDaysInYear/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getDaysInYear/index.js.flow +++ b/src/getDaysInYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getDaysInYear/test.js b/src/getDaysInYear/test.js index 3291c9a1c5..6acd4616de 100644 --- a/src/getDaysInYear/test.js +++ b/src/getDaysInYear/test.js @@ -36,4 +36,15 @@ describe('getDaysInYear', function () { var result = getDaysInYear(date) assert(result === 366) }) + + it('returns NaN if the given date is invalid', function () { + var result = getDaysInYear(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getDaysInYear.bind(null, new Date(2014, 6 /* Jul */, 2), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getHours/index.js b/src/getHours/index.js index 7fdfc2bf36..6fa387d049 100644 --- a/src/getHours/index.js +++ b/src/getHours/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the hours + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Get the hours of 29 February 2012 11:45:00: diff --git a/src/getHours/index.js.flow b/src/getHours/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getHours/index.js.flow +++ b/src/getHours/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getHours/test.js b/src/getHours/test.js index 24d633c6d1..1547db3aa1 100644 --- a/src/getHours/test.js +++ b/src/getHours/test.js @@ -19,4 +19,15 @@ describe('getHours', function () { var result = getHours(new Date(2014, 3 /* Apr */, 2, 23, 30).getTime()) assert(result === 23) }) + + it('returns NaN if the given date is invalid', function () { + var result = getHours(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getHours.bind(null, new Date(2012, 1 /* Feb */, 29, 11, 45), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getISODay/index.js b/src/getISODay/index.js index bd6cfab04a..d3cc0e6fee 100644 --- a/src/getISODay/index.js +++ b/src/getISODay/index.js @@ -13,7 +13,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the day of ISO week + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which day of the ISO week is 26 February 2012? diff --git a/src/getISODay/index.js.flow b/src/getISODay/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getISODay/index.js.flow +++ b/src/getISODay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getISODay/test.js b/src/getISODay/test.js index 557f09da44..a462412ced 100644 --- a/src/getISODay/test.js +++ b/src/getISODay/test.js @@ -24,4 +24,15 @@ describe('getISODay', function () { var result = getISODay(new Date(2014, 5 /* Jun */, 1).getTime()) assert(result === 7) }) + + it('returns NaN if the given date is invalid', function () { + var result = getISODay(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getISODay.bind(null, new Date(2012, 1 /* Feb */, 29), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getISOWeek/index.js b/src/getISOWeek/index.js index c94cad1bec..5bcb08e32a 100644 --- a/src/getISOWeek/index.js +++ b/src/getISOWeek/index.js @@ -16,7 +16,9 @@ var MILLISECONDS_IN_WEEK = 604800000 * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the ISO week + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which week of the ISO-week numbering year is 2 January 2005? diff --git a/src/getISOWeek/index.js.flow b/src/getISOWeek/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getISOWeek/index.js.flow +++ b/src/getISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getISOWeek/test.js b/src/getISOWeek/test.js index 6302845e60..b5a3ed5f38 100644 --- a/src/getISOWeek/test.js +++ b/src/getISOWeek/test.js @@ -49,4 +49,15 @@ describe('getISOWeek', function () { var result = getISOWeek(initialDate) assert(result === 52) }) + + it('returns NaN if the given date is invalid', function () { + var result = getISOWeek(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getISOWeek.bind(null, new Date(2005, 0 /* Jan */, 2), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getISOWeeksInYear/index.js b/src/getISOWeeksInYear/index.js index 9c5a608888..c614d77039 100644 --- a/src/getISOWeeksInYear/index.js +++ b/src/getISOWeeksInYear/index.js @@ -15,7 +15,9 @@ var MILLISECONDS_IN_WEEK = 604800000 * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of ISO weeks in a year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // How many weeks are in ISO week-numbering year 2015? diff --git a/src/getISOWeeksInYear/index.js.flow b/src/getISOWeeksInYear/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getISOWeeksInYear/index.js.flow +++ b/src/getISOWeeksInYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getISOWeeksInYear/test.js b/src/getISOWeeksInYear/test.js index 6931340028..098c76d5ac 100644 --- a/src/getISOWeeksInYear/test.js +++ b/src/getISOWeeksInYear/test.js @@ -29,4 +29,15 @@ describe('getISOWeeksInYear', function () { var result = getISOWeeksInYear(initialDate) assert(result === 53) }) + + it('returns NaN if the given date is invalid', function () { + var result = getISOWeeksInYear(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getISOWeeksInYear.bind(null, new Date(2015, 1 /* Feb */, 11), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getISOYear/index.js b/src/getISOYear/index.js index 9c05063fbc..5132a04f19 100644 --- a/src/getISOYear/index.js +++ b/src/getISOYear/index.js @@ -14,7 +14,9 @@ import startOfISOWeek from '../startOfISOWeek/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the ISO week-numbering year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which ISO-week numbering year is 2 January 2005? diff --git a/src/getISOYear/index.js.flow b/src/getISOYear/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getISOYear/index.js.flow +++ b/src/getISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getISOYear/test.js b/src/getISOYear/test.js index 09d87cfdcf..1009557349 100644 --- a/src/getISOYear/test.js +++ b/src/getISOYear/test.js @@ -27,4 +27,15 @@ describe('getISOYear', function () { var result = getISOYear(initialDate) assert(result === 8) }) + + it('returns NaN if the given date is invalid', function () { + var result = getISOYear(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getISOYear.bind(null, new Date(2007, 11 /* Dec */, 31), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getMilliseconds/index.js b/src/getMilliseconds/index.js index ba55bafaaf..959e6c8910 100644 --- a/src/getMilliseconds/index.js +++ b/src/getMilliseconds/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the milliseconds + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Get the milliseconds of 29 February 2012 11:45:05.123: diff --git a/src/getMilliseconds/index.js.flow b/src/getMilliseconds/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getMilliseconds/index.js.flow +++ b/src/getMilliseconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getMilliseconds/test.js b/src/getMilliseconds/test.js index 63986e6fc3..483ee18da8 100644 --- a/src/getMilliseconds/test.js +++ b/src/getMilliseconds/test.js @@ -19,4 +19,15 @@ describe('getMilliseconds', function () { var result = getMilliseconds(new Date(2014, 3 /* Apr */, 2, 23, 30, 42, 500).getTime()) assert(result === 500) }) + + it('returns NaN if the given date is invalid', function () { + var result = getMilliseconds(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getMilliseconds.bind(null, new Date(2012, 1 /* Feb */, 29, 11, 45, 5, 123), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getMinutes/index.js b/src/getMinutes/index.js index 2fd009ef57..77b2e32ac6 100644 --- a/src/getMinutes/index.js +++ b/src/getMinutes/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the minutes + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Get the minutes of 29 February 2012 11:45:05: diff --git a/src/getMinutes/index.js.flow b/src/getMinutes/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getMinutes/index.js.flow +++ b/src/getMinutes/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getMinutes/test.js b/src/getMinutes/test.js index 3ce3b6d948..8da979ce5c 100644 --- a/src/getMinutes/test.js +++ b/src/getMinutes/test.js @@ -19,4 +19,15 @@ describe('getMinutes', function () { var result = getMinutes(new Date(2014, 3 /* Apr */, 2, 23, 30).getTime()) assert(result === 30) }) + + it('returns NaN if the given date is invalid', function () { + var result = getMinutes(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getMinutes.bind(null, new Date(2012, 1 /* Feb */, 29, 11, 45, 5), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getMonth/index.js b/src/getMonth/index.js index d1b7ae982e..a835d743d8 100644 --- a/src/getMonth/index.js +++ b/src/getMonth/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the month + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which month is 29 February 2012? diff --git a/src/getMonth/index.js.flow b/src/getMonth/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getMonth/index.js.flow +++ b/src/getMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getMonth/test.js b/src/getMonth/test.js index 005ae50335..112d8e4738 100644 --- a/src/getMonth/test.js +++ b/src/getMonth/test.js @@ -19,4 +19,15 @@ describe('getMonth', function () { var result = getMonth(new Date(2014, 3 /* Apr */, 2).getTime()) assert(result === 3) }) + + it('returns NaN if the given date is invalid', function () { + var result = getMonth(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getMonth.bind(null, new Date(2012, 1 /* Feb */, 29), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getOverlappingDaysInIntervals/index.js b/src/getOverlappingDaysInIntervals/index.js index 54f5fca62e..cb143c9a4d 100644 --- a/src/getOverlappingDaysInIntervals/index.js +++ b/src/getOverlappingDaysInIntervals/index.js @@ -13,8 +13,11 @@ var MILLISECONDS_IN_DAY = 24 * 60 * 60 * 1000 * @param {Interval} intervalLeft - the first interval to compare. See [Interval]{@link docs/Interval} * @param {Interval} intervalRight - the second interval to compare. See [Interval]{@link docs/Interval} * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the number of days that overlap in two time intervals - * @throws {Error} The start of an interval cannot be after its end + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} The start of an interval cannot be after its end + * @throws {RangeError} Date in interval cannot be `Invalid Date` * * @example * // For overlapping time intervals adds 1 for each started overlapping day: @@ -38,8 +41,9 @@ export default function getOverlappingDaysInIntervals (dirtyIntervalLeft, dirtyI var rightStartTime = toDate(dirtyIntervalRight.start, dirtyOptions).getTime() var rightEndTime = toDate(dirtyIntervalRight.end, dirtyOptions).getTime() - if (leftStartTime > leftEndTime || rightStartTime > rightEndTime) { - throw new Error('The start of an interval cannot be after its end') + // Throw an exception if start date is after end date or if any date is `Invalid Date` + if (!(leftStartTime <= leftEndTime && rightStartTime <= rightEndTime)) { + throw new RangeError('Invalid interval') } var isOverlapping = leftStartTime < rightEndTime && rightStartTime < leftEndTime diff --git a/src/getOverlappingDaysInIntervals/index.js.flow b/src/getOverlappingDaysInIntervals/index.js.flow index 732964f889..497b3c426b 100644 --- a/src/getOverlappingDaysInIntervals/index.js.flow +++ b/src/getOverlappingDaysInIntervals/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getOverlappingDaysInIntervals/test.js b/src/getOverlappingDaysInIntervals/test.js index 577e6ff59e..4db2259061 100644 --- a/src/getOverlappingDaysInIntervals/test.js +++ b/src/getOverlappingDaysInIntervals/test.js @@ -167,7 +167,7 @@ describe('getOverlappingDaysInIntervals', function () { {start: new Date(2016, 10, 7), end: new Date(2016, 10, 3)}, {start: new Date(2016, 10, 5), end: new Date(2016, 10, 15)} ) - assert.throws(block) + assert.throws(block, RangeError) }) it('throws an exception if the start date of the compared time interval is after the end date', function () { @@ -176,6 +176,58 @@ describe('getOverlappingDaysInIntervals', function () { {start: new Date(2016, 10, 3), end: new Date(2016, 10, 7)}, {start: new Date(2016, 10, 15), end: new Date(2016, 10, 5)} ) - assert.throws(block) + assert.throws(block, RangeError) + }) + + context('one of the dates is `Invalid Date`', function () { + it('throws an exception if the start date of the initial time interval is `Invalid Date`', function () { + var block = getOverlappingDaysInIntervals.bind( + null, + {start: new Date(NaN), end: new Date(2016, 10, 3)}, + {start: new Date(2016, 10, 5), end: new Date(2016, 10, 15)} + ) + assert.throws(block, RangeError) + }) + + it('throws an exception if the end date of the initial time interval is `Invalid Date`', function () { + var block = getOverlappingDaysInIntervals.bind( + null, + {start: new Date(2016, 10, 3), end: new Date(NaN)}, + {start: new Date(2016, 10, 5), end: new Date(2016, 10, 15)} + ) + assert.throws(block, RangeError) + }) + + it('throws an exception if the start date of the compared time interval is `Invalid Date`', function () { + var block = getOverlappingDaysInIntervals.bind( + null, + {start: new Date(2016, 10, 3), end: new Date(2016, 10, 7)}, + {start: new Date(NaN), end: new Date(2016, 10, 5)} + ) + assert.throws(block, RangeError) + }) + + it('throws an exception if the end date of the compared time interval is `Invalid Date`', function () { + var block = getOverlappingDaysInIntervals.bind( + null, + {start: new Date(2016, 10, 3), end: new Date(2016, 10, 7)}, + {start: new Date(2016, 10, 5), end: new Date(NaN)} + ) + assert.throws(block, RangeError) + }) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var earlierIntervalStart = new Date(2016, 9, 25) + var earlierIntervalEnd = new Date(2016, 10, 9) + + var block = getOverlappingDaysInIntervals.bind( + null, + {start: initialIntervalStart, end: initialIntervalEnd}, + {start: earlierIntervalStart, end: earlierIntervalEnd}, + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) }) }) diff --git a/src/getQuarter/index.js b/src/getQuarter/index.js index 1d321cc462..d85573ff23 100644 --- a/src/getQuarter/index.js +++ b/src/getQuarter/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the quarter + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which quarter is 2 July 2014? diff --git a/src/getQuarter/index.js.flow b/src/getQuarter/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getQuarter/index.js.flow +++ b/src/getQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getQuarter/test.js b/src/getQuarter/test.js index 03c81e5618..8b45b70564 100644 --- a/src/getQuarter/test.js +++ b/src/getQuarter/test.js @@ -19,4 +19,15 @@ describe('getQuarter', function () { var result = getQuarter(new Date(2014, 3 /* Apr */, 2).getTime()) assert(result === 2) }) + + it('returns NaN if the given date is invalid', function () { + var result = getQuarter(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getQuarter.bind(null, new Date(2014, 6 /* Jul */, 2), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getSeconds/index.js b/src/getSeconds/index.js index d6ee3c9518..350a085207 100644 --- a/src/getSeconds/index.js +++ b/src/getSeconds/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the seconds + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Get the seconds of 29 February 2012 11:45:05.123: diff --git a/src/getSeconds/index.js.flow b/src/getSeconds/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getSeconds/index.js.flow +++ b/src/getSeconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getSeconds/test.js b/src/getSeconds/test.js index a9cb1f3a87..35013e3c72 100644 --- a/src/getSeconds/test.js +++ b/src/getSeconds/test.js @@ -19,4 +19,15 @@ describe('getSeconds', function () { var result = getSeconds(new Date(2014, 3 /* Apr */, 2, 23, 30, 42).getTime()) assert(result === 42) }) + + it('returns NaN if the given date is invalid', function () { + var result = getSeconds(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getSeconds.bind(null, new Date(2012, 1 /* Feb */, 29, 11, 45, 5, 123), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getTime/index.js b/src/getTime/index.js index bd3a528ebe..e5c847f964 100644 --- a/src/getTime/index.js +++ b/src/getTime/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the timestamp + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Get the timestamp of 29 February 2012 11:45:05.123: diff --git a/src/getTime/index.js.flow b/src/getTime/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getTime/index.js.flow +++ b/src/getTime/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getTime/test.js b/src/getTime/test.js index 7e8f9e460d..e8b13f7168 100644 --- a/src/getTime/test.js +++ b/src/getTime/test.js @@ -22,4 +22,16 @@ describe('getTime', function () { var result = getTime(timestamp) assert(result === timestamp) }) + + it('returns NaN if the given date is invalid', function () { + var result = getTime(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var timestamp = 1483228800000 + // $ExpectedMistake + var block = getTime.bind(null, new Date(timestamp), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/getYear/index.js b/src/getYear/index.js index 0c4ca1f0fb..0729df65be 100644 --- a/src/getYear/index.js +++ b/src/getYear/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the given date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Number} the year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which year is 2 July 2014? diff --git a/src/getYear/index.js.flow b/src/getYear/index.js.flow index 1e6055bbd0..33086accbb 100644 --- a/src/getYear/index.js.flow +++ b/src/getYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/getYear/test.js b/src/getYear/test.js index f1dc12ec8a..b97b1e4aca 100644 --- a/src/getYear/test.js +++ b/src/getYear/test.js @@ -19,4 +19,15 @@ describe('getYear', function () { var result = getYear(new Date(20000, 3 /* Apr */, 2).getTime()) assert(result === 20000) }) + + it('returns NaN if the given date is invalid', function () { + var result = getYear(new Date(NaN)) + assert(isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = getYear.bind(null, new Date(2014, 6 /* Jul */, 2), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isAfter/index.js b/src/isAfter/index.js index 8a88d9a389..fb65d06b32 100644 --- a/src/isAfter/index.js +++ b/src/isAfter/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date that should be after the other one to return true * @param {Date|String|Number} dateToCompare - the date to compare with * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the first date is after the second date + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 10 July 1989 after 11 February 1987? diff --git a/src/isAfter/index.js.flow b/src/isAfter/index.js.flow index 6ce51ba082..4d5a709492 100644 --- a/src/isAfter/index.js.flow +++ b/src/isAfter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isAfter/test.js b/src/isAfter/test.js index 558bf50768..de6e859e98 100644 --- a/src/isAfter/test.js +++ b/src/isAfter/test.js @@ -44,4 +44,39 @@ describe('isAfter', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isAfter( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isAfter( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isAfter( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isAfter.bind( + null, + new Date(1989, 6 /* Jul */, 10), + new Date(1987, 1 /* Feb */, 11), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isBefore/index.js b/src/isBefore/index.js index dea9ccc153..fb5f9dcb63 100644 --- a/src/isBefore/index.js +++ b/src/isBefore/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date that should be before the other one to return true * @param {Date|String|Number} dateToCompare - the date to compare with * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the first date is before the second date + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 10 July 1989 before 11 February 1987? diff --git a/src/isBefore/index.js.flow b/src/isBefore/index.js.flow index 6ce51ba082..4d5a709492 100644 --- a/src/isBefore/index.js.flow +++ b/src/isBefore/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isBefore/test.js b/src/isBefore/test.js index b05e2f1777..ff0c4f9bd9 100644 --- a/src/isBefore/test.js +++ b/src/isBefore/test.js @@ -44,4 +44,39 @@ describe('isBefore', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isBefore( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isBefore( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isBefore( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isBefore.bind( + null, + new Date(1987, 1 /* Feb */, 11), + new Date(1989, 6 /* Jul */, 10), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isDate/index.js.flow b/src/isDate/index.js.flow index 311e530527..000e61a201 100644 --- a/src/isDate/index.js.flow +++ b/src/isDate/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isEqual/index.js b/src/isEqual/index.js index 003c311bcd..180da56e42 100644 --- a/src/isEqual/index.js +++ b/src/isEqual/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} dateLeft - the first date to compare * @param {Date|String|Number} dateRight - the second date to compare * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the dates are equal + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Are 2 July 2014 06:30:45.000 and 2 July 2014 06:30:45.500 equal? diff --git a/src/isEqual/index.js.flow b/src/isEqual/index.js.flow index f84117193e..b5d7a7fd08 100644 --- a/src/isEqual/index.js.flow +++ b/src/isEqual/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isEqual/test.js b/src/isEqual/test.js index e352fd4994..8f157cfbd6 100644 --- a/src/isEqual/test.js +++ b/src/isEqual/test.js @@ -36,4 +36,39 @@ describe('isEqual', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isEqual( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isEqual( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isEqual( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isEqual.bind( + null, + new Date(1987, 1 /* Feb */, 11), + new Date(1987, 1 /* Feb */, 11), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isFirstDayOfMonth/index.js b/src/isFirstDayOfMonth/index.js index 4ce13575fb..64b6f5a4fa 100644 --- a/src/isFirstDayOfMonth/index.js +++ b/src/isFirstDayOfMonth/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is the first day of a month + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 1 September 2014 the first day of a month? diff --git a/src/isFirstDayOfMonth/index.js.flow b/src/isFirstDayOfMonth/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isFirstDayOfMonth/index.js.flow +++ b/src/isFirstDayOfMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isFirstDayOfMonth/test.js b/src/isFirstDayOfMonth/test.js index 33297f3778..ff7d80e0b7 100644 --- a/src/isFirstDayOfMonth/test.js +++ b/src/isFirstDayOfMonth/test.js @@ -26,4 +26,15 @@ describe('isFirstDayOfMonth', function () { var result = isFirstDayOfMonth(date) assert(result === true) }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isFirstDayOfMonth(new Date(NaN)) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isFirstDayOfMonth.bind(null, new Date(2014, 9 /* Oct */, 1), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isFriday/index.js b/src/isFriday/index.js index eacbbb6972..694aaed629 100644 --- a/src/isFriday/index.js +++ b/src/isFriday/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is Friday + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 26 September 2014 Friday? diff --git a/src/isFriday/index.js.flow b/src/isFriday/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isFriday/index.js.flow +++ b/src/isFriday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isFriday/test.js b/src/isFriday/test.js index 834f34329e..14b46d1335 100644 --- a/src/isFriday/test.js +++ b/src/isFriday/test.js @@ -24,4 +24,15 @@ describe('isFriday', function () { var result = isFriday(new Date(2014, 1 /* Feb */, 14).getTime()) assert(result === true) }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isFriday(new Date(NaN)) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isFriday.bind(null, new Date(2014, 8 /* Sep */, 26), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isLastDayOfMonth/index.js b/src/isLastDayOfMonth/index.js index 9d2ef3c0b8..e82946c9dc 100644 --- a/src/isLastDayOfMonth/index.js +++ b/src/isLastDayOfMonth/index.js @@ -12,7 +12,9 @@ import endOfMonth from '../endOfMonth/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is the last day of a month + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 28 February 2014 the last day of a month? diff --git a/src/isLastDayOfMonth/index.js.flow b/src/isLastDayOfMonth/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isLastDayOfMonth/index.js.flow +++ b/src/isLastDayOfMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isLastDayOfMonth/test.js b/src/isLastDayOfMonth/test.js index fbc7622628..ac103dba3d 100644 --- a/src/isLastDayOfMonth/test.js +++ b/src/isLastDayOfMonth/test.js @@ -26,4 +26,15 @@ describe('isLastDayOfMonth', function () { var result = isLastDayOfMonth(date) assert(result === true) }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isLastDayOfMonth(new Date(NaN)) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isLastDayOfMonth.bind(null, new Date(2014, 9 /* Oct */, 31), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isLeapYear/index.js b/src/isLeapYear/index.js index 1c16da74ae..accee60f5c 100644 --- a/src/isLeapYear/index.js +++ b/src/isLeapYear/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is in the leap year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 1 September 2012 in the leap year? diff --git a/src/isLeapYear/index.js.flow b/src/isLeapYear/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isLeapYear/index.js.flow +++ b/src/isLeapYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isLeapYear/test.js b/src/isLeapYear/test.js index a43db0b5b9..1dceb1c3df 100644 --- a/src/isLeapYear/test.js +++ b/src/isLeapYear/test.js @@ -36,4 +36,15 @@ describe('isLeapYear', function () { var result = isLeapYear(date) assert(result === true) }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isLeapYear(new Date(NaN)) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isLeapYear.bind(null, new Date(2012, 6 /* Jul */, 2), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isMonday/index.js b/src/isMonday/index.js index 6e511fd252..6bfb665774 100644 --- a/src/isMonday/index.js +++ b/src/isMonday/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is Monday + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 22 September 2014 Monday? diff --git a/src/isMonday/index.js.flow b/src/isMonday/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isMonday/index.js.flow +++ b/src/isMonday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isMonday/test.js b/src/isMonday/test.js index 5c7c4fc7ca..234262e53a 100644 --- a/src/isMonday/test.js +++ b/src/isMonday/test.js @@ -24,4 +24,15 @@ describe('isMonday', function () { var result = isMonday(new Date(2014, 1 /* Feb */, 10).getTime()) assert(result === true) }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isMonday(new Date(NaN)) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isMonday.bind(null, new Date(2014, 8 /* Sep */, 22), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSameDay/index.js b/src/isSameDay/index.js index 37c4e2b177..ce3f7fd567 100644 --- a/src/isSameDay/index.js +++ b/src/isSameDay/index.js @@ -11,7 +11,9 @@ import startOfDay from '../startOfDay/index.js' * @param {Date|String|Number} dateLeft - the first date to check * @param {Date|String|Number} dateRight - the second date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the dates are in the same day + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day? diff --git a/src/isSameDay/index.js.flow b/src/isSameDay/index.js.flow index f84117193e..b5d7a7fd08 100644 --- a/src/isSameDay/index.js.flow +++ b/src/isSameDay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSameDay/test.js b/src/isSameDay/test.js index fd13543ac4..edb54e9616 100644 --- a/src/isSameDay/test.js +++ b/src/isSameDay/test.js @@ -36,4 +36,39 @@ describe('isSameDay', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isSameDay( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isSameDay( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isSameDay( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isSameDay.bind( + null, + new Date(2014, 8 /* Sep */, 4, 6, 0), + new Date(2014, 8 /* Sep */, 4, 18, 0), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSameHour/index.js b/src/isSameHour/index.js index 39c832383a..a62c01e4a8 100644 --- a/src/isSameHour/index.js +++ b/src/isSameHour/index.js @@ -11,7 +11,9 @@ import startOfHour from '../startOfHour/index.js' * @param {Date|String|Number} dateLeft - the first date to check * @param {Date|String|Number} dateRight - the second date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the dates are in the same hour + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Are 4 September 2014 06:00:00 and 4 September 06:30:00 in the same hour? diff --git a/src/isSameHour/index.js.flow b/src/isSameHour/index.js.flow index f84117193e..b5d7a7fd08 100644 --- a/src/isSameHour/index.js.flow +++ b/src/isSameHour/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSameHour/test.js b/src/isSameHour/test.js index 2edd228670..a564a4cf5e 100644 --- a/src/isSameHour/test.js +++ b/src/isSameHour/test.js @@ -36,4 +36,39 @@ describe('isSameHour', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isSameHour( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isSameHour( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isSameHour( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isSameHour.bind( + null, + new Date(2014, 8 /* Sep */, 4, 6, 0), + new Date(2014, 8 /* Sep */, 4, 6, 30), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSameISOWeek/index.js b/src/isSameISOWeek/index.js index d14cb5cfde..362be736e0 100644 --- a/src/isSameISOWeek/index.js +++ b/src/isSameISOWeek/index.js @@ -14,7 +14,9 @@ import cloneObject from '../_lib/cloneObject/index.js' * @param {Date|String|Number} dateLeft - the first date to check * @param {Date|String|Number} dateRight - the second date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the dates are in the same ISO week + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Are 1 September 2014 and 7 September 2014 in the same ISO week? diff --git a/src/isSameISOWeek/index.js.flow b/src/isSameISOWeek/index.js.flow index f84117193e..b5d7a7fd08 100644 --- a/src/isSameISOWeek/index.js.flow +++ b/src/isSameISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSameISOWeek/test.js b/src/isSameISOWeek/test.js index 33deaf48a0..927ea41f03 100644 --- a/src/isSameISOWeek/test.js +++ b/src/isSameISOWeek/test.js @@ -36,4 +36,39 @@ describe('isSameISOWeek', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isSameISOWeek( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isSameISOWeek( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isSameISOWeek( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isSameISOWeek.bind( + null, + new Date(2014, 8 /* Sep */, 1), + new Date(2014, 8 /* Sep */, 7), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSameISOYear/index.js b/src/isSameISOYear/index.js index ea41865b56..8925a1f5bb 100644 --- a/src/isSameISOYear/index.js +++ b/src/isSameISOYear/index.js @@ -13,7 +13,9 @@ import startOfISOYear from '../startOfISOYear/index.js' * @param {Date|String|Number} dateLeft - the first date to check * @param {Date|String|Number} dateRight - the second date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the dates are in the same ISO week-numbering year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Are 29 December 2003 and 2 January 2005 in the same ISO week-numbering year? diff --git a/src/isSameISOYear/index.js.flow b/src/isSameISOYear/index.js.flow index f84117193e..b5d7a7fd08 100644 --- a/src/isSameISOYear/index.js.flow +++ b/src/isSameISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSameISOYear/test.js b/src/isSameISOYear/test.js index 9984ff6422..00896bc8c4 100644 --- a/src/isSameISOYear/test.js +++ b/src/isSameISOYear/test.js @@ -47,4 +47,39 @@ describe('isSameISOYear', function () { var result = isSameISOYear(firstDate, secondDate) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isSameISOYear( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isSameISOYear( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isSameISOYear( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isSameISOYear.bind( + null, + new Date(2003, 11 /* Dec */, 29), + new Date(2005, 0 /* Jan */, 2), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSameMinute/index.js b/src/isSameMinute/index.js index 456ccf4bcd..ccb8508ae2 100644 --- a/src/isSameMinute/index.js +++ b/src/isSameMinute/index.js @@ -11,7 +11,9 @@ import startOfMinute from '../startOfMinute/index.js' * @param {Date|String|Number} dateLeft - the first date to check * @param {Date|String|Number} dateRight - the second date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the dates are in the same minute + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Are 4 September 2014 06:30:00 and 4 September 2014 06:30:15 diff --git a/src/isSameMinute/index.js.flow b/src/isSameMinute/index.js.flow index f84117193e..b5d7a7fd08 100644 --- a/src/isSameMinute/index.js.flow +++ b/src/isSameMinute/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSameMinute/test.js b/src/isSameMinute/test.js index 4b34ffee63..db63844ad6 100644 --- a/src/isSameMinute/test.js +++ b/src/isSameMinute/test.js @@ -36,4 +36,39 @@ describe('isSameMinute', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isSameMinute( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isSameMinute( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isSameMinute( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isSameMinute.bind( + null, + new Date(2014, 8 /* Sep */, 4, 6, 30), + new Date(2014, 8 /* Sep */, 4, 6, 30, 15), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSameMonth/index.js b/src/isSameMonth/index.js index 2d80a623f9..aa8f3101d9 100644 --- a/src/isSameMonth/index.js +++ b/src/isSameMonth/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} dateLeft - the first date to check * @param {Date|String|Number} dateRight - the second date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the dates are in the same month + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Are 2 September 2014 and 25 September 2014 in the same month? diff --git a/src/isSameMonth/index.js.flow b/src/isSameMonth/index.js.flow index f84117193e..b5d7a7fd08 100644 --- a/src/isSameMonth/index.js.flow +++ b/src/isSameMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSameMonth/test.js b/src/isSameMonth/test.js index 60e4922bb2..2c2ba7f1bc 100644 --- a/src/isSameMonth/test.js +++ b/src/isSameMonth/test.js @@ -36,4 +36,39 @@ describe('isSameMonth', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isSameMonth( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isSameMonth( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isSameMonth( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isSameMonth.bind( + null, + new Date(2014, 8 /* Sep */, 2), + new Date(2014, 8 /* Sep */, 25), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSameQuarter/index.js b/src/isSameQuarter/index.js index 8dfe6d8789..6477ff32d2 100644 --- a/src/isSameQuarter/index.js +++ b/src/isSameQuarter/index.js @@ -11,7 +11,9 @@ import startOfQuarter from '../startOfQuarter/index.js' * @param {Date|String|Number} dateLeft - the first date to check * @param {Date|String|Number} dateRight - the second date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the dates are in the same quarter + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Are 1 January 2014 and 8 March 2014 in the same quarter? diff --git a/src/isSameQuarter/index.js.flow b/src/isSameQuarter/index.js.flow index f84117193e..b5d7a7fd08 100644 --- a/src/isSameQuarter/index.js.flow +++ b/src/isSameQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSameQuarter/test.js b/src/isSameQuarter/test.js index 0edf0181e4..2ef589a97f 100644 --- a/src/isSameQuarter/test.js +++ b/src/isSameQuarter/test.js @@ -36,4 +36,39 @@ describe('isSameQuarter', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isSameQuarter( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isSameQuarter( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isSameQuarter( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isSameQuarter.bind( + null, + new Date(2014, 0 /* Jan */, 1), + new Date(2014, 2 /* Mar */, 8), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSameSecond/index.js b/src/isSameSecond/index.js index 5bd4d4cd7b..1c0442d526 100644 --- a/src/isSameSecond/index.js +++ b/src/isSameSecond/index.js @@ -11,7 +11,9 @@ import startOfSecond from '../startOfSecond/index.js' * @param {Date|String|Number} dateLeft - the first date to check * @param {Date|String|Number} dateRight - the second date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the dates are in the same second + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Are 4 September 2014 06:30:15.000 and 4 September 2014 06:30.15.500 diff --git a/src/isSameSecond/index.js.flow b/src/isSameSecond/index.js.flow index f84117193e..b5d7a7fd08 100644 --- a/src/isSameSecond/index.js.flow +++ b/src/isSameSecond/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSameSecond/test.js b/src/isSameSecond/test.js index f9b9c0fc54..a2ac90500d 100644 --- a/src/isSameSecond/test.js +++ b/src/isSameSecond/test.js @@ -36,4 +36,39 @@ describe('isSameSecond', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isSameSecond( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isSameSecond( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isSameSecond( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isSameSecond.bind( + null, + new Date(2014, 8 /* Sep */, 4, 6, 30, 15), + new Date(2014, 8 /* Sep */, 4, 6, 30, 15, 500), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSameWeek/index.js b/src/isSameWeek/index.js index 123023b24d..62430cea4b 100644 --- a/src/isSameWeek/index.js +++ b/src/isSameWeek/index.js @@ -11,8 +11,11 @@ import startOfWeek from '../startOfWeek/index.js' * @param {Date|String|Number} dateLeft - the first date to check * @param {Date|String|Number} dateRight - the second date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} - * @param {Number} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} + * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) * @returns {Boolean} the dates are in the same week + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6 * * @example * // Are 31 August 2014 and 4 September 2014 in the same week? diff --git a/src/isSameWeek/index.js.flow b/src/isSameWeek/index.js.flow index f84117193e..b5d7a7fd08 100644 --- a/src/isSameWeek/index.js.flow +++ b/src/isSameWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSameWeek/test.js b/src/isSameWeek/test.js index fe97bfc6e8..68dd00134c 100644 --- a/src/isSameWeek/test.js +++ b/src/isSameWeek/test.js @@ -55,4 +55,50 @@ describe('isSameWeek', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isSameWeek( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isSameWeek( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isSameWeek( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.weekStartsOn` is not convertable to 0, 1, ..., 6 or undefined', function () { + var block = isSameWeek.bind( + null, + new Date(2014, 7 /* Aug */, 31), + new Date(2014, 8 /* Sep */, 4), + // $ExpectedMistake + {weekStartsOn: NaN} + ) + assert.throws(block, RangeError) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isSameWeek.bind( + null, + new Date(2014, 7 /* Aug */, 31), + new Date(2014, 8 /* Sep */, 4), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSameYear/index.js b/src/isSameYear/index.js index ed49e22606..9901e78b4f 100644 --- a/src/isSameYear/index.js +++ b/src/isSameYear/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} dateLeft - the first date to check * @param {Date|String|Number} dateRight - the second date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the dates are in the same year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Are 2 September 2014 and 25 September 2014 in the same year? diff --git a/src/isSameYear/index.js.flow b/src/isSameYear/index.js.flow index f84117193e..b5d7a7fd08 100644 --- a/src/isSameYear/index.js.flow +++ b/src/isSameYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSameYear/test.js b/src/isSameYear/test.js index 904d039bbf..6f4d9e2f4f 100644 --- a/src/isSameYear/test.js +++ b/src/isSameYear/test.js @@ -36,4 +36,39 @@ describe('isSameYear', function () { ) assert(result === true) }) + + it('returns false if the first date is `Invalid Date`', function () { + var result = isSameYear( + new Date(NaN), + new Date(1989, 6 /* Jul */, 10) + ) + assert(result === false) + }) + + it('returns false if the second date is `Invalid Date`', function () { + var result = isSameYear( + new Date(1987, 1 /* Feb */, 11), + new Date(NaN) + ) + assert(result === false) + }) + + it('returns false if the both dates are `Invalid Date`', function () { + var result = isSameYear( + new Date(NaN), + new Date(NaN) + ) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isSameYear.bind( + null, + new Date(2014, 8 /* Sep */, 2), + new Date(2014, 8 /* Sep */, 25), + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSaturday/index.js b/src/isSaturday/index.js index 6dba460828..071f82f79e 100644 --- a/src/isSaturday/index.js +++ b/src/isSaturday/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is Saturday + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 27 September 2014 Saturday? diff --git a/src/isSaturday/index.js.flow b/src/isSaturday/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isSaturday/index.js.flow +++ b/src/isSaturday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSaturday/test.js b/src/isSaturday/test.js index c9457847c8..15743b2b1e 100644 --- a/src/isSaturday/test.js +++ b/src/isSaturday/test.js @@ -24,4 +24,15 @@ describe('isSaturday', function () { var result = isSaturday(new Date(2014, 1 /* Feb */, 15).getTime()) assert(result === true) }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isSaturday(new Date(NaN)) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isSaturday.bind(null, new Date(2014, 8 /* Sep */, 27), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isSunday/index.js b/src/isSunday/index.js index cb1afe72a4..937672eac1 100644 --- a/src/isSunday/index.js +++ b/src/isSunday/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is Sunday + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 21 September 2014 Sunday? diff --git a/src/isSunday/index.js.flow b/src/isSunday/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isSunday/index.js.flow +++ b/src/isSunday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isSunday/test.js b/src/isSunday/test.js index f6424aedb3..46e0eaeda8 100644 --- a/src/isSunday/test.js +++ b/src/isSunday/test.js @@ -24,4 +24,15 @@ describe('isSunday', function () { var result = isSunday(new Date(2014, 1 /* Feb */, 9).getTime()) assert(result === true) }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isSunday(new Date(NaN)) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isSunday.bind(null, new Date(2014, 8 /* Sep */, 21), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isThursday/index.js b/src/isThursday/index.js index d3d4b79f7d..65572238e4 100644 --- a/src/isThursday/index.js +++ b/src/isThursday/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is Thursday + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 25 September 2014 Thursday? diff --git a/src/isThursday/index.js.flow b/src/isThursday/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isThursday/index.js.flow +++ b/src/isThursday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isThursday/test.js b/src/isThursday/test.js index 67df8bd21e..bf9fe714f0 100644 --- a/src/isThursday/test.js +++ b/src/isThursday/test.js @@ -24,4 +24,15 @@ describe('isThursday', function () { var result = isThursday(new Date(2014, 1 /* Feb */, 13).getTime()) assert(result === true) }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isThursday(new Date(NaN)) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isThursday.bind(null, new Date(2014, 8 /* Sep */, 25), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isTuesday/index.js b/src/isTuesday/index.js index bb6d5a9d0e..e1be3fae19 100644 --- a/src/isTuesday/index.js +++ b/src/isTuesday/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is Tuesday + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 23 September 2014 Tuesday? diff --git a/src/isTuesday/index.js.flow b/src/isTuesday/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isTuesday/index.js.flow +++ b/src/isTuesday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isTuesday/test.js b/src/isTuesday/test.js index c2b0930b10..1a54ed9eed 100644 --- a/src/isTuesday/test.js +++ b/src/isTuesday/test.js @@ -24,4 +24,15 @@ describe('isTuesday', function () { var result = isTuesday(new Date(2014, 1 /* Feb */, 11).getTime()) assert(result === true) }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isTuesday(new Date(NaN)) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isTuesday.bind(null, new Date(2014, 8 /* Sep */, 23), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isValid/index.js b/src/isValid/index.js index ae5fc696f5..dcd41657d2 100644 --- a/src/isValid/index.js +++ b/src/isValid/index.js @@ -14,7 +14,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is valid + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // For the valid date: diff --git a/src/isValid/index.js.flow b/src/isValid/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isValid/index.js.flow +++ b/src/isValid/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isValid/test.js b/src/isValid/test.js index 64e9efcede..ec80b0ed5e 100644 --- a/src/isValid/test.js +++ b/src/isValid/test.js @@ -24,4 +24,10 @@ describe('isValid', function () { assert(isValid(new Date(2014, 1 /* Feb */, 11).getTime()) === true) assert(isValid(NaN) === false) }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isValid.bind(null, new Date(), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isWednesday/index.js b/src/isWednesday/index.js index 86fdc47de5..e459234be9 100644 --- a/src/isWednesday/index.js +++ b/src/isWednesday/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is Wednesday + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Is 24 September 2014 Wednesday? diff --git a/src/isWednesday/index.js.flow b/src/isWednesday/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isWednesday/index.js.flow +++ b/src/isWednesday/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isWednesday/test.js b/src/isWednesday/test.js index 08b192436f..5953a8d3d2 100644 --- a/src/isWednesday/test.js +++ b/src/isWednesday/test.js @@ -24,4 +24,15 @@ describe('isWednesday', function () { var result = isWednesday(new Date(2014, 1 /* Feb */, 12).getTime()) assert(result === true) }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isWednesday(new Date(NaN)) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isWednesday.bind(null, new Date(2014, 8 /* Sep */, 24), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isWeekend/index.js b/src/isWeekend/index.js index 3d94251e3a..b565506eb8 100644 --- a/src/isWeekend/index.js +++ b/src/isWeekend/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the date to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date falls on a weekend + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Does 5 October 2014 fall on a weekend? diff --git a/src/isWeekend/index.js.flow b/src/isWeekend/index.js.flow index eab32cc1d6..d6e24d762d 100644 --- a/src/isWeekend/index.js.flow +++ b/src/isWeekend/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isWeekend/test.js b/src/isWeekend/test.js index dee95831c9..9e64c1ca43 100644 --- a/src/isWeekend/test.js +++ b/src/isWeekend/test.js @@ -24,4 +24,15 @@ describe('isWeekend', function () { var result = isWeekend(new Date(2014, 9 /* Oct */, 5).getTime()) assert(result === true) }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isWeekend(new Date(NaN)) + assert(result === false) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + // $ExpectedMistake + var block = isWeekend.bind(null, new Date(2014, 9 /* Oct */, 5), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/isWithinInterval/index.js b/src/isWithinInterval/index.js index 1c812d8a35..07cf3888d6 100644 --- a/src/isWithinInterval/index.js +++ b/src/isWithinInterval/index.js @@ -11,8 +11,11 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date to check * @param {Interval} interval - the interval to check * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Boolean} the date is within the interval - * @throws {Error} The start of an interval cannot be after its end + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} The start of an interval cannot be after its end + * @throws {RangeError} Date in interval cannot be `Invalid Date` * * @example * // For the date within the interval: @@ -35,8 +38,9 @@ export default function isWithinInterval (dirtyDate, dirtyInterval, dirtyOptions var startTime = toDate(dirtyInterval.start, dirtyOptions).getTime() var endTime = toDate(dirtyInterval.end, dirtyOptions).getTime() - if (startTime > endTime) { - throw new Error('The start of an interval cannot be after its end') + // Throw an exception if start date is after end date or if any date is `Invalid Date` + if (!(startTime <= endTime)) { + throw new RangeError('Invalid interval') } return time >= startTime && time <= endTime diff --git a/src/isWithinInterval/index.js.flow b/src/isWithinInterval/index.js.flow index 01ebc4aaa6..a6c51d3983 100644 --- a/src/isWithinInterval/index.js.flow +++ b/src/isWithinInterval/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/isWithinInterval/test.js b/src/isWithinInterval/test.js index 2e0f20b533..0bce925498 100644 --- a/src/isWithinInterval/test.js +++ b/src/isWithinInterval/test.js @@ -67,6 +67,43 @@ describe('isWithinInterval', function () { new Date(2014, 9 /* Oct */, 31), {start: new Date(2014, 11 /* Dec */, 31), end: new Date(2014, 8 /* Sep */, 1)} ) - assert.throws(block) + assert.throws(block, RangeError) + }) + + it('returns false if the given date is `Invalid Date`', function () { + var result = isWithinInterval( + new Date(NaN), + {start: new Date(2014, 8 /* Sep */, 1), end: new Date(2014, 11 /* Dec */, 31)} + ) + assert(result === false) + }) + + it('throws an exception if the start date is `Invalid Date`', function () { + var block = isWithinInterval.bind( + null, + new Date(2014, 9 /* Oct */, 31), + {start: new Date(NaN), end: new Date(2014, 8 /* Sep */, 1)} + ) + assert.throws(block, RangeError) + }) + + it('throws an exception if the end date is `Invalid Date`', function () { + var block = isWithinInterval.bind( + null, + new Date(2014, 9 /* Oct */, 31), + {start: new Date(2014, 11 /* Dec */, 31), end: new Date(NaN)} + ) + assert.throws(block, RangeError) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined', function () { + var block = isWithinInterval.bind( + null, + new Date(2014, 9 /* Oct */, 31), + {start: new Date(2014, 8 /* Sep */, 1), end: new Date(2014, 11 /* Dec */, 31)}, + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) }) }) diff --git a/src/lastDayOfISOWeek/index.js b/src/lastDayOfISOWeek/index.js index 1ff5f10979..788b1348bd 100644 --- a/src/lastDayOfISOWeek/index.js +++ b/src/lastDayOfISOWeek/index.js @@ -14,7 +14,9 @@ import cloneObject from '../_lib/cloneObject/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the last day of an ISO week + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The last day of an ISO week for 2 September 2014 11:55:00: diff --git a/src/lastDayOfISOWeek/index.js.flow b/src/lastDayOfISOWeek/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/lastDayOfISOWeek/index.js.flow +++ b/src/lastDayOfISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/lastDayOfISOWeek/test.js b/src/lastDayOfISOWeek/test.js index 394dcbdd2a..a3d45c64cc 100644 --- a/src/lastDayOfISOWeek/test.js +++ b/src/lastDayOfISOWeek/test.js @@ -34,4 +34,16 @@ describe('lastDayOfISOWeek', function () { lastDayOfISOWeek(date) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = lastDayOfISOWeek(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = lastDayOfISOWeek.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/lastDayOfISOYear/index.js b/src/lastDayOfISOYear/index.js index a077a6c9cc..c7d3f88f29 100644 --- a/src/lastDayOfISOYear/index.js +++ b/src/lastDayOfISOYear/index.js @@ -15,7 +15,9 @@ import startOfISOWeek from '../startOfISOWeek/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the end of an ISO week-numbering year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The last day of an ISO week-numbering year for 2 July 2005: diff --git a/src/lastDayOfISOYear/index.js.flow b/src/lastDayOfISOYear/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/lastDayOfISOYear/index.js.flow +++ b/src/lastDayOfISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/lastDayOfISOYear/test.js b/src/lastDayOfISOYear/test.js index 6639912912..827d025006 100644 --- a/src/lastDayOfISOYear/test.js +++ b/src/lastDayOfISOYear/test.js @@ -36,4 +36,15 @@ describe('lastDayOfISOYear', function () { var result = lastDayOfISOYear(initialDate) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = lastDayOfISOYear(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = lastDayOfISOYear.bind(null, new Date(2009, 0 /* Jan */, 1, 16, 0), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/lastDayOfMonth/index.js b/src/lastDayOfMonth/index.js index 990c7a888c..8e3a624acd 100644 --- a/src/lastDayOfMonth/index.js +++ b/src/lastDayOfMonth/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the last day of a month + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The last day of a month for 2 September 2014 11:55:00: diff --git a/src/lastDayOfMonth/index.js.flow b/src/lastDayOfMonth/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/lastDayOfMonth/index.js.flow +++ b/src/lastDayOfMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/lastDayOfMonth/test.js b/src/lastDayOfMonth/test.js index 8f51888111..5f0e18286c 100644 --- a/src/lastDayOfMonth/test.js +++ b/src/lastDayOfMonth/test.js @@ -52,4 +52,16 @@ describe('lastDayOfMonth', function () { ) }) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = lastDayOfMonth(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = lastDayOfMonth.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/lastDayOfQuarter/index.js b/src/lastDayOfQuarter/index.js index 1a3e91c3c3..0be43c9c78 100644 --- a/src/lastDayOfQuarter/index.js +++ b/src/lastDayOfQuarter/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the last day of a quarter + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The last day of a quarter for 2 September 2014 11:55:00: diff --git a/src/lastDayOfQuarter/index.js.flow b/src/lastDayOfQuarter/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/lastDayOfQuarter/index.js.flow +++ b/src/lastDayOfQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/lastDayOfQuarter/test.js b/src/lastDayOfQuarter/test.js index ba5e4e7c97..bc64d95159 100644 --- a/src/lastDayOfQuarter/test.js +++ b/src/lastDayOfQuarter/test.js @@ -28,4 +28,16 @@ describe('lastDayOfQuarter', function () { lastDayOfQuarter(date) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = lastDayOfQuarter(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = lastDayOfQuarter.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/lastDayOfWeek/index.js b/src/lastDayOfWeek/index.js index 0b0366f92e..9e6c3ce2c4 100644 --- a/src/lastDayOfWeek/index.js +++ b/src/lastDayOfWeek/index.js @@ -11,8 +11,11 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} - * @param {Number} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} + * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) * @returns {Date} the last day of a week + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6 * * @example * // The last day of a week for 2 September 2014 11:55:00: @@ -25,7 +28,13 @@ import toDate from '../toDate/index.js' * //=> Sun Sep 07 2014 00:00:00 */ export default function lastDayOfWeek (dirtyDate, dirtyOptions) { - var weekStartsOn = dirtyOptions ? (Number(dirtyOptions.weekStartsOn) || 0) : 0 + var options = dirtyOptions || {} + var weekStartsOn = options.weekStartsOn === undefined ? 0 : Number(options.weekStartsOn) + + // Test if weekStartsOn is between 0 and 6 _and_ is not NaN + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError('weekStartsOn must be between 0 and 6') + } var date = toDate(dirtyDate, dirtyOptions) var day = date.getDay() diff --git a/src/lastDayOfWeek/index.js.flow b/src/lastDayOfWeek/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/lastDayOfWeek/index.js.flow +++ b/src/lastDayOfWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/lastDayOfWeek/test.js b/src/lastDayOfWeek/test.js index 60dac6136e..30161a917a 100644 --- a/src/lastDayOfWeek/test.js +++ b/src/lastDayOfWeek/test.js @@ -83,4 +83,22 @@ describe('lastDayOfWeek', function () { assert.deepEqual(result, new Date(2015, 0 /* Jan */, 1)) }) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = lastDayOfWeek(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.weekStartsOn` is not convertable to 0, 1, ..., 6 or undefined', function () { + // $ExpectedMistake + var block = lastDayOfWeek.bind(null, new Date(2014, 8 /* Sep */, 2, 11, 55, 0), {weekStartsOn: NaN}) + assert.throws(block, RangeError) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = lastDayOfWeek.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/lastDayOfYear/index.js b/src/lastDayOfYear/index.js index 7e4d20e828..23aa97f86d 100644 --- a/src/lastDayOfYear/index.js +++ b/src/lastDayOfYear/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the last day of a year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The last day of a year for 2 September 2014 11:55:00: diff --git a/src/lastDayOfYear/index.js.flow b/src/lastDayOfYear/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/lastDayOfYear/index.js.flow +++ b/src/lastDayOfYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/lastDayOfYear/test.js b/src/lastDayOfYear/test.js index 96125a434f..95e1748176 100644 --- a/src/lastDayOfYear/test.js +++ b/src/lastDayOfYear/test.js @@ -34,4 +34,16 @@ describe('lastDayOfYear', function () { lastDayOfYear(date) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = lastDayOfYear(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = lastDayOfYear.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/max/index.js b/src/max/index.js index 3fad2b4cf1..2ebb4a7508 100644 --- a/src/max/index.js +++ b/src/max/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date[]|String[]|Number[]} datesArray - the dates to compare * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the latest of the dates + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which of these dates is the latest? diff --git a/src/max/index.js.flow b/src/max/index.js.flow index f2e7a16f9b..1dc5e37ca6 100644 --- a/src/max/index.js.flow +++ b/src/max/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/max/test.js b/src/max/test.js index 009d8bd156..261a25dcd7 100644 --- a/src/max/test.js +++ b/src/max/test.js @@ -46,4 +46,36 @@ describe('max', function () { ) assert.deepEqual(result, new Date(1989, 6 /* Jul */, 10)) }) + + it('returns `Invalid Date` if any given date is invalid', function () { + var result = max([ + new Date(1989, 6 /* Jul */, 10), + new Date(NaN), + new Date(1987, 1 /* Feb */, 11) + ]) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if any given value is undefined', function () { + var result = max([ + new Date(1989, 6 /* Jul */, 10), + // $ExpectedMistake + undefined, + new Date(1987, 1 /* Feb */, 11) + ]) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var block = max.bind( + null, + [ + new Date(1989, 6 /* Jul */, 10), + new Date(1987, 1 /* Feb */, 11) + ], + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/min/index.js b/src/min/index.js index bafecb62c2..941f444697 100644 --- a/src/min/index.js +++ b/src/min/index.js @@ -10,7 +10,9 @@ import toDate from '../toDate/index.js' * * @param {Date[]|String[]|Number[]} datesArray - the dates to compare * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the earliest of the dates + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Which of these dates is the earliest? diff --git a/src/min/index.js.flow b/src/min/index.js.flow index f2e7a16f9b..1dc5e37ca6 100644 --- a/src/min/index.js.flow +++ b/src/min/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/min/test.js b/src/min/test.js index 3f3e0434e8..5eda1cc1ca 100644 --- a/src/min/test.js +++ b/src/min/test.js @@ -46,4 +46,36 @@ describe('min', function () { ) assert.deepEqual(result, new Date(1987, 1 /* Feb */, 11)) }) + + it('returns `Invalid Date` if any given date is invalid', function () { + var result = min([ + new Date(1989, 6 /* Jul */, 10), + new Date(NaN), + new Date(1987, 1 /* Feb */, 11) + ]) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if any given value is undefined', function () { + var result = min([ + new Date(1989, 6 /* Jul */, 10), + // $ExpectedMistake + undefined, + new Date(1987, 1 /* Feb */, 11) + ]) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var block = min.bind( + null, + [ + new Date(1989, 6 /* Jul */, 10), + new Date(1987, 1 /* Feb */, 11) + ], + // $ExpectedMistake + {additionalDigits: NaN} + ) + assert.throws(block, RangeError) + }) }) diff --git a/src/parse/index.js b/src/parse/index.js index a74ee5a7a0..2961b63d6d 100644 --- a/src/parse/index.js +++ b/src/parse/index.js @@ -73,6 +73,8 @@ var MILLISECONDS_IN_MINUTE = 60000 * If you're not sure which `baseDate` to supply, create a new instance of Date: * `parse('02/11/2014', 'MM/DD/YYYY', new Date())` * In this case parsing will be done in the context of the current date. + * If `baseDate` is `Invalid Date` or a value not convertible to valid `Date`, + * then `Invalid Date` will be returned. * * The characters wrapped in square brackets in the format string are escaped. * @@ -88,9 +90,12 @@ var MILLISECONDS_IN_MINUTE = 60000 * @param {String} formatString - the string of tokens * @param {Date|String|Number} baseDate - the date to took the missing higher priority values from * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @param {Locale} [options.locale=enLocale] - the locale object. See [Locale]{@link docs/Locale} - * @param {Number} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) + * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) * @returns {Date} the parsed date + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6 * * @example * // Parse 11 February 2014 from middle-endian format: @@ -117,6 +122,13 @@ export default function parse (dirtyDateString, dirtyFormatString, dirtyBaseDate var formatString = String(dirtyFormatString) var options = dirtyOptions || {} + var weekStartsOn = options.weekStartsOn === undefined ? 0 : Number(options.weekStartsOn) + + // Test if weekStartsOn is between 0 and 6 _and_ is not NaN + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError('weekStartsOn must be between 0 and 6 inclusively') + } + if (formatString === '') { if (dateString === '') { return toDate(dirtyBaseDate, options) @@ -209,6 +221,10 @@ export default function parse (dirtyDateString, dirtyFormatString, dirtyBaseDate var date = toDate(dirtyBaseDate, options) + if (isNaN(date)) { + return new Date(NaN) + } + // Convert the date in system timezone to the same date in UTC+00:00 timezone. // This ensures that when UTC functions will be implemented, locales will be compatible with them. // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/37 diff --git a/src/parse/index.js.flow b/src/parse/index.js.flow index 5041e34e10..59aaf22e7b 100644 --- a/src/parse/index.js.flow +++ b/src/parse/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/parse/test.js b/src/parse/test.js index 405fb8f9fb..9e6c48ea97 100644 --- a/src/parse/test.js +++ b/src/parse/test.js @@ -788,5 +788,26 @@ describe('parse', function () { var result = parse(dateString, formatString, baseDate) assert(result instanceof Date && isNaN(result)) }) + + it('returns `Invalid Date` if `baseDate` is `Invalid Date`', function () { + var dateString = '2014-07-02T05:30:15.123+06:00' + var formatString = 'YYYY-MM-DDTHH:mm:ss.SSSZ' + var result = parse(dateString, formatString, new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.weekStartsOn` is not convertable to 0, 1, ..., 6 or undefined', function () { + var dateString = '2014-07-02T05:30:15.123+06:00' + var formatString = 'YYYY-MM-DDTHH:mm:ss.SSSZ' + // $ExpectedMistake + var block = parse.bind(null, dateString, formatString, baseDate, {weekStartsOn: NaN}) + assert.throws(block, RangeError) + }) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = parse.bind(null, '16', 'YY', baseDate, {additionalDigits: NaN}) + assert.throws(block, RangeError) }) }) diff --git a/src/setDate/index.js b/src/setDate/index.js index 83fe615ece..3ee40994f0 100644 --- a/src/setDate/index.js +++ b/src/setDate/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} dayOfMonth - the day of the month of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the day of the month setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set the 30th day of the month to 1 September 2014: diff --git a/src/setDate/index.js.flow b/src/setDate/index.js.flow index 745f7ca977..8699ee24c2 100644 --- a/src/setDate/index.js.flow +++ b/src/setDate/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setDate/test.js b/src/setDate/test.js index 7c9ec7a6f0..73b3b2fcd4 100644 --- a/src/setDate/test.js +++ b/src/setDate/test.js @@ -31,4 +31,20 @@ describe('setDate', function () { setDate(date, 20) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setDate(new Date(NaN), 30) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setDate(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setDate.bind(null, new Date(2014, 8 /* Sep */, 1), 30, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setDay/index.js b/src/setDay/index.js index 0964a62290..4225335165 100644 --- a/src/setDay/index.js +++ b/src/setDay/index.js @@ -12,8 +12,11 @@ import addDays from '../addDays/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} day - the day of the week of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} - * @param {Number} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} + * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) * @returns {Date} the new date with the day of the week setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6 * * @example * // Set Sunday to 1 September 2014: @@ -26,8 +29,15 @@ import addDays from '../addDays/index.js' * //=> Sun Sep 07 2014 00:00:00 */ export default function setDay (dirtyDate, dirtyDay, dirtyOptions) { - var weekStartsOn = dirtyOptions ? (Number(dirtyOptions.weekStartsOn) || 0) : 0 - var date = toDate(dirtyDate, dirtyOptions) + var options = dirtyOptions || {} + var weekStartsOn = options.weekStartsOn === undefined ? 0 : Number(options.weekStartsOn) + + // Test if weekStartsOn is between 0 and 6 _and_ is not NaN + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError('weekStartsOn must be between 0 and 6 inclusively') + } + + var date = toDate(dirtyDate, options) var day = Number(dirtyDay) var currentDay = date.getDay() @@ -35,5 +45,5 @@ export default function setDay (dirtyDate, dirtyDay, dirtyOptions) { var dayIndex = (remainder + 7) % 7 var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay - return addDays(date, diff, dirtyOptions) + return addDays(date, diff, options) } diff --git a/src/setDay/index.js.flow b/src/setDay/index.js.flow index be57d71097..f9f0467e26 100644 --- a/src/setDay/index.js.flow +++ b/src/setDay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setDay/test.js b/src/setDay/test.js index 2d758b1809..541100c13f 100644 --- a/src/setDay/test.js +++ b/src/setDay/test.js @@ -76,4 +76,26 @@ describe('setDay', function () { setDay(date, 3) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setDay(new Date(NaN), 0) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setDay(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.weekStartsOn` is not convertable to 0, 1, ..., 6 or undefined', function () { + // $ExpectedMistake + var block = setDay.bind(null, new Date(2014, 8 /* Sep */, 1), 0, {weekStartsOn: NaN}) + assert.throws(block, RangeError) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setDay.bind(null, new Date(2014, 8 /* Sep */, 1), 0, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setDayOfYear/index.js b/src/setDayOfYear/index.js index 1ea4fb6bb7..e724c3aae1 100644 --- a/src/setDayOfYear/index.js +++ b/src/setDayOfYear/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} dayOfYear - the day of the year of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the day of the year setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set the 2nd day of the year to 2 July 2014: diff --git a/src/setDayOfYear/index.js.flow b/src/setDayOfYear/index.js.flow index 43c05251dd..539742ebde 100644 --- a/src/setDayOfYear/index.js.flow +++ b/src/setDayOfYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setDayOfYear/test.js b/src/setDayOfYear/test.js index 3a323c0e99..05a5608fa9 100644 --- a/src/setDayOfYear/test.js +++ b/src/setDayOfYear/test.js @@ -31,4 +31,20 @@ describe('setDayOfYear', function () { setDayOfYear(date, 365) assert.deepEqual(date, new Date(2014, 6 /* Jul */, 2)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setDayOfYear(new Date(NaN), 2) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setDayOfYear(new Date(2014, 6 /* Jul */, 2), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setDayOfYear.bind(null, new Date(2014, 6 /* Jul */, 2), 2, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setHours/index.js b/src/setHours/index.js index 7c8eba4117..f8888de187 100644 --- a/src/setHours/index.js +++ b/src/setHours/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} hours - the hours of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the hours setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set 4 hours to 1 September 2014 11:30:00: diff --git a/src/setHours/index.js.flow b/src/setHours/index.js.flow index 38664fb53e..f04af8a0d5 100644 --- a/src/setHours/index.js.flow +++ b/src/setHours/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setHours/test.js b/src/setHours/test.js index 13bf763471..53a36aad6d 100644 --- a/src/setHours/test.js +++ b/src/setHours/test.js @@ -31,4 +31,20 @@ describe('setHours', function () { setHours(date, 12) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1, 11)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setHours(new Date(NaN), 4) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setHours(new Date(2014, 8 /* Sep */, 1, 11, 30), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setHours.bind(null, new Date(2014, 8 /* Sep */, 1, 11, 30), 4, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setISODay/index.js b/src/setISODay/index.js index c58fd10bff..06977388a7 100644 --- a/src/setISODay/index.js +++ b/src/setISODay/index.js @@ -15,7 +15,9 @@ import getISODay from '../getISODay/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} day - the day of the ISO week of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the day of the ISO week setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set Sunday to 1 September 2014: diff --git a/src/setISODay/index.js.flow b/src/setISODay/index.js.flow index be57d71097..f9f0467e26 100644 --- a/src/setISODay/index.js.flow +++ b/src/setISODay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setISODay/test.js b/src/setISODay/test.js index 5b03300c2d..6c6002a1b9 100644 --- a/src/setISODay/test.js +++ b/src/setISODay/test.js @@ -60,4 +60,20 @@ describe('setISODay', function () { setISODay(date, 3) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setISODay(new Date(NaN), 3) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setISODay(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setISODay.bind(null, new Date(2014, 8 /* Sep */, 1), 3, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setISOWeek/index.js b/src/setISOWeek/index.js index 0af6df7944..45a3336be5 100644 --- a/src/setISOWeek/index.js +++ b/src/setISOWeek/index.js @@ -14,7 +14,9 @@ import getISOWeek from '../getISOWeek/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} isoWeek - the ISO week of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the ISO week setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set the 53rd ISO week to 7 August 2004: diff --git a/src/setISOWeek/index.js.flow b/src/setISOWeek/index.js.flow index 41baa1366c..1948075624 100644 --- a/src/setISOWeek/index.js.flow +++ b/src/setISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setISOWeek/test.js b/src/setISOWeek/test.js index 90f9d358de..dd4389734a 100644 --- a/src/setISOWeek/test.js +++ b/src/setISOWeek/test.js @@ -42,4 +42,20 @@ describe('setISOWeek', function () { var result = setISOWeek(initialDate, 52) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setISOWeek(new Date(NaN), 53) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setISOWeek(new Date(2004, 7 /* Aug */, 7), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setISOWeek.bind(null, new Date(2004, 7 /* Aug */, 7), 53, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setISOYear/index.js b/src/setISOYear/index.js index 05c9d7a6de..073fa425f4 100644 --- a/src/setISOYear/index.js +++ b/src/setISOYear/index.js @@ -16,7 +16,9 @@ import differenceInCalendarDays from '../differenceInCalendarDays/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} isoYear - the ISO week-numbering year of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the ISO week-numbering year setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set ISO week-numbering year 2007 to 29 December 2008: diff --git a/src/setISOYear/index.js.flow b/src/setISOYear/index.js.flow index 6303b3dfbe..d6120d64d3 100644 --- a/src/setISOYear/index.js.flow +++ b/src/setISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setISOYear/test.js b/src/setISOYear/test.js index 8196557205..b0f3ae4d3f 100644 --- a/src/setISOYear/test.js +++ b/src/setISOYear/test.js @@ -51,4 +51,20 @@ describe('setISOYear', function () { var result = setISOYear(initialDate, 7) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setISOYear(new Date(NaN), 2007) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setISOYear(new Date(2008, 11 /* Dec */, 29), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setISOYear.bind(null, new Date(2008, 11 /* Dec */, 29), 2007, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setMilliseconds/index.js b/src/setMilliseconds/index.js index 31e2bf36f5..b7394226f6 100644 --- a/src/setMilliseconds/index.js +++ b/src/setMilliseconds/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} milliseconds - the milliseconds of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the milliseconds setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set 300 milliseconds to 1 September 2014 11:30:40.500: diff --git a/src/setMilliseconds/index.js.flow b/src/setMilliseconds/index.js.flow index 40cca62feb..83393177dc 100644 --- a/src/setMilliseconds/index.js.flow +++ b/src/setMilliseconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setMilliseconds/test.js b/src/setMilliseconds/test.js index b6016516e6..40365a9ed1 100644 --- a/src/setMilliseconds/test.js +++ b/src/setMilliseconds/test.js @@ -31,4 +31,20 @@ describe('setMilliseconds', function () { setMilliseconds(date, 137) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1, 11, 30, 40, 500)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setMilliseconds(new Date(NaN), 300) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setMilliseconds(new Date(2014, 8 /* Sep */, 1, 11, 30, 40, 500), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setMilliseconds.bind(null, new Date(2014, 8 /* Sep */, 1, 11, 30, 40, 500), 300, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setMinutes/index.js b/src/setMinutes/index.js index abb6a76b8b..1be5fe8f2e 100644 --- a/src/setMinutes/index.js +++ b/src/setMinutes/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} minutes - the minutes of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the minutes setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set 45 minutes to 1 September 2014 11:30:40: diff --git a/src/setMinutes/index.js.flow b/src/setMinutes/index.js.flow index 59eddc3d31..4acfb9f5ba 100644 --- a/src/setMinutes/index.js.flow +++ b/src/setMinutes/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setMinutes/test.js b/src/setMinutes/test.js index 982923abc7..ade0d5b073 100644 --- a/src/setMinutes/test.js +++ b/src/setMinutes/test.js @@ -31,4 +31,20 @@ describe('setMinutes', function () { setMinutes(date, 15) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1, 11, 30)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setMinutes(new Date(NaN), 45) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setMinutes(new Date(2014, 8 /* Sep */, 1, 11, 30, 40), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setMinutes.bind(null, new Date(2014, 8 /* Sep */, 1, 11, 30, 40), 45, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setMonth/index.js b/src/setMonth/index.js index e01da373fe..67c788e6ff 100644 --- a/src/setMonth/index.js +++ b/src/setMonth/index.js @@ -12,7 +12,9 @@ import getDaysInMonth from '../getDaysInMonth/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} month - the month of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the month setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set February to 1 September 2014: diff --git a/src/setMonth/index.js.flow b/src/setMonth/index.js.flow index 592c337833..68cc1ab6f1 100644 --- a/src/setMonth/index.js.flow +++ b/src/setMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setMonth/test.js b/src/setMonth/test.js index 15ff62ecb1..1f717e0b52 100644 --- a/src/setMonth/test.js +++ b/src/setMonth/test.js @@ -47,4 +47,20 @@ describe('setMonth', function () { var result = setMonth(initialDate, 1) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setMonth(new Date(NaN), 1) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setMonth(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setMonth.bind(null, new Date(2014, 8 /* Sep */, 1), 1, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setQuarter/index.js b/src/setQuarter/index.js index e33cc02e3b..79918ca0f0 100644 --- a/src/setQuarter/index.js +++ b/src/setQuarter/index.js @@ -12,7 +12,9 @@ import setMonth from '../setMonth/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} quarter - the quarter of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the quarter setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set the 2nd quarter to 2 July 2014: diff --git a/src/setQuarter/index.js.flow b/src/setQuarter/index.js.flow index 64d4b1b403..efea6ec5fe 100644 --- a/src/setQuarter/index.js.flow +++ b/src/setQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setQuarter/test.js b/src/setQuarter/test.js index 76f5a0962c..5398a911f5 100644 --- a/src/setQuarter/test.js +++ b/src/setQuarter/test.js @@ -47,4 +47,20 @@ describe('setQuarter', function () { var result = setQuarter(initialDate, 1) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setQuarter(new Date(NaN), 1) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setQuarter(new Date(2014, 6 /* Jul */, 2), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setQuarter.bind(null, new Date(2014, 6 /* Jul */, 2), 1, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setSeconds/index.js b/src/setSeconds/index.js index c2b3d4462c..7903f045eb 100644 --- a/src/setSeconds/index.js +++ b/src/setSeconds/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} seconds - the seconds of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the seconds setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set 45 seconds to 1 September 2014 11:30:40: diff --git a/src/setSeconds/index.js.flow b/src/setSeconds/index.js.flow index 0e70074a83..4496c61c29 100644 --- a/src/setSeconds/index.js.flow +++ b/src/setSeconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setSeconds/test.js b/src/setSeconds/test.js index b3465d349d..00ae471bff 100644 --- a/src/setSeconds/test.js +++ b/src/setSeconds/test.js @@ -31,4 +31,20 @@ describe('setSeconds', function () { setSeconds(date, 15) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1, 11, 30, 40)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setSeconds(new Date(NaN), 45) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setSeconds(new Date(2014, 8 /* Sep */, 1, 11, 30, 40, 500), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setSeconds.bind(null, new Date(2014, 8 /* Sep */, 1, 11, 30, 40, 500), 45, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/setYear/index.js b/src/setYear/index.js index 1f76a4f9c4..143c582a9c 100644 --- a/src/setYear/index.js +++ b/src/setYear/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} year - the year of the new date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the year setted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Set year 2013 to 1 September 2014: @@ -21,6 +23,12 @@ import toDate from '../toDate/index.js' export default function setYear (dirtyDate, dirtyYear, dirtyOptions) { var date = toDate(dirtyDate, dirtyOptions) var year = Number(dirtyYear) + + // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date + if (isNaN(date)) { + return new Date(NaN) + } + date.setFullYear(year) return date } diff --git a/src/setYear/index.js.flow b/src/setYear/index.js.flow index 50135eea90..d49db433f0 100644 --- a/src/setYear/index.js.flow +++ b/src/setYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/setYear/test.js b/src/setYear/test.js index 7c6c57ee9c..30ed7ec259 100644 --- a/src/setYear/test.js +++ b/src/setYear/test.js @@ -31,4 +31,20 @@ describe('setYear', function () { setYear(date, 2011) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = setYear(new Date(NaN), 2013) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = setYear(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = setYear.bind(null, new Date(2014, 8 /* Sep */, 1), 2013, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/startOfDay/index.js b/src/startOfDay/index.js index d1688306d5..9b4bfcd9ee 100644 --- a/src/startOfDay/index.js +++ b/src/startOfDay/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the start of a day + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The start of a day for 2 September 2014 11:55:00: diff --git a/src/startOfDay/index.js.flow b/src/startOfDay/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/startOfDay/index.js.flow +++ b/src/startOfDay/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/startOfDay/test.js b/src/startOfDay/test.js index 47ba9fd21b..676b923d88 100644 --- a/src/startOfDay/test.js +++ b/src/startOfDay/test.js @@ -34,4 +34,16 @@ describe('startOfDay', function () { startOfDay(date) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = startOfDay(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = startOfDay.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/startOfHour/index.js b/src/startOfHour/index.js index cc437ad086..c323fd9732 100644 --- a/src/startOfHour/index.js +++ b/src/startOfHour/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the start of an hour + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The start of an hour for 2 September 2014 11:55:00: diff --git a/src/startOfHour/index.js.flow b/src/startOfHour/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/startOfHour/index.js.flow +++ b/src/startOfHour/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/startOfHour/test.js b/src/startOfHour/test.js index f04c38c003..379107d1fc 100644 --- a/src/startOfHour/test.js +++ b/src/startOfHour/test.js @@ -28,4 +28,16 @@ describe('startOfHour', function () { var result = startOfHour(date) assert.deepEqual(result, new Date(2014, 11, 1, 12, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = startOfHour(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55) + // $ExpectedMistake + var block = startOfHour.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/startOfISOWeek/index.js b/src/startOfISOWeek/index.js index e1a840c220..bc41843473 100644 --- a/src/startOfISOWeek/index.js +++ b/src/startOfISOWeek/index.js @@ -14,7 +14,9 @@ import cloneObject from '../_lib/cloneObject/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the start of an ISO week + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The start of an ISO week for 2 September 2014 11:55:00: diff --git a/src/startOfISOWeek/index.js.flow b/src/startOfISOWeek/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/startOfISOWeek/index.js.flow +++ b/src/startOfISOWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/startOfISOWeek/test.js b/src/startOfISOWeek/test.js index 26381fbdab..fec6a3cb86 100644 --- a/src/startOfISOWeek/test.js +++ b/src/startOfISOWeek/test.js @@ -28,4 +28,16 @@ describe('startOfISOWeek', function () { startOfISOWeek(date) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = startOfISOWeek(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = startOfISOWeek.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/startOfISOYear/index.js b/src/startOfISOYear/index.js index 7936f34e8f..7bd7f576a4 100644 --- a/src/startOfISOYear/index.js +++ b/src/startOfISOYear/index.js @@ -15,7 +15,9 @@ import startOfISOWeek from '../startOfISOWeek/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the start of an ISO year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The start of an ISO week-numbering year for 2 July 2005: diff --git a/src/startOfISOYear/index.js.flow b/src/startOfISOYear/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/startOfISOYear/index.js.flow +++ b/src/startOfISOYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/startOfISOYear/test.js b/src/startOfISOYear/test.js index 71a3813519..50cf24faa9 100644 --- a/src/startOfISOYear/test.js +++ b/src/startOfISOYear/test.js @@ -41,4 +41,15 @@ describe('startOfISOYear', function () { var result = startOfISOYear(new Date(2009, 6 /* Jul */, 2)) assert.deepEqual(result, new Date(2008, 11 /* Dec */, 29)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = startOfISOYear(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = startOfISOYear.bind(null, new Date(2009, 0 /* Jan */, 1, 16, 0), {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/startOfMinute/index.js b/src/startOfMinute/index.js index 15f90eed69..b83d4b29cc 100644 --- a/src/startOfMinute/index.js +++ b/src/startOfMinute/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the start of a minute + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The start of a minute for 1 December 2014 22:15:45.400: diff --git a/src/startOfMinute/index.js.flow b/src/startOfMinute/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/startOfMinute/index.js.flow +++ b/src/startOfMinute/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/startOfMinute/test.js b/src/startOfMinute/test.js index fc6d8dc4ee..672aa94fe6 100644 --- a/src/startOfMinute/test.js +++ b/src/startOfMinute/test.js @@ -28,4 +28,16 @@ describe('startOfMinute', function () { startOfMinute(date) assert.deepEqual(date, new Date(2014, 11 /* Dec */, 1, 22, 15, 45, 400)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = startOfMinute(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 11 /* Dec */, 1, 22, 15, 45, 400) + // $ExpectedMistake + var block = startOfMinute.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/startOfMonth/index.js b/src/startOfMonth/index.js index c8a4a23c70..de2b941f70 100644 --- a/src/startOfMonth/index.js +++ b/src/startOfMonth/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the start of a month + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The start of a month for 2 September 2014 11:55:00: diff --git a/src/startOfMonth/index.js.flow b/src/startOfMonth/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/startOfMonth/index.js.flow +++ b/src/startOfMonth/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/startOfMonth/test.js b/src/startOfMonth/test.js index 4506776a43..363ee2ed5e 100644 --- a/src/startOfMonth/test.js +++ b/src/startOfMonth/test.js @@ -28,4 +28,16 @@ describe('startOfMonth', function () { startOfMonth(date) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = startOfMonth(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = startOfMonth.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/startOfQuarter/index.js b/src/startOfQuarter/index.js index 4644de4040..4b95af5af2 100644 --- a/src/startOfQuarter/index.js +++ b/src/startOfQuarter/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the start of a quarter + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The start of a quarter for 2 September 2014 11:55:00: diff --git a/src/startOfQuarter/index.js.flow b/src/startOfQuarter/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/startOfQuarter/index.js.flow +++ b/src/startOfQuarter/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/startOfQuarter/test.js b/src/startOfQuarter/test.js index 70106e2b2e..362f28f10d 100644 --- a/src/startOfQuarter/test.js +++ b/src/startOfQuarter/test.js @@ -28,4 +28,16 @@ describe('startOfQuarter', function () { startOfQuarter(date) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = startOfQuarter(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = startOfQuarter.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/startOfSecond/index.js b/src/startOfSecond/index.js index 0d31c35d42..8f390fc2ed 100644 --- a/src/startOfSecond/index.js +++ b/src/startOfSecond/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the start of a second + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The start of a second for 1 December 2014 22:15:45.400: diff --git a/src/startOfSecond/index.js.flow b/src/startOfSecond/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/startOfSecond/index.js.flow +++ b/src/startOfSecond/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/startOfSecond/test.js b/src/startOfSecond/test.js index e5a1a3b8ff..a719d57eb5 100644 --- a/src/startOfSecond/test.js +++ b/src/startOfSecond/test.js @@ -28,4 +28,16 @@ describe('startOfSecond', function () { startOfSecond(date) assert.deepEqual(date, new Date(2014, 11 /* Dec */, 1, 22, 15, 45, 400)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = startOfSecond(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 11 /* Dec */, 1, 22, 15, 45, 400) + // $ExpectedMistake + var block = startOfSecond.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/startOfWeek/index.js b/src/startOfWeek/index.js index 0f2ffa3e8f..4a40b94516 100644 --- a/src/startOfWeek/index.js +++ b/src/startOfWeek/index.js @@ -11,8 +11,11 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} - * @param {Number} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} + * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) * @returns {Date} the start of a week + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 + * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6 * * @example * // The start of a week for 2 September 2014 11:55:00: @@ -25,9 +28,15 @@ import toDate from '../toDate/index.js' * //=> Mon Sep 01 2014 00:00:00 */ export default function startOfWeek (dirtyDate, dirtyOptions) { - var weekStartsOn = dirtyOptions ? (Number(dirtyOptions.weekStartsOn) || 0) : 0 + var options = dirtyOptions || {} + var weekStartsOn = options.weekStartsOn === undefined ? 0 : Number(options.weekStartsOn) - var date = toDate(dirtyDate, dirtyOptions) + // Test if weekStartsOn is between 0 and 6 _and_ is not NaN + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError('weekStartsOn must be between 0 and 6 inclusively') + } + + var date = toDate(dirtyDate, options) var day = date.getDay() var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn diff --git a/src/startOfWeek/index.js.flow b/src/startOfWeek/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/startOfWeek/index.js.flow +++ b/src/startOfWeek/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/startOfWeek/test.js b/src/startOfWeek/test.js index f62e7af192..8e846c2365 100644 --- a/src/startOfWeek/test.js +++ b/src/startOfWeek/test.js @@ -73,4 +73,22 @@ describe('startOfWeek', function () { assert.deepEqual(result, new Date(2013, 11 /* Dec */, 29)) }) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = startOfWeek(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.weekStartsOn` is not convertable to 0, 1, ..., 6 or undefined', function () { + // $ExpectedMistake + var block = startOfWeek.bind(null, new Date(2014, 8 /* Sep */, 2, 11, 55, 0), {weekStartsOn: NaN}) + assert.throws(block, RangeError) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = startOfWeek.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/startOfYear/index.js b/src/startOfYear/index.js index 06ce77a2a1..abc3ef9fbe 100644 --- a/src/startOfYear/index.js +++ b/src/startOfYear/index.js @@ -11,7 +11,9 @@ import toDate from '../toDate/index.js' * * @param {Date|String|Number} date - the original date * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the start of a year + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // The start of a year for 2 September 2014 11:55:00: diff --git a/src/startOfYear/index.js.flow b/src/startOfYear/index.js.flow index 77c379f747..9fac5fcb80 100644 --- a/src/startOfYear/index.js.flow +++ b/src/startOfYear/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/startOfYear/test.js b/src/startOfYear/test.js index 9e2e16838d..28e3bd331c 100644 --- a/src/startOfYear/test.js +++ b/src/startOfYear/test.js @@ -39,4 +39,16 @@ describe('startOfYear', function () { var result = startOfYear(initialDate) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = startOfYear(new Date(NaN)) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + var date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + // $ExpectedMistake + var block = startOfYear.bind(null, date, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/subDays/index.js b/src/subDays/index.js index 5f1e7fc64e..d8706dc0d5 100644 --- a/src/subDays/index.js +++ b/src/subDays/index.js @@ -11,7 +11,9 @@ import addDays from '../addDays/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of days to be subtracted * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the days subtracted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Subtract 10 days from 1 September 2014: diff --git a/src/subDays/index.js.flow b/src/subDays/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/subDays/index.js.flow +++ b/src/subDays/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/subDays/test.js b/src/subDays/test.js index cc817213b0..29c3caf244 100644 --- a/src/subDays/test.js +++ b/src/subDays/test.js @@ -31,4 +31,20 @@ describe('subDays', function () { subDays(date, 11) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = subDays(new Date(NaN), 10) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = subDays(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = subDays.bind(null, new Date(2014, 8 /* Sep */, 1), 10, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/subHours/index.js b/src/subHours/index.js index 50b1692353..269420785f 100644 --- a/src/subHours/index.js +++ b/src/subHours/index.js @@ -11,7 +11,9 @@ import addHours from '../addHours/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of hours to be subtracted * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the hours subtracted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Subtract 2 hours from 11 July 2014 01:00:00: diff --git a/src/subHours/index.js.flow b/src/subHours/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/subHours/index.js.flow +++ b/src/subHours/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/subHours/test.js b/src/subHours/test.js index a2509150b8..1d5dd987a1 100644 --- a/src/subHours/test.js +++ b/src/subHours/test.js @@ -35,4 +35,20 @@ describe('subHours', function () { subHours(date, 10) assert.deepEqual(date, new Date(2014, 6 /* Jul */, 10, 23, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = subHours(new Date(NaN), 2) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = subHours(new Date(2014, 6 /* Jul */, 11, 1, 0), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = subHours.bind(null, new Date(2014, 6 /* Jul */, 11, 1, 0), 2, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/subISOYears/index.js b/src/subISOYears/index.js index 73ce373d2b..d1cd513fdc 100644 --- a/src/subISOYears/index.js +++ b/src/subISOYears/index.js @@ -13,7 +13,9 @@ import addISOYears from '../addISOYears/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of ISO week-numbering years to be subtracted * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the ISO week-numbering years subtracted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Subtract 5 ISO week-numbering years from 1 September 2014: diff --git a/src/subISOYears/index.js.flow b/src/subISOYears/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/subISOYears/index.js.flow +++ b/src/subISOYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/subISOYears/test.js b/src/subISOYears/test.js index 57de6f19d8..91802a3c28 100644 --- a/src/subISOYears/test.js +++ b/src/subISOYears/test.js @@ -42,4 +42,20 @@ describe('subISOYears', function () { var result = subISOYears(initialDate, 5) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = subISOYears(new Date(NaN), 5) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = subISOYears(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = subISOYears.bind(null, new Date(2014, 8 /* Sep */, 1), 5, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/subMilliseconds/index.js b/src/subMilliseconds/index.js index 5756a23869..107fce71d1 100644 --- a/src/subMilliseconds/index.js +++ b/src/subMilliseconds/index.js @@ -11,7 +11,9 @@ import addMilliseconds from '../addMilliseconds/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of milliseconds to be subtracted * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the milliseconds subtracted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000: diff --git a/src/subMilliseconds/index.js.flow b/src/subMilliseconds/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/subMilliseconds/index.js.flow +++ b/src/subMilliseconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/subMilliseconds/test.js b/src/subMilliseconds/test.js index a2ea5730bf..d918adeb98 100644 --- a/src/subMilliseconds/test.js +++ b/src/subMilliseconds/test.js @@ -35,4 +35,20 @@ describe('subMilliseconds', function () { subMilliseconds(date, 250) assert.deepEqual(date, new Date(2014, 6 /* Jul */, 10, 12, 45, 30, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = subMilliseconds(new Date(NaN), 750) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = subMilliseconds(new Date(2014, 6 /* Jul */, 10, 12, 45, 30, 0), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = subMilliseconds.bind(null, new Date(2014, 6 /* Jul */, 10, 12, 45, 30, 0), 750, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/subMinutes/index.js b/src/subMinutes/index.js index 9f977129c6..d8a0631384 100644 --- a/src/subMinutes/index.js +++ b/src/subMinutes/index.js @@ -11,7 +11,9 @@ import addMinutes from '../addMinutes/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of minutes to be subtracted * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the mintues subtracted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Subtract 30 minutes from 10 July 2014 12:00:00: diff --git a/src/subMinutes/index.js.flow b/src/subMinutes/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/subMinutes/index.js.flow +++ b/src/subMinutes/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/subMinutes/test.js b/src/subMinutes/test.js index 120a8e319a..ad88abfd97 100644 --- a/src/subMinutes/test.js +++ b/src/subMinutes/test.js @@ -35,4 +35,20 @@ describe('subMinutes', function () { subMinutes(date, 25) assert.deepEqual(date, new Date(2014, 6 /* Jul */, 10, 12, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = subMinutes(new Date(NaN), 30) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = subMinutes(new Date(2014, 6 /* Jul */, 10, 12, 0), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = subMinutes.bind(null, new Date(2014, 6 /* Jul */, 10, 12, 0), 30, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/subMonths/index.js b/src/subMonths/index.js index b6686915f4..7e6a244714 100644 --- a/src/subMonths/index.js +++ b/src/subMonths/index.js @@ -11,7 +11,9 @@ import addMonths from '../addMonths/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of months to be subtracted * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the months subtracted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Subtract 5 months from 1 February 2015: diff --git a/src/subMonths/index.js.flow b/src/subMonths/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/subMonths/index.js.flow +++ b/src/subMonths/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/subMonths/test.js b/src/subMonths/test.js index 0a5b853808..8f65bde4f7 100644 --- a/src/subMonths/test.js +++ b/src/subMonths/test.js @@ -48,4 +48,20 @@ describe('subMonths', function () { var result = subMonths(initialDate, 1) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = subMonths(new Date(NaN), 5) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = subMonths(new Date(2015, 1 /* Feb */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = subMonths.bind(null, new Date(2015, 1 /* Feb */, 1), 5, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/subQuarters/index.js b/src/subQuarters/index.js index 15f445f7f5..d946395f25 100644 --- a/src/subQuarters/index.js +++ b/src/subQuarters/index.js @@ -11,7 +11,9 @@ import addQuarters from '../addQuarters/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of quarters to be subtracted * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the quarters subtracted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Subtract 3 quarters from 1 September 2014: diff --git a/src/subQuarters/index.js.flow b/src/subQuarters/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/subQuarters/index.js.flow +++ b/src/subQuarters/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/subQuarters/test.js b/src/subQuarters/test.js index d30d4a7224..d4265a29dc 100644 --- a/src/subQuarters/test.js +++ b/src/subQuarters/test.js @@ -48,4 +48,20 @@ describe('subQuarters', function () { var result = subQuarters(initialDate, 3) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = subQuarters(new Date(NaN), 3) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = subQuarters(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = subQuarters.bind(null, new Date(2014, 8 /* Sep */, 1), 3, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/subSeconds/index.js b/src/subSeconds/index.js index 41846e1932..f3199e662b 100644 --- a/src/subSeconds/index.js +++ b/src/subSeconds/index.js @@ -11,7 +11,9 @@ import addSeconds from '../addSeconds/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of seconds to be subtracted * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the seconds subtracted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Subtract 30 seconds from 10 July 2014 12:45:00: diff --git a/src/subSeconds/index.js.flow b/src/subSeconds/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/subSeconds/index.js.flow +++ b/src/subSeconds/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/subSeconds/test.js b/src/subSeconds/test.js index 11cc05f18b..2061b1d757 100644 --- a/src/subSeconds/test.js +++ b/src/subSeconds/test.js @@ -35,4 +35,20 @@ describe('subSeconds', function () { subSeconds(date, 15) assert.deepEqual(date, new Date(2014, 6 /* Jul */, 10, 12, 45, 0)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = subSeconds(new Date(NaN), 30) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = subSeconds(new Date(2014, 6 /* Jul */, 10, 12, 45, 0), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = subSeconds.bind(null, new Date(2014, 6 /* Jul */, 10, 12, 45, 0), 30, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/subWeeks/index.js b/src/subWeeks/index.js index da2579e677..ecd48436df 100644 --- a/src/subWeeks/index.js +++ b/src/subWeeks/index.js @@ -11,7 +11,9 @@ import addWeeks from '../addWeeks/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of weeks to be subtracted * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the weeks subtracted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Subtract 4 weeks from 1 September 2014: diff --git a/src/subWeeks/index.js.flow b/src/subWeeks/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/subWeeks/index.js.flow +++ b/src/subWeeks/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/subWeeks/test.js b/src/subWeeks/test.js index 8abfaec003..0cf58ab531 100644 --- a/src/subWeeks/test.js +++ b/src/subWeeks/test.js @@ -31,4 +31,20 @@ describe('subWeeks', function () { subWeeks(date, 2) assert.deepEqual(date, new Date(2014, 8 /* Sep */, 1)) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = subWeeks(new Date(NaN), 4) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = subWeeks(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = subWeeks.bind(null, new Date(2014, 8 /* Sep */, 1), 4, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/subYears/index.js b/src/subYears/index.js index ab41f06f19..ca5675efd8 100644 --- a/src/subYears/index.js +++ b/src/subYears/index.js @@ -11,7 +11,9 @@ import addYears from '../addYears/index.js' * @param {Date|String|Number} date - the date to be changed * @param {Number} amount - the amount of years to be subtracted * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} + * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link docs/toDate} * @returns {Date} the new date with the years subtracted + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Subtract 5 years from 1 September 2014: diff --git a/src/subYears/index.js.flow b/src/subYears/index.js.flow index 134bb51f34..cc2c84144c 100644 --- a/src/subYears/index.js.flow +++ b/src/subYears/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/subYears/test.js b/src/subYears/test.js index 60c2accae3..32373e80be 100644 --- a/src/subYears/test.js +++ b/src/subYears/test.js @@ -47,4 +47,20 @@ describe('subYears', function () { var result = subYears(initialDate, 1) assert.deepEqual(result, expectedResult) }) + + it('returns `Invalid Date` if the given date is invalid', function () { + var result = subYears(new Date(NaN), 5) + assert(result instanceof Date && isNaN(result)) + }) + + it('returns `Invalid Date` if the given amount is NaN', function () { + var result = subYears(new Date(2014, 8 /* Sep */, 1), NaN) + assert(result instanceof Date && isNaN(result)) + }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = subYears.bind(null, new Date(2014, 8 /* Sep */, 1), 5, {additionalDigits: NaN}) + assert.throws(block, RangeError) + }) }) diff --git a/src/toDate/index.js b/src/toDate/index.js index e779f5ece6..825e8a5982 100644 --- a/src/toDate/index.js +++ b/src/toDate/index.js @@ -58,10 +58,14 @@ var patterns = { * * If all above fails, the function passes the given argument to Date constructor. * + * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`. + * All *date-fns* functions will throw `RangeError` if `options.additionalDigits` is not 0, 1, 2 or undefined. + * * @param {Date|String|Number} argument - the value to convert * @param {Options} [options] - the object with options. See [Options]{@link docs/Options} * @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format * @returns {Date} the parsed date in the local time zone + * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 * * @example * // Convert string '2014-02-11T11:30:30' to date: @@ -75,6 +79,13 @@ var patterns = { * //=> Fri Apr 11 2014 00:00:00 */ export default function toDate (argument, dirtyOptions) { + var options = dirtyOptions || {} + + var additionalDigits = options.additionalDigits === undefined ? DEFAULT_ADDITIONAL_DIGITS : Number(options.additionalDigits) + if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) { + throw new RangeError('additionalDigits must be 0, 1 or 2') + } + // Clone the date if (isDate(argument)) { // Prevent the date to lose the milliseconds when passed to new Date() in IE10 @@ -83,14 +94,6 @@ export default function toDate (argument, dirtyOptions) { return new Date(argument) } - var options = dirtyOptions || {} - var additionalDigits = options.additionalDigits - if (additionalDigits == null) { - additionalDigits = DEFAULT_ADDITIONAL_DIGITS - } else { - additionalDigits = Number(additionalDigits) - } - var dateStrings = splitDateString(argument) var parseYearResult = parseYear(dateStrings.date, additionalDigits) diff --git a/src/toDate/index.js.flow b/src/toDate/index.js.flow index 05e236afb0..78eed411a0 100644 --- a/src/toDate/index.js.flow +++ b/src/toDate/index.js.flow @@ -7,13 +7,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { diff --git a/src/toDate/test.js b/src/toDate/test.js index 294266034b..563025e87e 100644 --- a/src/toDate/test.js +++ b/src/toDate/test.js @@ -254,4 +254,10 @@ describe('toDate', function () { var result = toDate('+12340702', {additionalDigits: '0'}) assert.deepEqual(result, new Date(1234, 6 /* Jul */, 2)) }) + + it('throws `RangeError` if `options.additionalDigits` is not convertable to 0, 1, 2 or undefined`', function () { + // $ExpectedMistake + var block = toDate.bind(null, '+12340702', {additionalDigits: 3}) + assert.throws(block, RangeError) + }) }) diff --git a/typings.d.ts b/typings.d.ts index ff4a3e4ebb..def51cfe24 100644 --- a/typings.d.ts +++ b/typings.d.ts @@ -32,13 +32,13 @@ type Interval = { } type Options = { - weekStartsOn?: number, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, additionalDigits?: 0 | 1 | 2, locale?: Locale, includeSeconds?: boolean, addSuffix?: boolean, unit?: 's' | 'm' | 'h' | 'd' | 'M' | 'Y', - partialMethod?: 'floor' | 'ceil' | 'round' + roundingMethod?: 'floor' | 'ceil' | 'round' } type Locale = { @@ -16948,7 +16948,7 @@ interface dateFns { ): boolean isValid( - date: Date, + date: Date | string | number, options?: Options ): boolean