#!/usr/bin/php -q
<?php

// Copyright (c) 1997-now, NeoNova BV, The Netherlands. All rights Reserved.
//
// This software is the copyrighted work of NeoNova BV.
// Use of the software is subject to the general business terms and conditions of NeoNova BV
// and its related transaction documents like license sheets or other written notices.#
// Any reproduction or redistribution of the software not in accordance with the license terms
// is expressly prohibited by law, and may result in severe civil and criminally penalties.
// Violators will be prosecuted to the maximum extent possible.

include "/usr/local/astium/web/php/cms/db.php";
include "/usr/local/astium/web/php/config.php";

  $cms = new DB_CMS;

  $cms->query("select distinct zonedst.timezone, zonedst.tz, zonedst.isdst, zonedst.gmtoff, zonetab.isocode, country.name, zonetab.comments 
                 from zonedst left join zonetab on zonetab.timezone = zonedst.timezone 
                              left join country on country.isocode = zonetab.isocode 
                where zonedst.isdst = 'no'
                order by zonedst.timezone");
  while ($cms->next_record()) {
    $timezone = $cms->f('timezone');
    $tz = $cms->f('tz');
    $isdst = $cms->f('isdst');
    $isocode = $cms->f('isocode');
    $name = $cms->f('name');
    $comments = $cms->f('comments');
    $gmtoff = $cms->f('gmtoff') / 3600;
    
    if (strpos($name, "Australian External Territories") !== false) continue; // dupes
    if (strpos($name, "French Antilles") !== false) continue; // dupes
    if (strpos($name, "French Guiana") !== false) continue; // dupes
    if (strpos($name, "Mayotte and Reunion") !== false) continue; // dupes
    if (strpos($name, "Tokelau") !== false) continue; // dupes

    if ($gmtoff == 0) {
      $off = "(GMT)";
    } else if ($gmtoff > 0) {
      $off = sprintf("(GMT+%d)", $gmtoff);
    } else {
      $off = sprintf("(GMT%d)",  $gmtoff);
    }
    $tzname = sprintf("\"%s\":", $timezone);
    $comments = strlen($comments) > 0 ? "($comments)" : '';
    printf("  case %-34s  // %-5.5s %-8.8s  %-2s  %s %s\n", $tzname, $tz, $off, $isocode, $name, $comments);
  }
?>
