Skip to content

Instantly share code, notes, and snippets.

@shazron
Created June 5, 2012 18:59
Show Gist options
  • Select an option

  • Save shazron/2876989 to your computer and use it in GitHub Desktop.

Select an option

Save shazron/2876989 to your computer and use it in GitHub Desktop.
test geolocation.js for CB-866
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