/*
Copyright (c) 2000 Benjamin Crowell,
2008 Kostas Giannakakis. All rights reserved.
About the GPL License
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace PlanetFinder
{
class TimezoneList
{
static private double [] timezones =
{-12, -11, -10, -9, -8, -7,-6, -5, -4.5, -4, -3.5, -3, -2, -1,
0, 1, 2, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 8, 9, 9.5,
10, 11, 12, 13};
public static int GmtIndex = 14;
public TimezoneList()
{
}
public int GetTimezonesCount() {
return timezones.Length;
}
public double GetTimezone(int index) {
if (index >=0 && index < timezones.Length) {
return timezones[index];
}
throw new IndexOutOfRangeException("Not such timezone");
}
public String GetTimezoneName(int index) {
if (index >=0 && index < timezones.Length) {
double tz = timezones[index];
if (tz == 0) {
return "GMT";
}
int hours = (int) tz;
int minutes = (int) ((tz - hours) * 60);
if (minutes < 0) minutes = - minutes;
return String.Format("GMT {0}{1:00}:{2:00}",
hours > 0 ? "+" : "",
hours, minutes);
}
throw new IndexOutOfRangeException("Not such timezone");
}
}
}