#ifndef NTPtime_h
#define NTPtime_h

#include <WiFiUdp.h>

struct strDateTime {
  byte hour;
  byte minute;
  byte second;
  int year;
  byte month;
  byte day;
  byte dayofWeek;
  boolean valid;
};


class NTPtime {
  public:
    NTPtime(String NTPtime);
    strDateTime dt = {0};

    strDateTime getNTPtime(float _timeZone, boolean _DayLightSaving);

    void updateNTPtime();

    bool setSendInterval(unsigned long _sendInterval);  // in seconds
    bool setRecvTimeout(unsigned long _recvTimeout);    // in seconds

    static boolean summerTime(unsigned long _timeStamp );
    static strDateTime ConvertUnixTimestamp( unsigned long _tempTimeStamp);
    static boolean daylightSavingTime(unsigned long _timeStamp);
    static unsigned long adjustTimeZone(unsigned long _timeStamp, float _timeZone, byte _DayLightSavingSaving);

  private:

    bool _sendPhase;
    unsigned long _sentTime;
    unsigned long _sendInterval;
    unsigned long _recvTimeout;

    WiFiUDP UDPNTPClient;
};
#endif