wholemeal

Chunky | Goodness

Chrome vs Firefox Javascript Date Differences

Spent a fair amount of time wracking my brain over a problem caused by this today. It turns out there are some subtle implementation differences between Firefox and Chrome when parsing date strings:

// Chrome
new Date('2011-10-31'); // Sun Oct 30 2011 00:00:00 GMT+1300 (NZDT)

// Firefox
new Date('2011-10-31'); // Sun Oct 30 2011 13:00:00 GMT+1300 (NZST)
                        //                 ^^^^^^^^
                        //                 Different default hour

When parsing a date as a string without an explicit time, Chrome will default the Date object’s time to midnight local time. Firefox will default it to midnight GMT.

To ensure the same behaviour across both browsers, use the following style of initialiser.

// Note that the month numbers are zero indexed, so Jan is 0, Dec 11.
// Year and day numbers are *not* zero indexed.

new Date(2011, 10-1, 31);
// Returns Mon Oct 31 2011 00:00:00 GMT+1300 in Chrome and firefox.

Presenting Backbone.js at Christchurch on Rails

I’ll be giving a short presentation on Backbone.js at the next Christchurch on Rails meeting. There’s also potentially another short talk on CoffeeScript on the cards, so it will be a Javascript only night and may be of interest to non Rails folk.

Venue is being provided by the lovely folks at Trineo, and drinks and nibbles from the equally lovely folks at Resolve Digital.

  • Where: Trineo Ltd, Unit 2C, 105 Gasson St (entrance at rear)
  • When: Thu 15th Sep 2011 - 17:30

See you there!

Geeks on Bikes

NOTE >>>> CANCELLED DUE TO LACK OF INTEREST <<<<

I’ve been toying with getting this going for a while now, so lets just see if this thing floats. Announcing …

Geeks on Bikes [0]

Photo credit: Steve Jurvetson

Ever noticed how geekdom and cycling seem to go hand in hand? Perhaps it’s an appreciation of the design and engineering perfection of the humble bicycle, or maybe the frittering of funds on gadgets leaves no other transport options. Whatever the cause, on the whole, geeks like to bike.

And so, fellow pedallers, I humbly invite you to lay down your arms in the programming language / OS / editor wars and join me in the first of hopefully many two wheeled forays in and around beautiful Churtown.

Geeks on bikes[0] - geeks_on_bikes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
geeksOnBikes.push({
ride: 'Bottle Lake Forest Loop',
type: 'MTB',
grade: 'Easy',
distance: 10.0, // km (approx)
rendezvous: {
where: 'Beach Cafe, 16 Beach Rd, Nth New Brighton',
when: 'Sun Sep 11 14:00:00 NZST 2011',
latlon: [-43.485248,172.722116]
}
});

Bring yourself and steed. Extra merit for GPS plots, helmet cams, Arduino cycle computers, and other gadgetry. Follow @malclocke for updates, I may postpone in the event of atrocious weather.

See you then!