"""
API
Time Request API

Time API Wrapper using Python and WorldTimeAPI.org
"""

import requests

class API:
    json:dict = None
    city:str = None

    date:str = None
    time:str = None

    reqs:int = 0

    def __init__(self, timezone:str) -> None:
        self.city = timezone

    def update(self) -> None:
        """
        Sends a request to WorldTimeAPI.org, updates time information.
        """

        session = requests.get(f"https://worldtimeAPI.org/api/timezone/{self.city}")
        if session.status_code == 404:
            raise requests.RequestException("404: Time Zone Information not Found")

        elif session.status_code == 200:
            self.reqs += 1
            self.json = session.json()
            self.date = self.json["datetime"].split("T")[0]
            self.time = self.json["datetime"].split("T")[1].split("-")[0]

        else:
            raise requests.RequestException(f"{session.status_code}")

    def requestSpeed(self) -> None:
        print("Results may vary based on CPU speed, network speed, etc.")
        self.update()
        iTime = self.json["unixtime"]

        while True:
            self.update()
            ssi = self.json["unixtime"] - iTime+0.01 # Seconds Since Initial
            rs = round(self.reqs/ssi)
            print(f"Date: {self.date} | Time: {self.time} | City: {self.city} | Updates: {self.reqs} | Time Since Initial: {ssi} | Update Speed: {rs}rs", end="\r")


class timezones:
    """
    All available timezones
    """
    class AFRICA:
        ABIDJAN = "Africa/Abidjan"
        ACCRA = "Africa/Accra"
        ALGIERS = "Africa/Algiers"
        BISSAU = "Africa/Bissau"
        CAIRO = "Africa/Cairo"
        CASABLANCA = "Africa/Casablanca"
        CEUTA = "Africa/Ceuta"
        EL_AAIUN = "Africa/El_Aaiun"
        JOHANNESBURG = "Africa/Johannesburg"
        JUBA = "Africa/Juba"
        KHARTOUM = "Africa/Khartoum"
        LAGOS = "Africa/Lagos"
        MAPUTO = "Africa/Maputo"
        MONROVIA = "Africa/Monrovia"
        NAIROBI = "Africa/Nairobi"
        NDJAMENA = "Africa/Ndjamena"
        SAO_TOME = "Africa/Sao_Tome"
        TRIPOLI = "Africa/Tripoli"
        TUNIS = "Africa/Tunis"
        WINDHOEK = "Africa/Windhoek"

    class AMERICA:
        ADAK = "America/Adak"
        ANCHORAGE = "America/Anchorage"
        ARAGUAINA = "America/Araguaina"
        BUENOS_AIRES = "America/Argentina/Buenos_Aires"
        CATAMARCA = "America/Argentina/Catamarca"
        CORDOBA = "America/Argentina/Cordoba"
        JUJUY = "America/Argentina/Jujuy"
        LA_RIOJA = "America/Argentina/La_Rioja"
        MENDOZA = "America/Argentina/Mendoza"
        RIO_GALLEGOS = "America/Argentina/Rio_Gallegos"
        SALTA = "America/Argentina/Salta"
        SAN_JUAN = "America/Argentina/San_Juan"
        SAN_LUIS = "America/Argentina/San_Luis"
        TUCUMAN = "America/Argentina/Tucuman"
        USHUAIA = "America/Argentina/Ushuaia"
        ASUNCION = "America/Asuncion"
        ATIKOKAN = "America/Atikokan"
        BAHIA = "America/Bahia"
        BAHIA_BANDERAS = "America/Bahia_Banderas"
        BARBADOS = "America/Barbados"
        BELEM = "America/Belem"
        BELIZE = "America/Belize"
        BLANC_SABLON = "America/Blanc-Sablon"
        BOA_VISTA = "America/Boa_Vista"
        BOGOTA = "America/Bogota"
        BOISE = "America/Boise"
        CAMBRIDGE_BAY = "America/Cambridge_Bay"
        CAMPO_GRANDE = "America/Campo_Grande"
        CANCUN = "America/Cancun"
        CARACAS = "America/Caracas"
        CAYENNE = "America/Cayenne"
        CHICAGO = "America/Chicago"
        CHIHUAHUA = "America/Chihuahua"
        COSTA_RICA = "America/Costa_Rica"
        CRESTON = "America/Creston"
        CUIABA = "America/Cuiaba"
        CURACAO = "America/Curacao"
        DANMARKSHAVN = "America/Danmarkshavn"
        DAWSON = "America/Dawson"
        DAWSON_CREEK = "America/Dawson_Creek"
        DENVER = "America/Denver"
        DETROIT = "America/Detroit"
        EDMONTON = "America/Edmonton"
        EIRUNEPE = "America/Eirunepe"
        EL_SALVADOR = "America/El_Salvador"
        FORT_NELSON = "America/Fort_Nelson"
        FORTALEZA = "America/Fortaleza"
        GLACE_BAY = "America/Glace_Bay"
        GOOSE_BAY = "America/Goose_Bay"
        GRAND_TURK = "America/Grand_Turk"
        GUATEMALA = "America/Guatemala"
        GUAYAQUIL = "America/Guayaquil"
        GUYANA = "America/Guyana"
        HALIFAX = "America/Halifax"
        HAVANA = "America/Havana"
        HERMOSILLO = "America/Hermosillo"
        INDIANAPOLIS = "America/Indiana/Indianapolis"
        KNOX = "America/Indiana/Knox"
        MARENGO = "America/Indiana/Marengo"
        PETERSBURG = "America/Indiana/Petersburg"
        TELL_CITY = "America/Indiana/Tell_City"
        VEVAY = "America/Indiana/Vevay"
        VINCENNES = "America/Indiana/Vincennes"
        WINAMAC = "America/Indiana/Winamac"
        INUVIK = "America/Inuvik"
        IQALUIT = "America/Iqaluit"
        JAMAICA = "America/Jamaica"
        JUNEAU = "America/Juneau"
        LOUISVILLE = "America/Kentucky/Louisville"
        MONTICELLO = "America/Kentucky/Monticello"
        LA_PAZ = "America/La_Paz"
        LIMA = "America/Lima"
        LOS_ANGELES = "America/Los_Angeles"
        MACEIO = "America/Maceio"
        MANAGUA = "America/Managua"
        MANAUS = "America/Manaus"
        MARTINIQUE = "America/Martinique"
        MATAMOROS = "America/Matamoros"
        MAZATLAN = "America/Mazatlan"
        MENOMINEE = "America/Menominee"
        MERIDA = "America/Merida"
        METLAKATLA = "America/Metlakatla"
        MEXICO_CITY = "America/Mexico_City"
        MIQUELON = "America/Miquelon"
        MONCTON = "America/Moncton"
        MONTERREY = "America/Monterrey"
        MONTEVIDEO = "America/Montevideo"
        NASSAU = "America/Nassau"
        NEW_YORK = "America/New_York"
        NIPIGON = "America/Nipigon"
        NOME = "America/Nome"
        NORONHA = "America/Noronha"
        BEULAH = "America/North_Dakota/Beulah"
        CENTER = "America/North_Dakota/Center"
        NEW_SALEM = "America/North_Dakota/New_Salem"
        NUUK = "America/Nuuk"
        OJINAGA = "America/Ojinaga"
        PANAMA = "America/Panama"
        PANGNIRTUNG = "America/Pangnirtung"
        PARAMARIBO = "America/Paramaribo"
        PHOENIX = "America/Phoenix"
        PORT_AU_PRINCE = "America/Port-au-Prince"
        PORT_OF_SPAIN = "America/Port_of_Spain"
        PORTO_VELHO = "America/Porto_Velho"
        PUERTO_RICO = "America/Puerto_Rico"
        PUNTA_ARENAS = "America/Punta_Arenas"
        RAINY_RIVER = "America/Rainy_River"
        RANKIN_INLET = "America/Rankin_Inlet"
        RECIFE = "America/Recife"
        REGINA = "America/Regina"
        RESOLUTE = "America/Resolute"
        RIO_BRANCO = "America/Rio_Branco"
        SANTAREM = "America/Santarem"
        SANTIAGO = "America/Santiago"
        SANTO_DOMINGO = "America/Santo_Domingo"
        SAO_PAULO = "America/Sao_Paulo"
        SCORESBYSUND = "America/Scoresbysund"
        SITKA = "America/Sitka"
        ST_JOHNS = "America/St_Johns"
        SWIFT_CURRENT = "America/Swift_Current"
        TEGUCIGALPA = "America/Tegucigalpa"
        THULE = "America/Thule"
        THUNDER_BAY = "America/Thunder_Bay"
        TIJUANA = "America/Tijuana"
        TORONTO = "America/Toronto"
        VANCOUVER = "America/Vancouver"
        WHITEHORSE = "America/Whitehorse"
        WINNIPEG = "America/Winnipeg"
        YAKUTAT = "America/Yakutat"
        YELLOWKNIFE = "America/Yellowknife"


    class ANTARCTICA:
        CASEY = "Antarctica/Casey"
        DAVIS = "Antarctica/Davis"
        DUMONTDURVILLE = "Antarctica/DumontDUrville"
        MACQUARIE = "Antarctica/Macquarie"
        MAWSON = "Antarctica/Mawson"
        PALMER = "Antarctica/Palmer"
        ROTHERA = "Antarctica/Rothera"
        SYOWA = "Antarctica/Syowa"
        TROLL = "Antarctica/Troll"
        VOSTOK = "Antarctica/Vostok"

    class ASIA:
        ALMATY = "Asia/Almaty"
        AMMAN = "Asia/Amman"
        ANADYR = "Asia/Anadyr"
        AQTAU = "Asia/Aqtau"
        AQTOBE = "Asia/Aqtobe"
        ASHGABAT = "Asia/Ashgabat"
        ATYRAU = "Asia/Atyrau"
        BAGHDAD = "Asia/Baghdad"
        BAKU = "Asia/Baku"
        BANGKOK = "Asia/Bangkok"
        BARNAUL = "Asia/Barnaul"
        BEIRUT = "Asia/Beirut"
        BISHKEK = "Asia/Bishkek"
        BRUNEI = "Asia/Brunei"
        CHITA = "Asia/Chita"
        CHOIBALSAN = "Asia/Choibalsan"
        COLOMBO = "Asia/Colombo"
        DAMASCUS = "Asia/Damascus"
        DHAKA = "Asia/Dhaka"
        DILI = "Asia/Dili"
        DUBAI = "Asia/Dubai"
        DUSHANBE = "Asia/Dushanbe"
        FAMAGUSTA = "Asia/Famagusta"
        GAZA = "Asia/Gaza"
        HEBRON = "Asia/Hebron"
        HO_CHI_MINH = "Asia/Ho_Chi_Minh"
        HONG_KONG = "Asia/Hong_Kong"
        HOVD = "Asia/Hovd"
        IRKUTSK = "Asia/Irkutsk"
        JAKARTA = "Asia/Jakarta"
        JAYAPURA = "Asia/Jayapura"
        JERUSALEM = "Asia/Jerusalem"
        KABUL = "Asia/Kabul"
        KAMCHATKA = "Asia/Kamchatka"
        KARACHI = "Asia/Karachi"
        KATHMANDU = "Asia/Kathmandu"
        KHANDYGA = "Asia/Khandyga"
        KOLKATA = "Asia/Kolkata"
        KRASNOYARSK = "Asia/Krasnoyarsk"
        KUALA_LUMPUR = "Asia/Kuala_Lumpur"
        KUCHING = "Asia/Kuching"
        MACAU = "Asia/Macau"
        MAGADAN = "Asia/Magadan"
        MAKASSAR = "Asia/Makassar"
        MANILA = "Asia/Manila"
        NICOSIA = "Asia/Nicosia"
        NOVOKUZNETSK = "Asia/Novokuznetsk"
        NOVOSIBIRSK = "Asia/Novosibirsk"
        OMSK = "Asia/Omsk"
        ORAL = "Asia/Oral"
        PONTIANAK = "Asia/Pontianak"
        PYONGYANG = "Asia/Pyongyang"
        QATAR = "Asia/Qatar"
        QOSTANAY = "Asia/Qostanay"
        QYZYLORDA = "Asia/Qyzylorda"
        RIYADH = "Asia/Riyadh"
        SAKHALIN = "Asia/Sakhalin"
        SAMARKAND = "Asia/Samarkand"
        SEOUL = "Asia/Seoul"
        SHANGHAI = "Asia/Shanghai"
        SINGAPORE = "Asia/Singapore"
        SREDNEKOLYMSK = "Asia/Srednekolymsk"
        TAIPEI = "Asia/Taipei"
        TASHKENT = "Asia/Tashkent"
        TBILISI = "Asia/Tbilisi"
        TEHRAN = "Asia/Tehran"
        THIMPHU = "Asia/Thimphu"
        TOKYO = "Asia/Tokyo"
        TOMSK = "Asia/Tomsk"
        ULAANBAATAR = "Asia/Ulaanbaatar"
        URUMQI = "Asia/Urumqi"
        UST_NERA = "Asia/Ust-Nera"
        VLADIVOSTOK = "Asia/Vladivostok"
        YAKUTSK = "Asia/Yakutsk"
        YANGON = "Asia/Yangon"
        YEKATERINBURG = "Asia/Yekaterinburg"
        YEREVAN = "Asia/Yerevan"

    class ATLANTIC:
        AZORES = "Atlantic/Azores"
        BERMUDA = "Atlantic/Bermuda"
        CANARY = "Atlantic/Canary"
        CAPE_VERDE = "Atlantic/Cape_Verde"
        FAROE = "Atlantic/Faroe"
        MADEIRA = "Atlantic/Madeira"
        REYKJAVIK = "Atlantic/Reykjavik"
        SOUTH_GEORGIA = "Atlantic/South_Georgia"
        STANLEY = "Atlantic/Stanley"

    class AUSTRALIA:
        ADELAIDE = "Australia/Adelaide"
        BRISBANE = "Australia/Brisbane"
        BROKEN_HILL = "Australia/Broken_Hill"
        DARWIN = "Australia/Darwin"
        EUCLA = "Australia/Eucla"
        HOBART = "Australia/Hobart"
        LINDEMAN = "Australia/Lindeman"
        LORD_HOWE = "Australia/Lord_Howe"
        MELBOURNE = "Australia/Melbourne"
        PERTH = "Australia/Perth"
        SYDNEY = "Australia/Sydney"

    class EUROPE:
        AMSTERDAM = "Europe/Amsterdam"
        ANDORRA = "Europe/Andorra"
        ASTRAKHAN = "Europe/Astrakhan"
        ATHENS = "Europe/Athens"
        BELGRADE = "Europe/Belgrade"
        BERLIN = "Europe/Berlin"
        BRUSSELS = "Europe/Brussels"
        BUCHAREST = "Europe/Bucharest"
        BUDAPEST = "Europe/Budapest"
        CHISINAU = "Europe/Chisinau"
        COPENHAGEN = "Europe/Copenhagen"
        DUBLIN = "Europe/Dublin"
        GIBRALTAR = "Europe/Gibraltar"
        HELSINKI = "Europe/Helsinki"
        ISTANBUL = "Europe/Istanbul"
        KALININGRAD = "Europe/Kaliningrad"
        KIEV = "Europe/Kiev"
        KIROV = "Europe/Kirov"
        LISBON = "Europe/Lisbon"
        LONDON = "Europe/London"
        LUXEMBOURG = "Europe/Luxembourg"
        MADRID = "Europe/Madrid"
        MALTA = "Europe/Malta"
        MINSK = "Europe/Minsk"
        MONACO = "Europe/Monaco"
        MOSCOW = "Europe/Moscow"
        OSLO = "Europe/Oslo"
        PARIS = "Europe/Paris"
        PRAGUE = "Europe/Prague"
        RIGA = "Europe/Riga"
        ROME = "Europe/Rome"
        SAMARA = "Europe/Samara"
        SARATOV = "Europe/Saratov"
        SIMFEROPOL = "Europe/Simferopol"
        SOFIA = "Europe/Sofia"
        STOCKHOLM = "Europe/Stockholm"
        TALLINN = "Europe/Tallinn"
        TIRANE = "Europe/Tirane"
        ULYANOVSK = "Europe/Ulyanovsk"
        UZHGOROD = "Europe/Uzhgorod"
        VIENNA = "Europe/Vienna"
        VILNIUS = "Europe/Vilnius"
        VOLGOGRAD = "Europe/Volgograd"
        WARSAW = "Europe/Warsaw"
        ZAPOROZHYE = "Europe/Zaporozhye"
        ZURICH = "Europe/Zurich"

    class INDIAN:
        CHAGOS = "Indian/Chagos"
        CHRISTMAS = "Indian/Christmas"
        COCOS = "Indian/Cocos"
        KERGUELEN = "Indian/Kerguelen"
        MAHE = "Indian/Mahe"
        MALDIVES = "Indian/Maldives"
        MAURITIUS = "Indian/Mauritius"
        REUNION = "Indian/Reunion"

    class PACIFIC:
        APIA = "Pacific/APIa"
        AUCKLAND = "Pacific/Auckland"
        BOUGAINVILLE = "Pacific/Bougainville"
        CHATHAM = "Pacific/Chatham"
        CHUUK = "Pacific/Chuuk"
        EASTER = "Pacific/Easter"
        EFATE = "Pacific/Efate"
        ENDERBURY = "Pacific/Enderbury"
        FAKAOFO = "Pacific/Fakaofo"
        FIJI = "Pacific/Fiji"
        FUNAFUTI = "Pacific/Funafuti"
        GALAPAGOS = "Pacific/Galapagos"
        GAMBIER = "Pacific/Gambier"
        GUADALCANAL = "Pacific/Guadalcanal"
        GUAM = "Pacific/Guam"
        HONOLULU = "Pacific/Honolulu"
        KIRITIMATI = "Pacific/Kiritimati"
        KOSRAE = "Pacific/Kosrae"
        KWAJALEIN = "Pacific/Kwajalein"
        MAJURO = "Pacific/Majuro"
        MARQUESAS = "Pacific/Marquesas"
        NAURU = "Pacific/Nauru"
        NIUE = "Pacific/Niue"
        NORFOLK = "Pacific/Norfolk"
        NOUMEA = "Pacific/Noumea"
        PAGO_PAGO = "Pacific/Pago_Pago"
        PALAU = "Pacific/Palau"
        PITCAIRN = "Pacific/Pitcairn"
        POHNPEI = "Pacific/Pohnpei"
        PORT_MORESBY = "Pacific/Port_Moresby"
        RAROTONGA = "Pacific/Rarotonga"
        TAHITI = "Pacific/Tahiti"
        TARAWA = "Pacific/Tarawa"
        TONGATAPU = "Pacific/Tongatapu"
        WAKE = "Pacific/Wake"
        WALLIS = "Pacific/Wallis"

    class OTHER:
        WET = "WET"
        MET = "MET"
        MST = "MST"
        MST7MDT = "MST7MDT"
        PST8PDT = "PST8PDT"
        CET = "CET"
        CST6CDT = "CST6CDT"
        EET = "EET"
        EST = "EST"
        EST5EDT = "EST5EDT"
        GMT = "Etc/GMT"
        GMT_1 = "Etc/GMT-1"
        GMT_10 = "Etc/GMT-10"
        GMT_11 = "Etc/GMT-11"
        GMT_12 = "Etc/GMT-12"
        GMT_2 = "Etc/GMT-2"
        GMT_3 = "Etc/GMT-3"
        GMT_4 = "Etc/GMT-4"
        GMT_5 = "Etc/GMT-5"
        GMT_6 = "Etc/GMT-6"
        GMT_7 = "Etc/GMT-7"
        GMT_8 = "Etc/GMT-8"
        GMT_9 = "Etc/GMT-9"
        UTC = "Etc/UTC"