Commit ec8407f1 authored by Andrea Orlat's avatar Andrea Orlat
Browse files

Added a new time to string conversion function in IRATools class

parent 9afa09ea
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
/* Andrea Orlati(aorlati@ira.inaf.it)  12/06/2014	  Function to handle conversions from Reference frame and definition for radial velocity */
/* Marco Bartolini (bartolini@ira.inaf.it)  18/06/2014	   added function ACS::Time getACSTime() */
/* Andrea Orlati(aorlati@ira.inaf.it)  12/08/2015	  Function to check if a file exists or not */
/* Andrea Orlati(aorlati@ira.inaf.it)  19/11/2015	  Function timeToStrExtended was added */

#include <time.h>
#include <sys/time.h>
@@ -401,6 +402,17 @@ public:
	 */
	static bool timeToStr(const ACS::Time& time,IRA::CString& outString,char dateDelimiter='-',char timeDelimiter=':');

	/**
	 * Use this function to convert an ACS time epoch to a string with extended notation(YYYY-MM-DDThh:mm:ss.ss).
	 * @param time the representation in 100ns units of the time epoch to be converted
	 * @param outString string that contains the time as it is converted
	 * @param dateDelimiter the char that has to be considered as the field separator for the date part of the time epoch
	 * @param timeDelimiter the char that has to be considered as the field separator for the time part of the time epoch
	 * @return the result of the conversion, true if the conversion could be done
	 */
	static bool timeToStrExtended(const ACS::Time& time,IRA::CString& outString,char dateDelimiter='-',char timeDelimiter=':');


	/**
	 * Use this function to convert from a double sequence to a string
	 * @param val sequence of double values
+20 −1
Original line number Diff line number Diff line
@@ -524,7 +524,12 @@ bool CIRATools::strToInterval(const IRA::CString& durationString,ACS::TimeInterv
bool CIRATools::intervalToStr(const ACS::TimeInterval& interval,IRA::CString& outString,char dateDelimiter,char timeDelimiter)
{
	TIMEDIFFERENCE timeD(interval);
	if (timeD.day()>0) {
		outString.Format("%03ld%c%02ld%c%02ld%c%02ld.%03lu",(long)timeD.day(),dateDelimiter,(long)timeD.hour(),timeDelimiter,(long)timeD.minute(),timeDelimiter,(long)timeD.second(),(unsigned long)timeD.microSecond()/1000);
	}
	else {
		outString.Format("%02ld%c%02ld%c%02ld.%03lu",(long)timeD.hour(),timeDelimiter,(long)timeD.minute(),timeDelimiter,(long)timeD.second(),(unsigned long)timeD.microSecond()/1000);
	}
	return true;
}

@@ -606,6 +611,20 @@ bool CIRATools::timeToStr(const ACS::Time& time,IRA::CString& outString,char dat
	return true;	
}

bool CIRATools::timeToStrExtended(const ACS::Time& time,IRA::CString& outString,char dateDelimiter,char timeDelimiter)
{
	TIMEVALUE timeE(time);
	outString.Format("%04lu%c%02ld%c%02ldT%02ld%c%02ld%c%02ld.%03ld",
			(unsigned long)timeE.year(),dateDelimiter,
			(long)timeE.month(),dateDelimiter,
			(long)timeE.day(),
			(long)timeE.hour(),timeDelimiter,
			(long)timeE.minute(),timeDelimiter,
			(long)timeE.second(),
			(long)timeE.microSecond()/1000);
	return true;
}

bool CIRATools::doubleSeqToStr(const ACS::doubleSeq& val,IRA::CString& outString,char delimiter)
{
	IRA::CString single;