summaryrefslogtreecommitdiff
path: root/sax/qa
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-06-28 00:43:19 +0200
committerEike Rathke <erack@redhat.com>2013-07-15 11:46:41 +0000
commit652ccbdf3111766fadc379a8cf4650b744e1e19c (patch)
tree5efdab367c4da4ac6c62ad1e228b77648cc62aed /sax/qa
parenta8e8d46020702c64ff314adbe87e6f21e73e1999 (diff)
i#108348 API CHANGE: add IsUTC to css.util.DateTime etc.
Add IsUTC member to: com.sun.star.util.DateTime com.sun.star.util.DateTimeRange com.sun.star.util.Time Add new stucts with explicit time zones: com.sun.star.util.DateTimeWithTimezone com.sun.star.util.DateWithTimezone com.sun.star.util.TimeWithTimezone Adapt the sax::Converter to read/write timezones, and fix the unit test. Everything else just uses default (no time zone), this commit is just to fix the API. STRUCT: /UCR/com/sun/star/util/DateTime nFields1 = 7 != nFields2 = 8 Registry2 contains 1 more fields STRUCT: /UCR/com/sun/star/util/DateTimeRange nFields1 = 14 != nFields2 = 15 Registry2 contains 1 more fields STRUCT: /UCR/com/sun/star/util/Time nFields1 = 4 != nFields2 = 5 Registry2 contains 1 more fields Conflicts: sc/source/filter/oox/unitconverter.cxx Change-Id: I01f7a6d082a6b090c8efe71d2de137474c495c18 Reviewed-on: https://gerrit.libreoffice.org/4833 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sax/qa')
-rw-r--r--sax/qa/cppunit/test_converter.cxx63
1 files changed, 32 insertions, 31 deletions
diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx
index 8a5f72826a92..cfda248adf6c 100644
--- a/sax/qa/cppunit/test_converter.cxx
+++ b/sax/qa/cppunit/test_converter.cxx
@@ -157,7 +157,8 @@ static bool eqDateTime(util::DateTime a, util::DateTime b) {
return a.Year == b.Year && a.Month == b.Month && a.Day == b.Day
&& a.Hours == b.Hours && a.Minutes == b.Minutes
&& a.Seconds == b.Seconds
- && a.NanoSeconds == b.NanoSeconds;
+ && a.NanoSeconds == b.NanoSeconds
+ && a.IsUTC == b.IsUTC;
}
static void doTest(util::DateTime const & rdt, char const*const pis,
@@ -168,13 +169,14 @@ static void doTest(util::DateTime const & rdt, char const*const pis,
util::DateTime odt;
SAL_INFO("sax.cppunit","about to convert '" << is << "'");
bool bSuccess( Converter::convertDateTime(odt, is) );
- SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << " M:" << odt.Minutes << " S:" << odt.Seconds << " nS:" << odt.NanoSeconds);
+ SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << " M:" << odt.Minutes << " S:" << odt.Seconds << " nS:" << odt.NanoSeconds << " UTC: " << (bool)odt.IsUTC);
CPPUNIT_ASSERT(bSuccess);
CPPUNIT_ASSERT(eqDateTime(rdt, odt));
OUStringBuffer buf;
Converter::convertDateTime(buf, odt, true);
SAL_INFO("sax.cppunit","" << buf.getStr());
- CPPUNIT_ASSERT(buf.makeStringAndClear().equalsAscii(pos));
+ CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(pos),
+ buf.makeStringAndClear());
}
static void doTestDateTimeF(char const*const pis)
@@ -189,43 +191,42 @@ static void doTestDateTimeF(char const*const pis)
void ConverterTest::testDateTime()
{
SAL_INFO("sax.cppunit","\nSAX CONVERTER TEST BEGIN");
- doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1), "0001-01-01T00:00:00" );
- doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1),
- "0001-01-01T00:00:00Z", "0001-01-01T00:00:00" );
- doTest( util::DateTime(0, 0, 0, 0, 1, 1, -1), "-0001-01-01T00:00:00");
-// doTest( util::DateTime(0, 0, 0, 0, 1, 1, -1), "-0001-01-01T00:00:00Z");
- doTest( util::DateTime(0, 0, 0, 0, 1, 1, -324),
+ doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1, false), "0001-01-01T00:00:00" );
+ doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1, true), "0001-01-01T00:00:00Z" );
+ doTest( util::DateTime(0, 0, 0, 0, 1, 1, -1, false),
+ "-0001-01-01T00:00:00");
+ doTest( util::DateTime(0, 0, 0, 0, 1, 1, -1, true),
+ "-0001-01-01T01:00:00+01:00", "-0001-01-01T00:00:00Z");
+ doTest( util::DateTime(0, 0, 0, 0, 1, 1, -324, false),
"-0324-01-01T00:00:00" );
- doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1),
- "0001-01-01T00:00:00-00:00", "0001-01-01T00:00:00" );
- doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1),
- "0001-01-01T00:00:00+00:00", "0001-01-01T00:00:00" );
- doTest( util::DateTime(0, 0, 0, 0, 2, 1, 1)/*(0, 0, 12, 0, 2, 1, 1)*/,
- "0001-01-02T00:00:00-12:00", "0001-01-02T00:00:00" );
-// "0001-02-01T12:00:00" );
- doTest( util::DateTime(0, 0, 0, 0, 2, 1, 1)/*(0, 0, 12, 0, 1, 1, 1)*/,
- "0001-01-02T00:00:00+12:00", "0001-01-02T00:00:00" );
-// "0001-01-01T12:00:00" );
- doTest( util::DateTime(990000000, 59, 59, 23, 31, 12, 9999),
+ doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1, true),
+ "0001-01-01T00:00:00-00:00", "0001-01-01T00:00:00Z" );
+ doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1, true),
+ "0001-01-01T00:00:00+00:00", "0001-01-01T00:00:00Z" );
+ doTest( util::DateTime(0, 0, 0, 12, 2, 1, 1, true),
+ "0001-01-02T00:00:00-12:00", "0001-01-02T12:00:00Z" );
+ doTest( util::DateTime(0, 0, 0, 12, 1, 1, 1, true),
+ "0001-01-02T00:00:00+12:00", "0001-01-01T12:00:00Z" );
+ doTest( util::DateTime(990000000, 59, 59, 23, 31, 12, 9999, false),
"9999-12-31T23:59:59.99", "9999-12-31T23:59:59.990000000" );
- doTest( util::DateTime(990000000, 59, 59, 23, 31, 12, 9999),
- "9999-12-31T23:59:59.99Z", "9999-12-31T23:59:59.990000000" );
- doTest( util::DateTime(999999999, 59, 59, 23, 31, 12, 9999),
+ doTest( util::DateTime(990000000, 59, 59, 23, 31, 12, 9999, true),
+ "9999-12-31T23:59:59.99Z", "9999-12-31T23:59:59.990000000Z" );
+ doTest( util::DateTime(999999999, 59, 59, 23, 31, 12, 9999, false),
"9999-12-31T23:59:59.9999999999999999999999999999999999999",
"9999-12-31T23:59:59.999999999" );
- doTest( util::DateTime(999999999, 59, 59, 23, 31, 12, 9999),
+ doTest( util::DateTime(999999999, 59, 59, 23, 31, 12, 9999, true),
"9999-12-31T23:59:59.9999999999999999999999999999999999999Z",
- "9999-12-31T23:59:59.999999999" );
- doTest( util::DateTime(0, 0, 0, 0, 29, 2, 2000), // leap year
- "2000-02-29T00:00:00-00:00", "2000-02-29T00:00:00" );
- doTest( util::DateTime(0, 0, 0, 0, 29, 2, 1600), // leap year
- "1600-02-29T00:00:00-00:00", "1600-02-29T00:00:00" );
- doTest( util::DateTime(0, 0, 0, 24, 1, 1, 333)
+ "9999-12-31T23:59:59.999999999Z" );
+ doTest( util::DateTime(0, 0, 0, 0, 29, 2, 2000, true), // leap year
+ "2000-02-29T00:00:00-00:00", "2000-02-29T00:00:00Z" );
+ doTest( util::DateTime(0, 0, 0, 0, 29, 2, 1600, true), // leap year
+ "1600-02-29T00:00:00-00:00", "1600-02-29T00:00:00Z" );
+ doTest( util::DateTime(0, 0, 0, 24, 1, 1, 333, false)
/*(0, 0, 0, 0, 2, 1, 333)*/,
"0333-01-01T24:00:00"/*, "0333-01-02T00:00:00"*/ );
// While W3C XMLSchema specifies a minimum of 4 year digits we are lenient
// in what we accept.
- doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1),
+ doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1, false),
"1-01-01T00:00:00", "0001-01-01T00:00:00" );
doTestDateTimeF( "+0001-01-01T00:00:00" ); // invalid: ^+
doTestDateTimeF( "0001-1-01T00:00:00" ); // invalid: < 2 M