#ifndef TIME_SERVER_H
#define TIME_SERVER_H

	#include "HttpUrl.h"
	#include "Clock.h"

	#define HTTP_DATE_LENGTH 25

	/**
	 * object to represent a time server
	 */
	typedef struct TimeServer
	{
		/**
		 * url that represents the server to connect to
		 */
		HttpUrl url;
		
		/**
		 * times on the webserver comes in GMT
		 * so we need to calculate the offset to our local timezone
		 * value is in seconds
		 */
		int gmt_offset;

		/**
		 * get offset of local time to the time servers time
		 * if an error occurs 0 is returned (means no offset)
		 */
		double (*getOffset)(struct TimeServer *server, Clock *clock);
	} TimeServer;
	
	/**
	 * before using a TimeServer object
	 * call this function!
	 */
	void initTimeServer(TimeServer *server);

	/**
	 * collection of time servers
	 */
	#define MAX_TIME_SERVERS 10
	typedef struct
	{
		int count;
		TimeServer server[MAX_TIME_SERVERS];
	} TimeServers;

#endif

