 class TimeZone
 
-  constructor: (key, @name = '') ->
-    if key
-      @name = TIMEZONES[key]
+  constructor: (keyOrProperties) ->
+    if typeof(keyOrProperties) == 'string'
+      zone = TIMEZONES[keyOrProperties]
+      @[property] = value for own property, value of zone
       @resolveAmbiguity()
+    else
+      @[property] = value for own property, value of keyOrProperties
 
   resolveAmbiguity: ->
     ambiguous = AMBIGIOUS_ZONES[@name]

        @name = value
        return

class Temporal

  @detect: (@username = null, @callback = null) =>
    navigator.geolocation.getCurrentPosition(@geoSuccess, ->) if @username and navigator.geolocation
    @fallback()

  @geoSuccess: (position) =>
    window[JSONP_CALLBACK] = @parseGeoResponse

  'America/Miquelon': new Date(2011, 2, 13, 5, 0, 0, 0)
  'America/Godthab': new Date(2011, 2, 27, 1, 0, 0, 0)
TIMEZONES =
  '-720,0':   {offset: -12,   name: 'Etc/GMT+12'}
  '-660,0':   {offset: -11,   name: 'Pacific/Pago_Pago'}
  '-600,1':   {offset: -11,   name: 'America/Adak'}
  '-660,1,s': {offset: -11,   name: 'Pacific/Apia'}
  '-600,0':   {offset: -10,   name: 'Pacific/Honolulu'}
  '-570,0':   {offset: -10.5, name: 'Pacific/Marquesas'}
  '-540,0':   {offset: -9,    name: 'Pacific/Gambier'}
  '-540,1':   {offset: -9,    name: 'America/Anchorage'}
  '-480,1':   {offset: -8,    name: 'America/Los_Angeles'}
  '-480,0':   {offset: -8,    name: 'Pacific/Pitcairn'}
  '-420,0':   {offset: -7,    name: 'America/Phoenix'}
  '-420,1':   {offset: -7,    name: 'America/Denver'}
  '-360,0':   {offset: -6,    name: 'America/Guatemala'}
  '-360,1':   {offset: -6,    name: 'America/Chicago'}
  '-360,1,s': {offset: -6,    name: 'Pacific/Easter'}
  '-300,0':   {offset: -5,    name: 'America/Bogota'}
  '-300,1':   {offset: -5,    name: 'America/New_York'}
  '-270,0':   {offset: -4.5,  name: 'America/Caracas'}
  '-240,1':   {offset: -4,    name: 'America/Halifax'}
  '-240,0':   {offset: -4,    name: 'America/Santo_Domingo'}
  '-240,1,s': {offset: -4,    name: 'America/Asuncion'}
  '-210,1':   {offset: -3.5,  name: 'America/St_Johns'}
  '-180,1':   {offset: -3,    name: 'America/Godthab'}
  '-180,0':   {offset: -3,    name: 'America/Argentina/Buenos_Aires,'}
  '-180,1,s': {offset: -3,    name: 'America/Montevideo'}
  '-120,0':   {offset: -2,    name: 'America/Noronha'}
  '-120,1':   {offset: -2,    name: 'Etc/GMT+2'}
  '-60,1':    {offset: -1,    name: 'Atlantic/Azores'}
  '-60,0':    {offset: -1,    name: 'Atlantic/Cape_Verde'}
  '0,0':      {offset: 0,     name: 'Africa/Casablanca'}
  '0,1':      {offset: 0,     name: 'Europe/London'}
  '60,1':     {offset: 1,     name: 'Europe/Berlin'}
  '60,0':     {offset: 1,     name: 'Africa/Lagos'}
  '60,1,s':   {offset: 1,     name: 'Africa/Windhoek'}
  '120,1':    {offset: 2,     name: 'Asia/Beirut'}
  '120,0':    {offset: 2,     name: 'Africa/Johannesburg'}
  '180,1':    {offset: 3,     name: 'Europe/Moscow'}
  '180,0':    {offset: 3,     name: 'Asia/Baghdad'}
  '210,1':    {offset: 3.5,   name: 'Asia/Tehran'}
  '240,0':    {offset: 4,     name: 'Asia/Dubai'}
  '240,1':    {offset: 4,     name: 'Asia/Yerevan'}
  '270,0':    {offset: 4.5,   name: 'Asia/Kabul'}
  '300,1':    {offset: 5,     name: 'Asia/Yekaterinburg'}
  '300,0':    {offset: 5,     name: 'Asia/Karachi'}
  '330,0':    {offset: 5,     name: 'Asia/Kolkata'}
  '345,0':    {offset: 5.75,  name: 'Asia/Kathmandu'}
  '360,0':    {offset: 6,     name: 'Asia/Dhaka'}
  '360,1':    {offset: 6,     name: 'Asia/Omsk'}
  '390,0':    {offset: 6,     name: 'Asia/Rangoon'}
  '420,1':    {offset: 7,     name: 'Asia/Krasnoyarsk'}
  '420,0':    {offset: 7,     name: 'Asia/Jakarta'}
  '480,0':    {offset: 8,     name: 'Asia/Shanghai'}
  '480,1':    {offset: 8,     name: 'Asia/Irkutsk'}
  '525,0':    {offset: 8.75,  name: 'Australia/Eucla'}
  '525,1,s':  {offset: 8.75,  name: 'Australia/Eucla'}
  '540,1':    {offset: 9,     name: 'Asia/Yakutsk'}
  '540,0':    {offset: 9,     name: 'Asia/Tokyo'}
  '570,0':    {offset: 9.5,   name: 'Australia/Darwin'}
  '570,1,s':  {offset: 9.5,   name: 'Australia/Adelaide'}
  '600,0':    {offset: 10,    name: 'Australia/Brisbane'}
  '600,1':    {offset: 10,    name: 'Asia/Vladivostok'}
  '600,1,s':  {offset: 10,    name: 'Australia/Sydney'}
  '630,1,s':  {offset: 10.5,  name: 'Australia/Lord_Howe'}
  '660,1':    {offset: 11,    name: 'Asia/Kamchatka'}
  '660,0':    {offset: 11,    name: 'Pacific/Noumea'}
  '690,0':    {offset: 11.5,  name: 'Pacific/Norfolk'}
  '720,1,s':  {offset: 12,    name: 'Pacific/Auckland'}
  '720,0':    {offset: 12,    name: 'Pacific/Tarawa'}
  '765,1,s':  {offset: 12.75, name: 'Pacific/Chatham'}
  '780,0':    {offset: 13,    name: 'Pacific/Tongatapu'}
  '840,0':    {offset: 14,    name: 'Pacific/Kiritimati'}

@Temporal = {detect: Temporal.detect}
