Created
June 5, 2012 18:59
-
-
Save shazron/2876989 to your computer and use it in GitHub Desktop.
test geolocation.js for CB-866
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function testOld(p) { | |
| var result = p.timestamp || new Date(); | |
| console.log("\told: " + result); | |
| } | |
| function testNew(p) { | |
| var result = (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp))); | |
| console.log("\tnew: " + result); | |
| } | |
| function testWithInt() { | |
| var p = { timestamp : 215123 }; | |
| console.log("timestamp has a number"); | |
| testOld(p); | |
| testNew(p); | |
| } | |
| function testWithDate() { | |
| var p = { timestamp : new Date(2012, 1, 2, 0, 0, 0, 0) }; | |
| console.log("timestamp has a date object"); | |
| testOld(p); | |
| testNew(p); | |
| } | |
| function testWithNoDate() { | |
| var p = { }; | |
| console.log("timestamp is null"); | |
| testOld(p); | |
| testNew(p); | |
| } | |
| (function() { | |
| testWithDate(); | |
| testWithNoDate(); | |
| testWithInt(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment