import adafruit_connection_manager
import adafruit_ntp
import os
import time
import wifi
 


wifi_ssid = os.getenv("CIRCUITPY_WIFI_SSID")
wifi_password = os.getenv("CIRCUITPY_WIFI_PASSWORD")
wifi.radio.connect(wifi_ssid, wifi_password)

pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ntp = adafruit_ntp.NTP(pool, tz_offset=-5, cache_seconds=3600)

while True:
    print(ntp.datetime)
    
    myTime = {'year':ntp.datetime.tm_year,
              'month': ntp.datetime.tm_mon,
              'day': ntp.datetime.tm_mday,
              'hour': ntp.datetime.tm_hour,
              'min': ntp.datetime.tm_min,
              'sec': ntp.datetime.tm_sec
              }
    print(myTime)

    time.sleep(10)
#    break
    
    