TimeUtil.hh 2.17 KB
/**
 * TimeUtil.hh
 *
 *  Created on: 29 oct. 2012
 *      Author: AKKA IS
 */

#ifndef TIMEUTIL_HH_
#define TIMEUTIL_HH_

#include <iostream>
#include <string>

#include "DD_time.hh"

namespace AMDA {

/**
 * @class TimeUtil
 */
class TimeUtil {
	TimeUtil();
	virtual ~TimeUtil();
public:
	static void formatTimeInIso(const double time, std::ostream& pOs, t_DDTimeKind timeKind);

	static void formatTimeDateInIso(const double time, std::ostream& pOs) {
		formatTimeInIso(time, pOs, DD_TM_DATE);
	}
	static void formatTimeIntervalInIso(const double time, std::ostream& pOs) {
		formatTimeInIso(time, pOs, DD_TM_TIME_INTERVAL);
	}

	static std::string formatTimeInIso(const double time, t_DDTimeKind timeKind);
	static std::string formatTimeDateInIso(const double time) {
		return formatTimeInIso(time, DD_TM_DATE);
	}
	static void formatTimeDateWithSpaces(const double time , std::ostream& pOs);
	static std::string formatTimeIntervalInIso(const double time) {
		return formatTimeInIso(time, DD_TM_TIME_INTERVAL);
	}

	static double readTimeInIso(char *stime);

	static void double2DD_Time(const double time, std::ostream& pOs, t_DDTimeKind timeKind );
	static void double2DD_TimeDate(const double time, std::ostream& pOs) {
		double2DD_Time(time, pOs, DD_TM_DATE);
	}
	static void double2DD_TimeInterval(const double time, std::ostream& pOs){
		double2DD_Time(time, pOs, DD_TM_TIME_INTERVAL);
	}

	static std::string double2DD_Time(const double time, t_DDTimeKind timeKind);
	static std::string double2DD_TimeDate(const double time) {
		return double2DD_Time(time, DD_TM_DATE);
	}
	static std::string double2DD_TimeInterval(const double time){
		return double2DD_Time(time,  DD_TM_TIME_INTERVAL);
	}

	static std::string DD2ISO_Time(std::string time, t_DDTimeKind timeKind );
	static std::string DD2ISO_TimeDate(std::string time) {
		return DD2ISO_Time(time, DD_TM_DATE);
	}
	static std::string DD2ISO_TimeInterval(std::string time) {
		return DD2ISO_Time(time, DD_TM_TIME_INTERVAL);
	}

//	static std::string DD2ISO_IntervalTime(std::string time, t_DDTimeKind timeKind) {
//		return DD2ISO_Time((time , DD_TM_TIME_INTERVAL);
//	}

private:
	static int monthday[2][12];
};

} /* namespace AMDA */
#endif /* TIMEUTIL_HH_ */