/** * TimeUtil.hh * * Created on: 29 oct. 2012 * Author: AKKA IS */ #ifndef TIMEUTIL_HH_ #define TIMEUTIL_HH_ #include #include #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 formatTimeInIsoWithoutMs(const double time, std::ostream& pOs, t_DDTimeKind timeKind); static void formatTimeInIsoZ(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 formatTimeDateInIsoWithoutMs(const double time, std::ostream& pOs) { formatTimeInIsoWithoutMs(time, pOs, DD_TM_DATE); } static void formatTimeDateInIsoZ(const double time, std::ostream& pOs) { formatTimeInIsoZ(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); /** * @brief This static method converts a given time into YYYYDDDHHMMSSMSC and put it into a given std::ostream * * @param time given time as double * @param pOs given std::ostream * @param timeKind type of date see DD_Time.hh * @param offsetDay the amount of days to be added to the given time, by default it worths to 0 */ static void double2DD_Time(const double time, std::ostream& pOs, t_DDTimeKind timeKind, const int offsetDay =0 ); static void double2DD_TimeDate(const double time, std::ostream& pOs) { double2DD_Time(time, pOs, DD_TM_DATE); } static void double2DOY_TimeDate(const double time, std::ostream& pOs) { double2DD_Time(time, pOs, DD_TM_DATE, 1); } 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_ */