[casacore] r21173 committed - Added output format options to support Boost date/time format

1 view
Skip to first unread message

casa...@googlecode.com

unread,
Jan 12, 2012, 2:48:33 AM1/12/12
to casacor...@googlegroups.com
Revision: 21173
Author: gervandiepen
Date: Wed Jan 11 23:47:21 2012
Log: Added output format options to support Boost date/time format

http://code.google.com/p/casacore/source/detail?r=21173

Added:
/trunk/casa/Quanta/test/tMVTime.out
Modified:
/trunk/casa/Quanta/MVTime.cc
/trunk/casa/Quanta/MVTime.h
/trunk/casa/Quanta/test/tMVTime.cc

=======================================
--- /dev/null
+++ /trunk/casa/Quanta/test/tMVTime.out Wed Jan 11 23:47:21 2012
@@ -0,0 +1,12 @@
++206.23.12.281
+13:45:32.819
+25-Jan-2012 13:45:33
+2012-01-25T13:45:32.8187
+2012/01/25/13:45:33
+25-Jan-2012/13:46:
+25-Jan-2012/13:46
+Wed-13:45:32.819
+Wed
+Wed 25-Jan-2012 13:45:32.819
+55951/13:45:32.819
+55951
=======================================
--- /trunk/casa/Quanta/MVTime.cc Thu Nov 24 07:38:17 2011
+++ /trunk/casa/Quanta/MVTime.cc Wed Jan 11 23:47:21 2012
@@ -262,7 +262,7 @@
}

MVTime::formatTypes MVTime::giveMe(const String &in) {
- const Int N_name = 13;
+ const Int N_name = 14;
static const String tab[N_name] = {
"ANGLE",
"TIME",
@@ -277,6 +277,7 @@
"DIG2",
"FITS",
"LOCAL",
+ "USE_SPACE"
};
static MVTime::formatTypes nam[N_name] = {
MVTime::ANGLE,
@@ -292,6 +293,7 @@
MVTime::DIG2,
MVTime::FITS,
MVTime::LOCAL,
+ MVTime::USE_SPACE
};
Int t = MUString::minimaxNC(in, N_name, tab);
return (t<N_name ? nam[t] : (MVTime::formatTypes) 0);
@@ -349,7 +351,11 @@
if (i1 == MVTime::YMD || i1 == MVTime::DMY ||
i1 == MVTime::MJD ||
(intyp & MVTime::NO_TIME) != MVTime::NO_TIME) {
- oss << '-';
+ if (intyp & MVTime::USE_SPACE) {
+ oss << ' ';
+ } else {
+ oss << '-';
+ }
}
}
if (i1 == MVTime::YMD || i1 == MVTime::DMY || i1 == MVTime::FITS) {
@@ -372,6 +378,8 @@
if ((intyp & MVTime::NO_TIME) != MVTime::NO_TIME) {
if (i1 == MVTime::FITS) {
oss << "T";
+ } else if (intyp & MVTime::USE_SPACE) {
+ oss << ' ';
} else {
oss << "/";
}
=======================================
--- /trunk/casa/Quanta/MVTime.h Thu Nov 24 07:38:17 2011
+++ /trunk/casa/Quanta/MVTime.h Wed Jan 11 23:47:21 2012
@@ -136,6 +136,8 @@
// precede the time with 'dd-Mon-yyyy/'.<br>
// The <src>MVTime::FITS</src> format implies TIME, and will
// precede the time with 'ccyy-mm-ddT'.
+// The <src>BOOST</src> format implies DMY and USE_SPACE (space
instead
+// of slash between date and time).
// <br>
// The output format can be modified with modifiers (specify as
// MVTime::TIME | MVTime::MOD (or + MVTime::MOD)).
@@ -156,7 +158,7 @@
// <li> <src>MVTime::NO_HM</src> (or <src>NO_DM</src>), to
// suppress the degrees and minutes.
// <li> <src>MVTime::DAY</src> will precede the output with
-// 'Day-' (e.g. Wed-)
+// 'Day-' (e.g. Wed-). Space delimiter is used for USE_SPACE.
// <li> <src>MVTime::NO_TIME</src> will suppress printing of time.
// </ul>
// Output in formats like <src>20'</src> can be done via the standard
@@ -169,6 +171,8 @@
// <li> MVTime::[ANGLE|TIME][_CLEAN]_NO_[D|H][M] in format with
// leading zero fields left empty.
// <li> MVTime::CLEAN modifier for suppressing superfluous periods
+// <li> MVTime::USE_SPACE to use a space instead of a slash
+// as delimiter between date and time.
// <li> MVTime::NO_[D|H][M] modifier to suppress first field(s)
// <li> MVTime::DIG2 modifier to get +dd.mm.ss.ttt in angle or
// time format(i.e. in range -90 - +90 or -12 - +12)
@@ -277,6 +281,8 @@
DIG2 = 1024,
FITS = TIME+2048,
LOCAL = 4096,
+ USE_SPACE = 8192,
+ BOOST = DMY + USE_SPACE,
NO_H = NO_D,
NO_HM = NO_DM,
ANGLE_CLEAN = ANGLE + CLEAN,
@@ -290,7 +296,8 @@
TIME_CLEAN_NO_H = TIME + CLEAN + NO_H,
TIME_CLEAN_NO_HM = TIME + CLEAN + NO_HM,
YMD_ONLY = YMD + NO_TIME,
- MOD_MASK = CLEAN + NO_DM + DAY + NO_TIME + DIG2 + LOCAL
+ MOD_MASK = CLEAN + NO_DM + DAY + NO_TIME + DIG2 +
+ LOCAL + USE_SPACE
};

//# Local structure
=======================================
--- /trunk/casa/Quanta/test/tMVTime.cc Thu Nov 24 07:38:17 2011
+++ /trunk/casa/Quanta/test/tMVTime.cc Wed Jan 11 23:47:21 2012
@@ -31,6 +31,11 @@
#include <casa/Quanta/MVTime.h>

#include <casa/namespace.h>
+
+void showTime (MVTime time, uInt format, uInt prec)
+{
+ cout << MVTime::Format(format,prec) << time << endl;
+}

int main ()
{
@@ -47,6 +52,20 @@
AlwaysAssertExit (MVTime::read (q, "1996/11/20/5:20"));
AlwaysAssertExit (MVTime::read (q, "20Nov96-5h20m"));
AlwaysAssertExit (MVTime::read (q, "1996-11-20T5:20"));
+ AlwaysAssertExit (MVTime::read (q, "25-Jan-2012/13:45:32.8187"));
+ MVTime time(q);
+ showTime (q, MVTime::ANGLE, 9);
+ showTime (q, MVTime::TIME, 9);
+ showTime (q, MVTime::BOOST, 0);
+ showTime (q, MVTime::FITS, 10);
+ showTime (q, MVTime::YMD, 5);
+ showTime (q, MVTime::DMY, 4);
+ showTime (q, MVTime::DMY+MVTime::CLEAN, 4);
+ showTime (q, MVTime::DAY, 9);
+ showTime (q, MVTime::DAY+MVTime::NO_TIME, 9);
+ showTime (q, MVTime::DAY+MVTime::DMY+MVTime::USE_SPACE, 9);
+ showTime (q, MVTime::MJD, 9);
+ showTime (q, MVTime::NO_TIME+MVTime::MJD, 9);
} catch (AipsError& x) {
cout << "Unexpected exception: " << x.getMesg() << endl;
return 1;

Reply all
Reply to author
Forward
0 new messages