Commits

Jon Nylander committed 47c3b72 Merge

Testing index.html

Comments (0)

Files changed (8)

detect_timezone.js

-/*jslint undef: true */
-/*global console*/
-/*global exports*/
-/*version 2012-05-10*/
-
-(function(root) {
-  /**
-   * Namespace to hold all the code for timezone detection.
-   */
-  var jstz = (function () {
-      'use strict';
-      var HEMISPHERE_SOUTH = 's',
-
-          /**
-           * Gets the offset in minutes from UTC for a certain date.
-           * @param {Date} date
-           * @returns {Number}
-           */
-          get_date_offset = function (date) {
-              var offset = -date.getTimezoneOffset();
-              return (offset !== null ? offset : 0);
-          },
-
-          get_january_offset = function () {
-              return get_date_offset(new Date(2010, 0, 1, 0, 0, 0, 0));
-          },
-
-          get_june_offset = function () {
-              return get_date_offset(new Date(2010, 5, 1, 0, 0, 0, 0));
-          },
-
-          /**
-           * Private method.
-           * Checks whether a given date is in daylight savings time.
-           * If the date supplied is after june, we assume that we're checking
-           * for southern hemisphere DST.
-           * @param {Date} date
-           * @returns {Boolean}
-           */
-          date_is_dst = function (date) {
-              var base_offset = ((date.getMonth() > 5 ? get_june_offset()
-                                                  : get_january_offset())),
-                  date_offset = get_date_offset(date);
-
-              return (base_offset - date_offset) !== 0;
-          },
-
-          /**
-           * This function does some basic calculations to create information about
-           * the user's timezone.
-           *
-           * Returns a key that can be used to do lookups in jstz.olson.timezones.
-           *
-           * @returns {String}
-           */
-
-          lookup_key = function () {
-              var january_offset = get_january_offset(),
-                  june_offset = get_june_offset(),
-                  diff = get_january_offset() - get_june_offset();
-
-              if (diff < 0) {
-                  return january_offset + ",1";
-              } else if (diff > 0) {
-                  return june_offset + ",1," + HEMISPHERE_SOUTH;
-              }
-
-              return january_offset + ",0";
-          },
-
-          /**
-           * Uses get_timezone_info() to formulate a key to use in the olson.timezones dictionary.
-           *
-           * Returns a primitive object on the format:
-           * {'timezone': TimeZone, 'key' : 'the key used to find the TimeZone object'}
-           *
-           * @returns Object
-           */
-          determine = function () {
-              var key = lookup_key();
-              return new jstz.TimeZone(jstz.olson.timezones[key]);
-          };
-
-      return {
-          determine_timezone : function () {
-              if (typeof console !== 'undefined') {
-                  console.log("jstz.determine_timezone() is deprecated and will be removed in an upcoming version. Please use jstz.determine() instead.");
-              }
-              return determine();
-          },
-          determine: determine,
-          date_is_dst : date_is_dst
-      };
-  }());
-
-  /**
-   * Simple object to perform ambiguity check and to return name of time zone.
-   */
-  jstz.TimeZone = function (tz_name) {
-      'use strict';
-      var timezone_name = null,
-
-          name = function () {
-              return timezone_name;
-          },
-
-          /**
-           * Checks if a timezone has possible ambiguities. I.e timezones that are similar.
-           *
-           * For example, if the preliminary scan determines that we're in America/Denver.
-           * We double check here that we're really there and not in America/Mazatlan.
-           *
-           * This is done by checking known dates for when daylight savings start for different
-           * timezones during 2010 and 2011.
-           */
-          ambiguity_check = function () {
-              var ambiguity_list = jstz.olson.ambiguity_list[timezone_name],
-                  length = ambiguity_list.length,
-                  i = 0,
-                  tz = ambiguity_list[0];
-
-              for (; i < length; i += 1) {
-                  tz = ambiguity_list[i];
-
-                  if (jstz.date_is_dst(jstz.olson.dst_start_dates[tz])) {
-                      timezone_name = tz;
-                      return;
-                  }
-              }
-          },
-
-          /**
-           * Checks if it is possible that the timezone is ambiguous.
-           */
-          is_ambiguous = function () {
-              return typeof (jstz.olson.ambiguity_list[timezone_name]) !== 'undefined';
-          };
-
-
-
-      timezone_name = tz_name;
-      if (is_ambiguous()) {
-          ambiguity_check();
-      }
-
-      return {
-          name: name
-      };
-  };
-
-  jstz.olson = {};
-
-  /*
-   * The keys in this dictionary are comma separated as such:
-   *
-   * First the offset compared to UTC time in minutes.
-   *
-   * Then a flag which is 0 if the timezone does not take daylight savings into account and 1 if it
-   * does.
-   *
-   * Thirdly an optional 's' signifies that the timezone is in the southern hemisphere,
-   * only interesting for timezones with DST.
-   *
-   * The mapped arrays is used for constructing the jstz.TimeZone object from within
-   * jstz.determine_timezone();
-   */
-  jstz.olson.timezones = {
-      '-720,0'   : 'Etc/GMT+12',
-      '-660,0'   : 'Pacific/Pago_Pago',
-      '-600,1'   : 'America/Adak',
-      '-600,0'   : 'Pacific/Honolulu',
-      '-570,0'   : 'Pacific/Marquesas',
-      '-540,0'   : 'Pacific/Gambier',
-      '-540,1'   : 'America/Anchorage',
-      '-480,1'   : 'America/Los_Angeles',
-      '-480,0'   : 'Pacific/Pitcairn',
-      '-420,0'   : 'America/Phoenix',
-      '-420,1'   : 'America/Denver',
-      '-360,0'   : 'America/Guatemala',
-      '-360,1'   : 'America/Chicago',
-      '-360,1,s' : 'Pacific/Easter',
-      '-300,0'   : 'America/Bogota',
-      '-300,1'   : 'America/New_York',
-      '-270,0'   : 'America/Caracas',
-      '-240,1'   : 'America/Halifax',
-      '-240,0'   : 'America/Santo_Domingo',
-      '-240,1,s' : 'America/Asuncion',
-      '-210,1'   : 'America/St_Johns',
-      '-180,1'   : 'America/Godthab',
-      '-180,0'   : 'America/Argentina/Buenos_Aires',
-      '-180,1,s' : 'America/Montevideo',
-      '-120,0'   : 'America/Noronha',
-      '-120,1'   : 'Etc/GMT+2',
-      '-60,1'    : 'Atlantic/Azores',
-      '-60,0'    : 'Atlantic/Cape_Verde',
-      '0,0'      : 'Etc/UTC',
-      '0,1'      : 'Europe/London',
-      '60,1'     : 'Europe/Berlin',
-      '60,0'     : 'Africa/Lagos',
-      '60,1,s'   : 'Africa/Windhoek',
-      '120,1'    : 'Asia/Beirut',
-      '120,0'    : 'Africa/Johannesburg',
-      '180,1'    : 'Europe/Moscow',
-      '180,0'    : 'Asia/Baghdad',
-      '210,1'    : 'Asia/Tehran',
-      '240,0'    : 'Asia/Dubai',
-      '240,1'    : 'Asia/Yerevan',
-      '270,0'    : 'Asia/Kabul',
-      '300,1'    : 'Asia/Yekaterinburg',
-      '300,0'    : 'Asia/Karachi',
-      '330,0'    : 'Asia/Kolkata',
-      '345,0'    : 'Asia/Kathmandu',
-      '360,0'    : 'Asia/Dhaka',
-      '360,1'    : 'Asia/Omsk',
-      '390,0'    : 'Asia/Rangoon',
-      '420,1'    : 'Asia/Krasnoyarsk',
-      '420,0'    : 'Asia/Jakarta',
-      '480,0'    : 'Asia/Shanghai',
-      '480,1'    : 'Asia/Irkutsk',
-      '525,0'    : 'Australia/Eucla',
-      '525,1,s'  : 'Australia/Eucla',
-      '540,1'    : 'Asia/Yakutsk',
-      '540,0'    : 'Asia/Tokyo',
-      '570,0'    : 'Australia/Darwin',
-      '570,1,s'  : 'Australia/Adelaide',
-      '600,0'    : 'Australia/Brisbane',
-      '600,1'    : 'Asia/Vladivostok',
-      '600,1,s'  : 'Australia/Sydney',
-      '630,1,s'  : 'Australia/Lord_Howe',
-      '660,1'    : 'Asia/Kamchatka',
-      '660,0'    : 'Pacific/Noumea',
-      '690,0'    : 'Pacific/Norfolk',
-      '720,1,s'  : 'Pacific/Auckland',
-      '720,0'    : 'Pacific/Tarawa',
-      '765,1,s'  : 'Pacific/Chatham',
-      '780,0'    : 'Pacific/Tongatapu',
-      '780,1,s'  : 'Pacific/Apia',
-      '840,0'    : 'Pacific/Kiritimati'
-  };
-
-
-  /**
-   * This object contains information on when daylight savings starts for
-   * different timezones.
-   *
-   * The list is short for a reason. Often we do not have to be very specific
-   * to single out the correct timezone. But when we do, this list comes in
-   * handy.
-   *
-   * Each value is a date denoting when daylight savings starts for that timezone.
-   */
-  jstz.olson.dst_start_dates = {
-      'America/Denver' : new Date(2011, 2, 13, 3, 0, 0, 0),
-      'America/Mazatlan' : new Date(2011, 3, 3, 3, 0, 0, 0),
-      'America/Chicago' : new Date(2011, 2, 13, 3, 0, 0, 0),
-      'America/Mexico_City' : new Date(2011, 3, 3, 3, 0, 0, 0),
-      'Atlantic/Stanley' : new Date(2011, 8, 4, 7, 0, 0, 0),
-      'America/Asuncion' : new Date(2011, 9, 2, 3, 0, 0, 0),
-      'America/Santiago' : new Date(2011, 9, 9, 3, 0, 0, 0),
-      'America/Campo_Grande' : new Date(2011, 9, 16, 5, 0, 0, 0),
-      'America/Montevideo' : new Date(2011, 9, 2, 3, 0, 0, 0),
-      'America/Sao_Paulo' : new Date(2011, 9, 16, 5, 0, 0, 0),
-      'America/Los_Angeles' : new Date(2011, 2, 13, 8, 0, 0, 0),
-      'America/Santa_Isabel' : new Date(2011, 3, 5, 8, 0, 0, 0),
-      'America/Havana' : new Date(2011, 2, 13, 2, 0, 0, 0),
-      'America/New_York' : new Date(2011, 2, 13, 7, 0, 0, 0),
-      'Asia/Gaza' : new Date(2011, 2, 26, 23, 0, 0, 0),
-      'Asia/Beirut' : new Date(2011, 2, 27, 1, 0, 0, 0),
-      'Europe/Minsk' : new Date(2011, 2, 27, 2, 0, 0, 0),
-      'Europe/Helsinki' : new Date(2011, 2, 27, 4, 0, 0, 0),
-      'Europe/Istanbul' : new Date(2011, 2, 28, 5, 0, 0, 0),
-      'Asia/Damascus' : new Date(2011, 3, 1, 2, 0, 0, 0),
-      'Asia/Jerusalem' : new Date(2011, 3, 1, 6, 0, 0, 0),
-      'Africa/Cairo' : new Date(2010, 3, 30, 4, 0, 0, 0),
-      'Asia/Yerevan' : new Date(2011, 2, 27, 4, 0, 0, 0),
-      'Asia/Baku'    : new Date(2011, 2, 27, 8, 0, 0, 0),
-      'Pacific/Auckland' : new Date(2011, 8, 26, 7, 0, 0, 0),
-      'Pacific/Fiji' : new Date(2010, 11, 29, 23, 0, 0, 0),
-      'America/Halifax' : new Date(2011, 2, 13, 6, 0, 0, 0),
-      'America/Goose_Bay' : new Date(2011, 2, 13, 2, 1, 0, 0),
-      'America/Miquelon' : new Date(2011, 2, 13, 5, 0, 0, 0),
-      'America/Godthab' : new Date(2011, 2, 27, 1, 0, 0, 0)
-  };
-
-  /**
-   * The keys in this object are timezones that we know may be ambiguous after
-   * a preliminary scan through the olson_tz object.
-   *
-   * The array of timezones to compare must be in the order that daylight savings
-   * starts for the regions.
-   */
-  jstz.olson.ambiguity_list = {
-      'America/Denver' : ['America/Denver', 'America/Mazatlan'],
-      'America/Chicago' : ['America/Chicago', 'America/Mexico_City'],
-      'America/Asuncion' : ['Atlantic/Stanley', 'America/Asuncion', 'America/Santiago', 'America/Campo_Grande'],
-      'America/Montevideo' : ['America/Montevideo', 'America/Sao_Paulo'],
-      'Asia/Beirut' : ['Asia/Gaza', 'Asia/Beirut', 'Europe/Minsk', 'Europe/Helsinki', 'Europe/Istanbul', 'Asia/Damascus', 'Asia/Jerusalem', 'Africa/Cairo'],
-      'Asia/Yerevan' : ['Asia/Yerevan', 'Asia/Baku'],
-      'Pacific/Auckland' : ['Pacific/Auckland', 'Pacific/Fiji'],
-      'America/Los_Angeles' : ['America/Los_Angeles', 'America/Santa_Isabel'],
-      'America/New_York' : ['America/Havana', 'America/New_York'],
-      'America/Halifax' : ['America/Goose_Bay', 'America/Halifax'],
-      'America/Godthab' : ['America/Miquelon', 'America/Godthab']
-  };
-
-  if (typeof exports !== 'undefined') {
-    exports.jstz = jstz;
-  } else {
-    root.jstz = jstz;
-  }
-})(this);
+/*global module*/
+module.exports = function (grunt) {
+	grunt.initConfig({
+    pkg: '<json:package.json>',
+    meta: {
+      banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %> */'
+    },		
+    lint: {
+			all: ['jstz.js']
+		},
+		min: {
+			dist: {
+        src: ['<banner>','jstz.js'],
+        dest: 'jstz.min.js'
+      }
+		}
+	});
+	
+	// Default task.
+	grunt.registerTask('default', 'lint min');
+
+};
+/*jslint undef: true */
+/*global console, exports*/
+
+(function(root) {
+  /**
+   * Namespace to hold all the code for timezone detection.
+   */
+  var jstz = (function () {
+      'use strict';
+      var HEMISPHERE_SOUTH = 's',
+
+          /**
+           * Gets the offset in minutes from UTC for a certain date.
+           * @param {Date} date
+           * @returns {Number}
+           */
+          get_date_offset = function (date) {
+              var offset = -date.getTimezoneOffset();
+              return (offset !== null ? offset : 0);
+          },
+
+          get_date = function (month, date) {
+              var d = new Date();
+              d.setDate(date);
+              d.setMonth(month);
+              return d;
+          },
+
+          get_january_offset = function () {
+              
+              return get_date_offset(get_date(0,2));
+          },
+
+          get_june_offset = function () {
+              return get_date_offset(get_date(5,2));
+          },
+
+          /**
+           * Private method.
+           * Checks whether a given date is in daylight savings time.
+           * If the date supplied is after june, we assume that we're checking
+           * for southern hemisphere DST.
+           * @param {Date} date
+           * @returns {Boolean}
+           */
+          date_is_dst = function (date) {
+              var base_offset = ((date.getMonth() > 5 ? get_june_offset()
+                                                  : get_january_offset())),
+                  date_offset = get_date_offset(date);
+
+              return (base_offset - date_offset) !== 0;
+          },
+
+          /**
+           * This function does some basic calculations to create information about
+           * the user's timezone.
+           *
+           * Returns a key that can be used to do lookups in jstz.olson.timezones.
+           *
+           * @returns {String}
+           */
+
+          lookup_key = function () {
+              var january_offset = get_january_offset(),
+                  june_offset = get_june_offset(),
+                  diff = get_january_offset() - get_june_offset();
+
+              if (diff < 0) {
+                  return january_offset + ",1";
+              } else if (diff > 0) {
+                  return june_offset + ",1," + HEMISPHERE_SOUTH;
+              }
+
+              return january_offset + ",0";
+          },
+
+          /**
+           * Uses get_timezone_info() to formulate a key to use in the olson.timezones dictionary.
+           *
+           * Returns a primitive object on the format:
+           * {'timezone': TimeZone, 'key' : 'the key used to find the TimeZone object'}
+           *
+           * @returns Object
+           */
+          determine = function () {
+              var key = lookup_key();
+              return new jstz.TimeZone(jstz.olson.timezones[key]);
+          };
+
+      return {
+          determine_timezone : function () {
+              if (typeof console !== 'undefined') {
+                  console.log("jstz.determine_timezone() is deprecated and will be removed in an upcoming version. Please use jstz.determine() instead.");
+              }
+              return determine();
+          },
+          determine: determine,
+          date_is_dst : date_is_dst
+      };
+  }());
+
+  /**
+   * Simple object to perform ambiguity check and to return name of time zone.
+   */
+  jstz.TimeZone = function (tz_name) {
+      'use strict';
+      var timezone_name = null,
+
+          name = function () {
+              return timezone_name;
+          },
+
+          /**
+           * Checks if a timezone has possible ambiguities. I.e timezones that are similar.
+           *
+           * For example, if the preliminary scan determines that we're in America/Denver.
+           * We double check here that we're really there and not in America/Mazatlan.
+           *
+           * This is done by checking known dates for when daylight savings start for different
+           * timezones during 2010 and 2011.
+           */
+          ambiguity_check = function () {
+              var ambiguity_list = jstz.olson.ambiguity_list[timezone_name],
+                  length = ambiguity_list.length,
+                  i = 0,
+                  tz = ambiguity_list[0];
+
+              for (; i < length; i += 1) {
+                  tz = ambiguity_list[i];
+
+                  if (jstz.date_is_dst(jstz.olson.dst_start_dates[tz])) {
+                      timezone_name = tz;
+                      return;
+                  }
+              }
+          },
+
+          /**
+           * Checks if it is possible that the timezone is ambiguous.
+           */
+          is_ambiguous = function () {
+              return typeof (jstz.olson.ambiguity_list[timezone_name]) !== 'undefined';
+          };
+
+
+
+      timezone_name = tz_name;
+      if (is_ambiguous()) {
+          ambiguity_check();
+      }
+
+      return {
+          name: name
+      };
+  };
+
+  jstz.olson = {};
+
+  /*
+   * The keys in this dictionary are comma separated as such:
+   *
+   * First the offset compared to UTC time in minutes.
+   *
+   * Then a flag which is 0 if the timezone does not take daylight savings into account and 1 if it
+   * does.
+   *
+   * Thirdly an optional 's' signifies that the timezone is in the southern hemisphere,
+   * only interesting for timezones with DST.
+   *
+   * The mapped arrays is used for constructing the jstz.TimeZone object from within
+   * jstz.determine_timezone();
+   */
+  jstz.olson.timezones = {
+      '-720,0'   : 'Etc/GMT+12',
+      '-660,0'   : 'Pacific/Pago_Pago',
+      '-600,1'   : 'America/Adak',
+      '-600,0'   : 'Pacific/Honolulu',
+      '-570,0'   : 'Pacific/Marquesas',
+      '-540,0'   : 'Pacific/Gambier',
+      '-540,1'   : 'America/Anchorage',
+      '-480,1'   : 'America/Los_Angeles',
+      '-480,0'   : 'Pacific/Pitcairn',
+      '-420,0'   : 'America/Phoenix',
+      '-420,1'   : 'America/Denver',
+      '-360,0'   : 'America/Guatemala',
+      '-360,1'   : 'America/Chicago',
+      '-360,1,s' : 'Pacific/Easter',
+      '-300,0'   : 'America/Bogota',
+      '-300,1'   : 'America/New_York',
+      '-270,0'   : 'America/Caracas',
+      '-240,1'   : 'America/Halifax',
+      '-240,0'   : 'America/Santo_Domingo',
+      '-240,1,s' : 'America/Santiago',
+      '-210,1'   : 'America/St_Johns',
+      '-180,1'   : 'America/Godthab',
+      '-180,0'   : 'America/Argentina/Buenos_Aires',
+      '-180,1,s' : 'America/Montevideo',
+      '-120,0'   : 'Etc/GMT+2',
+      '-120,1'   : 'Etc/GMT+2',
+      '-60,1'    : 'Atlantic/Azores',
+      '-60,0'    : 'Atlantic/Cape_Verde',
+      '0,0'      : 'Etc/UTC',
+      '0,1'      : 'Europe/London',
+      '60,1'     : 'Europe/Berlin',
+      '60,0'     : 'Africa/Lagos',
+      '60,1,s'   : 'Africa/Windhoek',
+      '120,1'    : 'Asia/Beirut',
+      '120,0'    : 'Africa/Johannesburg',
+      '180,0'    : 'Asia/Baghdad',
+      '180,1'    : 'Europe/Moscow',
+      '210,1'    : 'Asia/Tehran',
+      '240,0'    : 'Asia/Dubai',
+      '240,1'    : 'Asia/Baku',
+      '270,0'    : 'Asia/Kabul',
+      '300,1'    : 'Asia/Yekaterinburg',
+      '300,0'    : 'Asia/Karachi',
+      '330,0'    : 'Asia/Kolkata',
+      '345,0'    : 'Asia/Kathmandu',
+      '360,0'    : 'Asia/Dhaka',
+      '360,1'    : 'Asia/Omsk',
+      '390,0'    : 'Asia/Rangoon',
+      '420,1'    : 'Asia/Krasnoyarsk',
+      '420,0'    : 'Asia/Jakarta',
+      '480,0'    : 'Asia/Shanghai',
+      '480,1'    : 'Asia/Irkutsk',
+      '525,0'    : 'Australia/Eucla',
+      '525,1,s'  : 'Australia/Eucla',
+      '540,1'    : 'Asia/Yakutsk',
+      '540,0'    : 'Asia/Tokyo',
+      '570,0'    : 'Australia/Darwin',
+      '570,1,s'  : 'Australia/Adelaide',
+      '600,0'    : 'Australia/Brisbane',
+      '600,1'    : 'Asia/Vladivostok',
+      '600,1,s'  : 'Australia/Sydney',
+      '630,1,s'  : 'Australia/Lord_Howe',
+      '660,1'    : 'Asia/Kamchatka',
+      '660,0'    : 'Pacific/Noumea',
+      '690,0'    : 'Pacific/Norfolk',
+      '720,1,s'  : 'Pacific/Auckland',
+      '720,0'    : 'Pacific/Tarawa',
+      '765,1,s'  : 'Pacific/Chatham',
+      '780,0'    : 'Pacific/Tongatapu',
+      '780,1,s'  : 'Pacific/Apia',
+      '840,0'    : 'Pacific/Kiritimati'
+  };
+
+
+  /**
+   * This object contains information on when daylight savings starts for
+   * different timezones.
+   *
+   * The list is short for a reason. Often we do not have to be very specific
+   * to single out the correct timezone. But when we do, this list comes in
+   * handy.
+   *
+   * Each value is a date denoting when daylight savings starts for that timezone.
+   */
+  jstz.olson.dst_start_dates = {
+      'America/Denver' : new Date(2011, 2, 13, 3, 0, 0, 0),
+      'America/Mazatlan' : new Date(2011, 3, 3, 3, 0, 0, 0),
+      'America/Chicago' : new Date(2011, 2, 13, 3, 0, 0, 0),
+      'America/Mexico_City' : new Date(2011, 3, 3, 3, 0, 0, 0),
+      'America/Asuncion' : new Date(2012, 10, 7, 3, 0, 0, 0),
+      'America/Santiago' : new Date(2012, 9, 3, 3, 0, 0, 0),
+      'America/Campo_Grande' : new Date(2011, 9, 16, 5, 0, 0, 0),
+      'America/Montevideo' : new Date(2011, 9, 2, 3, 0, 0, 0),
+      'America/Sao_Paulo' : new Date(2011, 9, 16, 5, 0, 0, 0),
+      'America/Los_Angeles' : new Date(2011, 2, 13, 8, 0, 0, 0),
+      'America/Santa_Isabel' : new Date(2011, 3, 5, 8, 0, 0, 0),
+      'America/Havana' : new Date(2011, 2, 13, 2, 0, 0, 0),
+      'America/New_York' : new Date(2011, 2, 13, 7, 0, 0, 0),
+      'Asia/Gaza' : new Date(2011, 2, 26, 23, 0, 0, 0),
+      'Asia/Beirut' : new Date(2011, 2, 27, 1, 0, 0, 0),
+      'Europe/Helsinki' : new Date(2011, 2, 27, 4, 0, 0, 0),
+      'Europe/Istanbul' : new Date(2011, 2, 28, 5, 0, 0, 0),
+      'Asia/Damascus' : new Date(2011, 3, 1, 2, 0, 0, 0),
+      'Asia/Jerusalem' : new Date(2011, 3, 1, 6, 0, 0, 0),
+      'Africa/Cairo' : new Date(2010, 3, 30, 4, 0, 0, 0),
+      'Pacific/Auckland' : new Date(2011, 8, 26, 7, 0, 0, 0),
+      'Pacific/Fiji' : new Date(2010, 11, 29, 23, 0, 0, 0),
+      'America/Halifax' : new Date(2011, 2, 13, 6, 0, 0, 0),
+      'America/Goose_Bay' : new Date(2011, 2, 13, 2, 1, 0, 0),
+      'America/Miquelon' : new Date(2011, 2, 13, 5, 0, 0, 0),
+      'America/Godthab' : new Date(2011, 2, 27, 1, 0, 0, 0)
+  };
+
+  /**
+   * The keys in this object are timezones that we know may be ambiguous after
+   * a preliminary scan through the olson_tz object.
+   *
+   * The array of timezones to compare must be in the order that daylight savings
+   * starts for the regions.
+   */
+  jstz.olson.ambiguity_list = {
+      'America/Denver' : ['America/Denver', 'America/Mazatlan'],
+      'America/Chicago' : ['America/Chicago', 'America/Mexico_City'],
+      'America/Santiago' : ['America/Santiago', 'America/Asuncion', 'America/Campo_Grande'],
+      'America/Montevideo' : ['America/Montevideo', 'America/Sao_Paulo'],
+      'Asia/Beirut' : ['Asia/Gaza', 'Asia/Beirut', 'Europe/Helsinki', 'Europe/Istanbul', 'Asia/Damascus', 'Asia/Jerusalem', 'Africa/Cairo'],
+      'Pacific/Auckland' : ['Pacific/Auckland', 'Pacific/Fiji'],
+      'America/Los_Angeles' : ['America/Los_Angeles', 'America/Santa_Isabel'],
+      'America/New_York' : ['America/Havana', 'America/New_York'],
+      'America/Halifax' : ['America/Goose_Bay', 'America/Halifax'],
+      'America/Godthab' : ['America/Miquelon', 'America/Godthab']
+  };
+
+  if (typeof exports !== 'undefined') {
+    exports.jstz = jstz;
+  } else {
+    root.jstz = jstz;
+  }
+})(this);
+/*! jstz - v1.0.0 - 2012-12-11 */
+(function(e){var t=function(){"use strict";var e="s",n=function(e){var t=-e.getTimezoneOffset();return t!==null?t:0},r=function(e,t){var n=new Date;return n.setDate(t),n.setMonth(e),n},i=function(){return n(r(0,2))},s=function(){return n(r(5,2))},o=function(e){var t=e.getMonth()>5?s():i(),r=n(e);return t-r!==0},u=function(){var t=i(),n=s(),r=i()-s();return r<0?t+",1":r>0?n+",1,"+e:t+",0"},a=function(){var e=u();return new t.TimeZone(t.olson.timezones[e])};return{determine_timezone:function(){return typeof console!="undefined"&&console.log("jstz.determine_timezone() is deprecated and will be removed in an upcoming version. Please use jstz.determine() instead."),a()},determine:a,date_is_dst:o}}();t.TimeZone=function(e){"use strict";var n=null,r=function(){return n},i=function(){var e=t.olson.ambiguity_list[n],r=e.length,i=0,s=e[0];for(;i<r;i+=1){s=e[i];if(t.date_is_dst(t.olson.dst_start_dates[s])){n=s;return}}},s=function(){return typeof t.olson.ambiguity_list[n]!="undefined"};return n=e,s()&&i(),{name:r}},t.olson={},t.olson.timezones={"-720,0":"Etc/GMT+12","-660,0":"Pacific/Pago_Pago","-600,1":"America/Adak","-600,0":"Pacific/Honolulu","-570,0":"Pacific/Marquesas","-540,0":"Pacific/Gambier","-540,1":"America/Anchorage","-480,1":"America/Los_Angeles","-480,0":"Pacific/Pitcairn","-420,0":"America/Phoenix","-420,1":"America/Denver","-360,0":"America/Guatemala","-360,1":"America/Chicago","-360,1,s":"Pacific/Easter","-300,0":"America/Bogota","-300,1":"America/New_York","-270,0":"America/Caracas","-240,1":"America/Halifax","-240,0":"America/Santo_Domingo","-240,1,s":"America/Santiago","-210,1":"America/St_Johns","-180,1":"America/Godthab","-180,0":"America/Argentina/Buenos_Aires","-180,1,s":"America/Montevideo","-120,0":"Etc/GMT+2","-120,1":"Etc/GMT+2","-60,1":"Atlantic/Azores","-60,0":"Atlantic/Cape_Verde","0,0":"Etc/UTC","0,1":"Europe/London","60,1":"Europe/Berlin","60,0":"Africa/Lagos","60,1,s":"Africa/Windhoek","120,1":"Asia/Beirut","120,0":"Africa/Johannesburg","180,0":"Asia/Baghdad","180,1":"Europe/Moscow","210,1":"Asia/Tehran","240,0":"Asia/Dubai","240,1":"Asia/Baku","270,0":"Asia/Kabul","300,1":"Asia/Yekaterinburg","300,0":"Asia/Karachi","330,0":"Asia/Kolkata","345,0":"Asia/Kathmandu","360,0":"Asia/Dhaka","360,1":"Asia/Omsk","390,0":"Asia/Rangoon","420,1":"Asia/Krasnoyarsk","420,0":"Asia/Jakarta","480,0":"Asia/Shanghai","480,1":"Asia/Irkutsk","525,0":"Australia/Eucla","525,1,s":"Australia/Eucla","540,1":"Asia/Yakutsk","540,0":"Asia/Tokyo","570,0":"Australia/Darwin","570,1,s":"Australia/Adelaide","600,0":"Australia/Brisbane","600,1":"Asia/Vladivostok","600,1,s":"Australia/Sydney","630,1,s":"Australia/Lord_Howe","660,1":"Asia/Kamchatka","660,0":"Pacific/Noumea","690,0":"Pacific/Norfolk","720,1,s":"Pacific/Auckland","720,0":"Pacific/Tarawa","765,1,s":"Pacific/Chatham","780,0":"Pacific/Tongatapu","780,1,s":"Pacific/Apia","840,0":"Pacific/Kiritimati"},t.olson.dst_start_dates={"America/Denver":new Date(2011,2,13,3,0,0,0),"America/Mazatlan":new Date(2011,3,3,3,0,0,0),"America/Chicago":new Date(2011,2,13,3,0,0,0),"America/Mexico_City":new Date(2011,3,3,3,0,0,0),"America/Asuncion":new Date(2012,10,7,3,0,0,0),"America/Santiago":new Date(2012,9,3,3,0,0,0),"America/Campo_Grande":new Date(2011,9,16,5,0,0,0),"America/Montevideo":new Date(2011,9,2,3,0,0,0),"America/Sao_Paulo":new Date(2011,9,16,5,0,0,0),"America/Los_Angeles":new Date(2011,2,13,8,0,0,0),"America/Santa_Isabel":new Date(2011,3,5,8,0,0,0),"America/Havana":new Date(2011,2,13,2,0,0,0),"America/New_York":new Date(2011,2,13,7,0,0,0),"Asia/Gaza":new Date(2011,2,26,23,0,0,0),"Asia/Beirut":new Date(2011,2,27,1,0,0,0),"Europe/Helsinki":new Date(2011,2,27,4,0,0,0),"Europe/Istanbul":new Date(2011,2,28,5,0,0,0),"Asia/Damascus":new Date(2011,3,1,2,0,0,0),"Asia/Jerusalem":new Date(2011,3,1,6,0,0,0),"Africa/Cairo":new Date(2010,3,30,4,0,0,0),"Pacific/Auckland":new Date(2011,8,26,7,0,0,0),"Pacific/Fiji":new Date(2010,11,29,23,0,0,0),"America/Halifax":new Date(2011,2,13,6,0,0,0),"America/Goose_Bay":new Date(2011,2,13,2,1,0,0),"America/Miquelon":new Date(2011,2,13,5,0,0,0),"America/Godthab":new Date(2011,2,27,1,0,0,0)},t.olson.ambiguity_list={"America/Denver":["America/Denver","America/Mazatlan"],"America/Chicago":["America/Chicago","America/Mexico_City"],"America/Santiago":["America/Santiago","America/Asuncion","America/Campo_Grande"],"America/Montevideo":["America/Montevideo","America/Sao_Paulo"],"Asia/Beirut":["Asia/Gaza","Asia/Beirut","Europe/Helsinki","Europe/Istanbul","Asia/Damascus","Asia/Jerusalem","Africa/Cairo"],"Pacific/Auckland":["Pacific/Auckland","Pacific/Fiji"],"America/Los_Angeles":["America/Los_Angeles","America/Santa_Isabel"],"America/New_York":["America/Havana","America/New_York"],"America/Halifax":["America/Goose_Bay","America/Halifax"],"America/Godthab":["America/Miquelon","America/Godthab"]},typeof exports!="undefined"?exports.jstz=t:e.jstz=t})(this);
+{
+  "name": "jstz",
+  "description": "Detection of timezone in the browser.",
+  "version": "1.0.0"
+}

test/recurring_tester.sh

+#!/bin/bash
+while :
+do
+    clear
+    node run.js
+    sleep 1
+done
+var jstz = require("../jstz");
+
+function determine_current_timezone() {
+  var tz = jstz.jstz.determine();
+  console.log(tz.name());
+}
+
+determine_current_timezone();
+

test/smoke_tests.sh

+#!/bin/bash
+
+# This file is basically the documenation of the timezones that jstz
+# can successfully detect. Exluding the ambigous DST zones.
+#
+# Goes through all basic timezones (not ambiguated) and checks that they 
+# evaluate correctly. Take note that all russian timezones are excluded 
+# (even though they still exist in jstz.js to be compliant with computers
+# that have not been updated).
+#
+# Evaluates jstz.js by running it through node.js after having manually changed
+# the timezone of the system by copying the timezone to /etc/localtime.
+#
+
+timezones=( 'Pacific/Pago_Pago' 
+			'America/Adak'
+			'Pacific/Honolulu'
+			'Pacific/Marquesas'
+			'Pacific/Gambier'
+			'America/Anchorage'
+			'America/Los_Angeles'
+			'Pacific/Pitcairn'
+			'America/Phoenix'
+			'America/Denver'
+			'America/Guatemala'
+			'America/Chicago'
+			'Pacific/Easter'
+			'America/Bogota'
+			'America/New_York'
+			'America/Caracas'
+			'America/Halifax'
+			'America/Santo_Domingo'
+			'America/Santiago'
+			'America/St_Johns'
+			'America/Godthab'
+			'America/Argentina/Buenos_Aires'
+			'America/Montevideo'
+			'Etc/GMT+2'
+			'Atlantic/Azores'
+			'Atlantic/Cape_Verde'
+			'Etc/UTC'
+			'Europe/London'
+			'Europe/Berlin'
+			'Africa/Lagos'
+			'Africa/Windhoek'
+			'Asia/Beirut'
+			'Africa/Johannesburg'
+			'Asia/Baghdad'
+            'Asia/Tehran'
+			'Asia/Dubai'
+			'Asia/Baku'
+			'Asia/Kabul'
+            'Asia/Karachi'
+			'Asia/Kolkata'
+			'Asia/Kathmandu'
+			'Asia/Dhaka'
+			'Asia/Rangoon'
+			'Asia/Jakarta'
+			'Asia/Shanghai'
+			'Australia/Eucla'
+			'Asia/Tokyo'
+			'Australia/Darwin'
+			'Australia/Adelaide'
+			'Australia/Brisbane'
+			'Australia/Sydney'
+			'Pacific/Noumea'
+            'Pacific/Norfolk'
+			'Pacific/Auckland'
+			'Pacific/Tarawa'
+			'Pacific/Chatham'
+			'Pacific/Tongatapu'
+			'Pacific/Apia'
+			'Pacific/Kiritimati')
+
+failure_count=0
+for tz in "${timezones[@]}"
+do
+  cp "/usr/share/zoneinfo/$tz" "/etc/localtime"
+  test_result=$(node run.js)
+  if [[ "$test_result" != "$tz" ]] 
+  then
+    echo "Failure: $tz wrongly evaluates to $test_result!"
+    failure_count=$((failure_count + 1))
+  fi
+done
+
+echo "$failure_count failures"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.