Magnetiq

month

April 2010

3 posts

Parsing ISO 8601 UTC dates

Here’s a concise implementation for parsing UTC date strings in ISO 8601 format into Date objects in the local time zone.

function parseIsoDate(s) {
    var tokens = /(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)\.(\d+)/
        .exec(s).slice(1);
    tokens[1] -= 1;
    return new Date(Date.UTC.apply(null, tokens));
}

The new Date(Date.UTC.apply(null, tokens)) trick allows the direct usage of an array of date components for the construction of a new Date instance.

Apr 26, 20101 note
#javascript
Catch those anchors with hash && (hash = hash)

The following cryptic bit of JavaScript is actual code that I’ve used as a workaround to a very specific issue. The issue I was having was with anchor links not pointing to the right place on the page.

Read More →

Apr 26, 20109 notes
#javascript
Enabling Disqus comments on a custom Tumblr theme using jQuery

The official “Universal Code” that is suggested by Disqus for embedding the comment widget injects a new <script> element into the page and looks a bit messy. The embedding can be achieved with cleaner code using jQuery’s JSONP support.

Read More →

Apr 08, 201031 notes
#disqus #javascript #jquery #tumblr
Next page →
2012 2013
  • January
  • February
  • March 1
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
2011 2012 2013
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
2010 2011 2012
  • January 1
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
2009 2010 2011
  • January
  • February
  • March
  • April 3
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December 1
2008 2009 2010
  • January
  • February 2
  • March
  • April
  • May
  • June 3
  • July 2
  • August
  • September
  • October
  • November
  • December
2007 2008 2009
  • January
  • February
  • March
  • April
  • May
  • June 2
  • July
  • August 1
  • September 1
  • October 4
  • November
  • December 1
2006 2007 2008
  • January
  • February 1
  • March
  • April
  • May
  • June
  • July
  • August
  • September 1
  • October
  • November
  • December
2006 2007
  • January
  • February
  • March
  • April
  • May
  • June
  • July 4
  • August 2
  • September
  • October
  • November 2
  • December 1