Skip to content

Commit

Permalink
Remove all functions that create the current date internally (closes #…
Browse files Browse the repository at this point in the history
…377) (#380)

* Remove all functions that create the current date internally

* Correct number of functions in README.md

* Regenerate index.js

* Add #377 entry to CHANGELOG.md

* Add reasoning for removing now fns to changelog
  • Loading branch information
leshakoss committed Feb 13, 2017
1 parent 3ae4d17 commit 83c4982
Show file tree
Hide file tree
Showing 87 changed files with 65 additions and 1,994 deletions.
66 changes: 64 additions & 2 deletions CHANGELOG.md
Expand Up @@ -9,21 +9,83 @@ This change log follows the format documented in [Keep a CHANGELOG].
[Keep a CHANGELOG]: http://keepachangelog.com/

## [Unreleased]

### Changed

- **BREAKING**: min and max functions now accept an array of dates
rather than spread arguments.

```javascript
// Before v1.15.2
// Before v2.0.0
var minDate = min(new Date(1989, 6 /* Jul */, 10), new Date(1987, 1 /* Feb */, 11))
var maxDate = min(new Date(1989, 6 /* Jul */, 10), new Date(1987, 1 /* Feb */, 11))

// v1.15.2 onward
// v2.0.0 onward
var minDate = min([new Date(1989, 6 /* Jul */, 10), new Date(1987, 1 /* Feb */, 11)])
var maxDate = min([new Date(1989, 6 /* Jul */, 10), new Date(1987, 1 /* Feb */, 11)])
```

- **BREAKING**: remove all functions that create the current date internally:

- `distanceInWordsToNow`
- `isFuture`
- `isPast`
- `endOfToday`
- `endOfTomorrow`
- `endOfYesterday`
- `startOfToday`
- `startOfTomorrow`
- `startOfYesterday`
- `isToday`
- `isTomorrow`
- `isYesterday`
- `isThisSecond`
- `isThisMinute`
- `isThisHour`
- `isThisWeek`
- `isThisISOWeek`
- `isThisMonth`
- `isThisQuarter`
- `isThisYear`
- `isThisISOYear`

These functions are not pure, cannot have FP-versions [#253](https://github.com/date-fns/date-fns/issues/253)
and would add extra code for UTC-versions [#376](https://github.com/date-fns/date-fns/issues/376).

See issue: [#377](https://github.com/date-fns/date-fns/issues/377)

```javascript
// Before v2.0.0
var result = endOfToday()

// v2.0.0 onward
var result = endOfDay(new Date())
```

Upgrade guide:

- `distanceInWordsToNow(date)``distanceInWords(new Date(), date)`
- `isFuture(date)``isAfter(date, new Date())`
- `isPast(date)``isBefore(date, new Date())`
- `endOfToday()``endOfDay(new Date())`
- `endOfTomorrow()``endOfDay(addDays(new Date(), 1))`
- `endOfYesterday()``endOfDay(subDays(new Date(), 1))`
- `startOfToday()``startOfDay(new Date())`
- `startOfTomorrow()``startOfDay(addDays(new Date(), 1))`
- `startOfYesterday()``startOfDay(subDays(new Date(), 1))`
- `isToday(date)``isSameDay(new Date(), date)`
- `isTomorrow(date)``isSameDay(date, addDays(new Date(), 1))`
- `isYesterday(date)``isSameDay(date, subDays(new Date(), 1))`
- `isThisSecond(date)``isSameSecond(date, new Date())`
- `isThisMinute(date)``isSameMinute(date, new Date())`
- `isThisHour(date)``isSameHour(date, new Date())`
- `isThisWeek(date)``isSameWeek(date, new Date())`
- `isThisISOWeek(date)``isSameISOWeek(date, new Date())`
- `isThisMonth(date)``isSameMonth(date, new Date())`
- `isThisQuarter(date)``isSameQuarter(date, new Date())`
- `isThisYear(date)``isSameYear(date, new Date())`
- `isThisISOYear(date)``isSameISOYear(date, new Date())`

- **BREAKING**: make the second argument of `format` non-optional in favor of explicitness.

```javascript
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@
for manipulating **JavaScript dates** in **a browser** & **Node.js**.

**date-fns** is like [lodash](https://lodash.com) for dates. It has
[**140+ functions** for all occasions](https://date-fns.org/docs/).
[**130+ functions** for all occasions](https://date-fns.org/docs/).

```js
dateFns.format(new Date(2014, 1, 11), 'MM/DD/YYYY')
Expand Down
21 changes: 0 additions & 21 deletions index.js
Expand Up @@ -33,7 +33,6 @@ module.exports = {
differenceInYears: require('./difference_in_years/index.js'),
distanceInWords: require('./distance_in_words/index.js'),
distanceInWordsStrict: require('./distance_in_words_strict/index.js'),
distanceInWordsToNow: require('./distance_in_words_to_now/index.js'),
eachDay: require('./each_day/index.js'),
endOfDay: require('./end_of_day/index.js'),
endOfHour: require('./end_of_hour/index.js'),
Expand All @@ -43,11 +42,8 @@ module.exports = {
endOfMonth: require('./end_of_month/index.js'),
endOfQuarter: require('./end_of_quarter/index.js'),
endOfSecond: require('./end_of_second/index.js'),
endOfToday: require('./end_of_today/index.js'),
endOfTomorrow: require('./end_of_tomorrow/index.js'),
endOfWeek: require('./end_of_week/index.js'),
endOfYear: require('./end_of_year/index.js'),
endOfYesterday: require('./end_of_yesterday/index.js'),
format: require('./format/index.js'),
getDate: require('./get_date/index.js'),
getDay: require('./get_day/index.js'),
Expand All @@ -73,11 +69,9 @@ module.exports = {
isEqual: require('./is_equal/index.js'),
isFirstDayOfMonth: require('./is_first_day_of_month/index.js'),
isFriday: require('./is_friday/index.js'),
isFuture: require('./is_future/index.js'),
isLastDayOfMonth: require('./is_last_day_of_month/index.js'),
isLeapYear: require('./is_leap_year/index.js'),
isMonday: require('./is_monday/index.js'),
isPast: require('./is_past/index.js'),
isSameDay: require('./is_same_day/index.js'),
isSameHour: require('./is_same_hour/index.js'),
isSameISOWeek: require('./is_same_iso_week/index.js'),
Expand All @@ -90,24 +84,12 @@ module.exports = {
isSameYear: require('./is_same_year/index.js'),
isSaturday: require('./is_saturday/index.js'),
isSunday: require('./is_sunday/index.js'),
isThisHour: require('./is_this_hour/index.js'),
isThisISOWeek: require('./is_this_iso_week/index.js'),
isThisISOYear: require('./is_this_iso_year/index.js'),
isThisMinute: require('./is_this_minute/index.js'),
isThisMonth: require('./is_this_month/index.js'),
isThisQuarter: require('./is_this_quarter/index.js'),
isThisSecond: require('./is_this_second/index.js'),
isThisWeek: require('./is_this_week/index.js'),
isThisYear: require('./is_this_year/index.js'),
isThursday: require('./is_thursday/index.js'),
isToday: require('./is_today/index.js'),
isTomorrow: require('./is_tomorrow/index.js'),
isTuesday: require('./is_tuesday/index.js'),
isValid: require('./is_valid/index.js'),
isWednesday: require('./is_wednesday/index.js'),
isWeekend: require('./is_weekend/index.js'),
isWithinRange: require('./is_within_range/index.js'),
isYesterday: require('./is_yesterday/index.js'),
lastDayOfISOWeek: require('./last_day_of_iso_week/index.js'),
lastDayOfISOYear: require('./last_day_of_iso_year/index.js'),
lastDayOfMonth: require('./last_day_of_month/index.js'),
Expand Down Expand Up @@ -138,11 +120,8 @@ module.exports = {
startOfMonth: require('./start_of_month/index.js'),
startOfQuarter: require('./start_of_quarter/index.js'),
startOfSecond: require('./start_of_second/index.js'),
startOfToday: require('./start_of_today/index.js'),
startOfTomorrow: require('./start_of_tomorrow/index.js'),
startOfWeek: require('./start_of_week/index.js'),
startOfYear: require('./start_of_year/index.js'),
startOfYesterday: require('./start_of_yesterday/index.js'),
subDays: require('./sub_days/index.js'),
subHours: require('./sub_hours/index.js'),
subISOYears: require('./sub_iso_years/index.js'),
Expand Down
21 changes: 0 additions & 21 deletions src/distance_in_words_to_now/benchmark.js

This file was deleted.

85 changes: 0 additions & 85 deletions src/distance_in_words_to_now/index.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/distance_in_words_to_now/index.js.flow

This file was deleted.

0 comments on commit 83c4982

Please sign in to comment.