Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8a109e7

Browse files
KamalAmanmattphillips
authored andcommitted
Fixes bug with difference dates in the same second returning true (mattphillips#12)
1 parent 49e6acf commit 8a109e7

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

‎src/diff/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const diff = (lhs, rhs) => {
1313
}, {});
1414

1515
if (isDate(l) || isDate(r)) {
16-
if (l.toString() == r.toString()) return {};
16+
if (l.valueOf() == r.valueOf()) return {};
1717
return r;
1818
}
1919

‎src/diff/index.test.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe('.diff', () => {
3535
[100, () => ({})],
3636
[() => ({}), 100],
3737
[new Date('2017年01月01日'), new Date('2017年01月02日')],
38+
[new Date('2017年01月01日T00:00:00.636Z'), new Date('2017年01月01日T00:00:00.637Z')],
3839
]).test('returns right hand side value when different to left hand side value (%s, %s)', (lhs, rhs) => {
3940
expect(diff(lhs, rhs)).toEqual(rhs);
4041
});

‎src/updated/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const updatedDiff = (lhs, rhs) => {
1010
const r = properObject(rhs);
1111

1212
if (isDate(l) || isDate(r)) {
13-
if (l.toString() == r.toString()) return {};
13+
if (l.valueOf() == r.valueOf()) return {};
1414
return r;
1515
}
1616

‎src/updated/index.test.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe('.updatedDiff', () => {
3535
[100, () => ({})],
3636
[() => ({}), 100],
3737
[new Date('2017年01月01日'), new Date('2017年01月02日')],
38+
[new Date('2017年01月01日T00:00:00.636Z'), new Date('2017年01月01日T00:00:00.637Z')],
3839
]).test('returns right hand side value when different to left hand side value (%s, %s)', (lhs, rhs) => {
3940
expect(updatedDiff(lhs, rhs)).toEqual(rhs);
4041
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /