Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit cfc93a0

Browse files
committed
Merge branch 'kato-datejson' into kato-protractor
2 parents 75a3f96 + 679ffe5 commit cfc93a0

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@
374374
else {
375375
dat = {};
376376
utils.each(rec, function (v, k) {
377+
if( v instanceof Date ) { v = v.getTime(); }
377378
dat[k] = stripDollarPrefixedKeys(v);
378379
});
379380
}

tests/unit/utils.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ describe('$firebaseUtils', function () {
172172
$utils.toJSON({foo: 'bar', baz: undef});
173173
}).toThrowError(Error);
174174
});
175+
176+
it('should parse dates into milliseconds since epoch', function() {
177+
var date = new Date();
178+
var ts = date.getTime();
179+
expect($utils.toJSON({date: date}).date).toBe(ts);
180+
});
175181
});
176182

177183
describe('#getKey', function() {

0 commit comments

Comments
 (0)