Skip to content

Instantly share code, notes, and snippets.

@abl
Created September 10, 2013 16:48
Show Gist options
  • Select an option

  • Save abl/6512197 to your computer and use it in GitHub Desktop.

Select an option

Save abl/6512197 to your computer and use it in GitHub Desktop.

Revisions

  1. @Aleksandyr Aleksandyr created this gist Sep 10, 2013.
    14 changes: 14 additions & 0 deletions isdst.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    //This is completely ridiculous.
    var jan = new Date(this.getFullYear(), 0, 1).getTimezoneOffset();
    var jul = new Date(this.getFullYear(), 6, 1).getTimezoneOffset();
    var today = new Date().getTimezoneOffset();

    if(jan == jul) {
    $('#daylight_savings').prop('checked', false);
    } else if(jan > jun) {
    //Northern hemisphere
    $('#daylight_savings').prop('checked', (jun==today));
    } else { //jun < jan
    //Southern hemisphere
    $('#daylight_savings').prop('checked', (jan==today));
    }