date-fns
Advanced tools
Comparing version 0.5.0 to 0.6.0
# Changelog | ||
## v0.6.0 (7 Oct 2014) | ||
* Additions: | ||
- `isFirstDayOfMonth` | ||
- `isLastDayOfMonth` | ||
- `isSameMonth` | ||
* Bug fixes: | ||
- Inconsistent behavior of `endOfMonth` | ||
## v0.5.0 (7 Oct 2014) | ||
@@ -4,0 +13,0 @@ |
{ | ||
"name": "date-fns", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"author": "Sasha Koss <kossnocorp@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Date helpers", |
@@ -20,2 +20,5 @@ # date-fns | ||
* [`subDays`](./src/sub_days) - substract specified number of days from passed date | ||
* [`isSameMonth`](./src/is_same_month) - returns true if passed dates has same month (and year) | ||
* [`isFirstDayOfMonth`](./src/is_first_day_of_month) - return true if passed date is first day of month | ||
* [`isLastDayOfMonth`](./src/is_last_day_of_month) - return true if passed date is last day of month | ||
@@ -8,3 +8,3 @@ var endOfMonth = require('../end_of_month'); | ||
expect(result).to.be.eql( | ||
new Date(2014, 8 /* starts from 0 */, 30, 23, 59, 59, 999) | ||
new Date(2014, 8 /* Sep */, 30, 23, 59, 59, 999) | ||
); | ||
@@ -17,3 +17,3 @@ }); | ||
expect(result).to.be.eql( | ||
new Date(2014, 8 /* starts from 0 */, 30, 23, 59, 59, 999) | ||
new Date(2014, 8 /* Sep */, 30, 23, 59, 59, 999) | ||
); | ||
@@ -28,10 +28,20 @@ }); | ||
it('works for last month in year', function() { | ||
var date = '2014-12-01T10:00:00'; | ||
var result = endOfMonth(date); | ||
expect(result).to.be.eql( | ||
new Date(2014, 11 /* starts from 0 */, 31, 23, 59, 59, 999) | ||
); | ||
describe('edge cases', function() { | ||
it('works for last month in year', function() { | ||
var date = '2014-12-01T10:00:00'; | ||
var result = endOfMonth(date); | ||
expect(result).to.be.eql( | ||
new Date(2014, 11 /* Dec */, 31, 23, 59, 59, 999) | ||
); | ||
}); | ||
it('works for last day of month', function() { | ||
var date = new Date(2014, 9 /* Oct */, 31); | ||
var result = endOfMonth(date); | ||
expect(result).to.be.eql( | ||
new Date(2014, 9 /* Sep */, 31, 23, 59, 59, 999) | ||
); | ||
}); | ||
}); | ||
}); | ||
@@ -9,4 +9,3 @@ /** | ||
date.setHours(23, 59, 59, 999); | ||
date.setMonth(date.getMonth() + 1); | ||
date.setDate(0); | ||
date.setFullYear(date.getFullYear(), date.getMonth() + 1, 0); | ||
return date; | ||
@@ -13,0 +12,0 @@ }; |
22828
36
572
24