basic/source/runtime/methods1.cxx | 20 i18npool/inc/calendarImpl.hxx | 14 i18npool/inc/calendar_gregorian.hxx | 4 i18npool/source/calendar/calendarImpl.cxx | 23 i18npool/source/calendar/calendar_gregorian.cxx | 34 + i18npool/source/registerservices/registerservices.cxx | 3 i18npool/util/i18npool.component | 1 include/unotools/calendarwrapper.hxx | 18 offapi/UnoApi_offapi.mk | 2 offapi/com/sun/star/i18n/LocaleCalendar2.idl | 27 offapi/com/sun/star/i18n/XCalendar.idl | 12 offapi/com/sun/star/i18n/XCalendar4.idl | 57 + svl/qa/unit/svl.cxx | 561 +++++++++++++++++- svl/source/numbers/zforfind.cxx | 6 unotools/source/i18n/calendarwrapper.cxx | 47 - 15 files changed, 726 insertions(+), 103 deletions(-)
New commits: commit 58da9ef3f19643e20b9b22c3a3f0855c62c0d199 Author: Eike Rathke <er...@redhat.com> Date: Mon Jan 26 17:59:04 2015 +0100 merge existing date input tests to new unit test, tdf#63230 diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 4a9a080..76c3f3f 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -57,7 +57,6 @@ public: void testSharedString(); void testSharedStringPool(); void testSharedStringPoolPurge(); - void testFdo44286(); void testFdo60915(); void testI116701(); void testDateInput(); @@ -67,7 +66,6 @@ public: CPPUNIT_TEST(testSharedString); CPPUNIT_TEST(testSharedStringPool); CPPUNIT_TEST(testSharedStringPoolPurge); - CPPUNIT_TEST(testFdo44286); CPPUNIT_TEST(testFdo60915); CPPUNIT_TEST(testI116701); CPPUNIT_TEST(testDateInput); @@ -407,32 +405,6 @@ void Test::checkPreviewString(SvNumberFormatter& aFormatter, CPPUNIT_ASSERT_EQUAL(sExpected, sStr); } -void Test::testFdo44286() -{ - LanguageType eLang = LANGUAGE_ENGLISH_US; - OUString sCode = "YYYY-MM-DD", sExpected; - double fPreviewNumber; - SvNumberFormatter aFormatter(m_xContext, eLang); - { - icu::TimeZone::adoptDefault(icu::TimeZone::createTimeZone("America/Sao_Paulo")); - sExpected = "1902-04-22"; - fPreviewNumber = 843; - checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected); - } - { - icu::TimeZone::adoptDefault(icu::TimeZone::createTimeZone("Europe/Berlin")); - sExpected = "1790-07-27"; - fPreviewNumber = -39967; - checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected); - } - { - icu::TimeZone::adoptDefault(icu::TimeZone::createTimeZone("US/Mountain")); - sExpected = "1790-07-26"; - fPreviewNumber = -39968; - checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected); - } -} - void Test::testFdo60915() { LanguageType eLang = LANGUAGE_THAI; @@ -524,6 +496,8 @@ void Test::testDateInput() "Europe/Tallinn", "1790-03-01", // i#105864 "Australia/Perth", "2004-04-11", // i#17222 "America/Sao_Paulo", "1902-04-22", // tdf#44286 + "Europe/Berlin", "1790-07-27", + "US/Mountain", "1790-07-26", // Data from https://bugs.documentfoundation.org/show_bug.cgi?id=63230 // https://bugs.documentfoundation.org/attachment.cgi?id=79051 commit ce20ba5d3d6c6a88e0fd469f8bfe07e6decb3b26 Author: Eike Rathke <er...@redhat.com> Date: Mon Jan 26 17:51:15 2015 +0100 add older problems to unit test, tdf#63230 Check that various older problems remain fixed. diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 21be933..4a9a080 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -518,9 +518,15 @@ void Test::testI116701() void Test::testDateInput() { - // Data from https://bugs.documentfoundation.org/show_bug.cgi?id=63230 - // attachment https://bugs.documentfoundation.org/attachment.cgi?id=79051 const char* aData[][2] = { + "Europe/Paris", "1938-10-07", // i#76623 + "Europe/Moscow", "1919-07-01", // i#86094 + "Europe/Tallinn", "1790-03-01", // i#105864 + "Australia/Perth", "2004-04-11", // i#17222 + "America/Sao_Paulo", "1902-04-22", // tdf#44286 + + // Data from https://bugs.documentfoundation.org/show_bug.cgi?id=63230 + // https://bugs.documentfoundation.org/attachment.cgi?id=79051 "Africa/Accra", "1800-01-01", "Africa/Accra", "1800-04-10", "Africa/Addis_Ababa", "1870-01-01", commit 9a5f4b3b8374da48369ab71e03fbf7713ef198f9 Author: Eike Rathke <er...@redhat.com> Date: Mon Jan 26 17:21:57 2015 +0100 add unit test for tdf#63230 All problematic dates of https://bugs.documentfoundation.org/attachment.cgi?id=79051 Muchas gracias to Isamu Mogi! diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index dd856fb..21be933 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -60,6 +60,7 @@ public: void testFdo44286(); void testFdo60915(); void testI116701(); + void testDateInput(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testNumberFormat); @@ -69,6 +70,7 @@ public: CPPUNIT_TEST(testFdo44286); CPPUNIT_TEST(testFdo60915); CPPUNIT_TEST(testI116701); + CPPUNIT_TEST(testDateInput); CPPUNIT_TEST_SUITE_END(); private: @@ -78,6 +80,7 @@ private: double fPreviewNumber, LanguageType eLang, OUString& sExpected); + void checkDateInput( SvNumberFormatter& rFormatter, const char* pTimezone, const char* pIsoDate ); boost::scoped_ptr<icu::TimeZone> m_pDefaultTimeZone; }; @@ -513,6 +516,528 @@ void Test::testI116701() checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected); } +void Test::testDateInput() +{ + // Data from https://bugs.documentfoundation.org/show_bug.cgi?id=63230 + // attachment https://bugs.documentfoundation.org/attachment.cgi?id=79051 + const char* aData[][2] = { + "Africa/Accra", "1800-01-01", + "Africa/Accra", "1800-04-10", + "Africa/Addis_Ababa", "1870-01-01", + "Africa/Addis_Ababa", "1936-05-05", + "Africa/Algiers", "1956-01-29", + "Africa/Algiers", "1981-05-01", + "Africa/Asmara", "1936-05-05", + "Africa/Asmera", "1936-05-05", + "Africa/Bujumbura", "1890-01-01", + "Africa/Casablanca", "1984-03-16", + "Africa/Ceuta", "1984-03-16", + "Africa/Dar_es_Salaam", "1931-01-01", + "Africa/Dar_es_Salaam", "1961-01-01", + "Africa/Djibouti", "1911-07-01", + "Africa/Douala", "1912-01-01", + "Africa/El_Aaiun", "1934-01-01", + "Africa/Freetown", "1913-06-01", + "Africa/Gaborone", "1885-01-01", + "Africa/Johannesburg", "1903-03-01", + "Africa/Kampala", "1928-07-01", + "Africa/Kampala", "1948-01-01", + "Africa/Kampala", "1957-01-01", + "Africa/Lagos", "1919-09-01", + "Africa/Libreville", "1912-01-01", + "Africa/Luanda", "1911-05-26", + "Africa/Lubumbashi", "1897-11-09", + "Africa/Lusaka", "1903-03-01", + "Africa/Malabo", "1963-12-15", + "Africa/Maseru", "1903-03-01", + "Africa/Mogadishu", "1957-01-01", + "Africa/Monrovia", "1919-03-01", + "Africa/Nairobi", "1928-07-01", + "Africa/Nairobi", "1940-01-01", + "Africa/Nairobi", "1960-01-01", + "Africa/Niamey", "1960-01-01", + "Africa/Porto-Novo", "1934-02-26", + "Africa/Tripoli", "1920-01-01", + "Africa/Tripoli", "1959-01-01", + "Africa/Tripoli", "1990-05-04", + "Africa/Tunis", "1911-03-11", + "Africa/Windhoek", "1892-02-08", + "Africa/Windhoek", "1903-03-01", + "America/Antigua", "1912-03-02", + "America/Argentina/Buenos_Aires", "1894-10-31", + "America/Argentina/Catamarca", "1991-10-20", + "America/Argentina/Catamarca", "2004-06-01", + "America/Argentina/ComodRivadavia", "1991-10-20", + "America/Argentina/ComodRivadavia", "2004-06-01", + "America/Argentina/Cordoba", "1991-10-20", + "America/Argentina/Jujuy", "1991-10-06", + "America/Argentina/La_Rioja", "2004-06-01", + "America/Argentina/Mendoza", "1992-10-18", + "America/Argentina/Mendoza", "2004-05-23", + "America/Argentina/Rio_Gallegos", "2004-06-01", + "America/Argentina/Salta", "1991-10-20", + "America/Argentina/San_Juan", "2004-05-31", + "America/Argentina/San_Luis", "2004-05-31", + "America/Argentina/San_Luis", "2008-01-21", + "America/Argentina/Tucuman", "1991-10-20", + "America/Argentina/Tucuman", "2004-06-01", + "America/Argentina/Ushuaia", "2004-05-30", + "America/Asuncion", "1931-10-10", + "America/Asuncion", "1974-04-01", + "America/Bahia", "1914-01-01", + "America/Bahia_Banderas", "1930-11-15", + "America/Bahia_Banderas", "1931-10-01", + "America/Bahia_Banderas", "1942-04-24", + "America/Bahia_Banderas", "1949-01-14", + "America/Barbados", "1932-01-01", + "America/Belize", "1912-04-01", + "America/Blanc-Sablon", "1884-01-01", + "America/Bogota", "1914-11-23", + "America/Buenos_Aires", "1894-10-31", + "America/Cambridge_Bay", "2000-11-05", + "America/Campo_Grande", "1914-01-01", + "America/Caracas", "1912-02-12", + "America/Catamarca", "1991-10-20", + "America/Catamarca", "2004-06-01", + "America/Cayenne", "1911-07-01", + "America/Chihuahua", "1930-11-15", + "America/Chihuahua", "1931-10-01", + "America/Cordoba", "1991-10-20", + "America/Costa_Rica", "1921-01-15", + "America/Cuiaba", "1914-01-01", + "America/Danmarkshavn", "1916-07-28", + "America/Detroit", "1905-01-01", + "America/Eirunepe", "1914-01-01", + "America/El_Salvador", "1921-01-01", + "America/Ensenada", "1924-01-01", + "America/Ensenada", "1930-11-15", + "America/Fortaleza", "1914-01-01", + "America/Glace_Bay", "1902-06-15", + "America/Grand_Turk", "1890-01-01", + "America/Guyana", "1991-01-01", + "America/Havana", "1890-01-01", + "America/Hermosillo", "1930-11-15", + "America/Hermosillo", "1931-10-01", + "America/Hermosillo", "1942-04-24", + "America/Hermosillo", "1949-01-14", + "America/Jujuy", "1991-10-06", + "America/Lima", "1890-01-01", + "America/Maceio", "1914-01-01", + "America/Managua", "1890-01-01", + "America/Managua", "1934-06-23", + "America/Managua", "1975-02-16", + "America/Managua", "1992-09-24", + "America/Managua", "1997-01-01", + "America/Mazatlan", "1930-11-15", + "America/Mazatlan", "1931-10-01", + "America/Mazatlan", "1942-04-24", + "America/Mazatlan", "1949-01-14", + "America/Mendoza", "1992-10-18", + "America/Mendoza", "2004-05-23", + "America/Merida", "1982-12-02", + "America/Mexico_City", "1930-11-15", + "America/Mexico_City", "1931-10-01", + "America/Miquelon", "1911-05-15", + "America/Moncton", "1883-12-09", + "America/Montevideo", "1942-12-14", + "America/Montreal", "1884-01-01", + "America/Ojinaga", "1930-11-15", + "America/Ojinaga", "1931-10-01", + "America/Panama", "1890-01-01", + "America/Paramaribo", "1911-01-01", + "America/Porto_Acre", "1914-01-01", + "America/Recife", "1914-01-01", + "America/Regina", "1905-09-01", + "America/Rio_Branco", "1914-01-01", + "America/Rosario", "1991-10-20", + "America/Santa_Isabel", "1924-01-01", + "America/Santa_Isabel", "1930-11-15", + "America/Santarem", "1914-01-01", + "America/Santiago", "1910-01-01", + "America/Santiago", "1919-07-01", + "America/Santo_Domingo", "1890-01-01", + "America/Scoresbysund", "1916-07-28", + "America/Scoresbysund", "1981-03-29", + "America/Tegucigalpa", "1921-04-01", + "America/Thunder_Bay", "1895-01-01", + "America/Tijuana", "1924-01-01", + "America/Tijuana", "1930-11-15", + "Antarctica/Casey", "1969-01-01", + "Antarctica/Casey", "2009-10-18", + "Antarctica/Davis", "1957-01-13", + "Antarctica/Davis", "1969-02-01", + "Antarctica/Davis", "2010-03-11", + "Antarctica/DumontDUrville", "1947-01-01", + "Antarctica/DumontDUrville", "1956-11-01", + "Antarctica/Macquarie", "1911-01-01", + "Antarctica/Mawson", "1954-02-13", + "Antarctica/McMurdo", "1956-01-01", + "Antarctica/Palmer", "1982-05-01", + "Antarctica/South_Pole", "1956-01-01", + "Antarctica/Syowa", "1957-01-29", + "Antarctica/Vostok", "1957-12-16", + "Arctic/Longyearbyen", "1895-01-01", + "Asia/Almaty", "1930-06-21", + "Asia/Anadyr", "1924-05-02", + "Asia/Anadyr", "1930-06-21", + "Asia/Anadyr", "1992-01-19", + "Asia/Anadyr", "2011-03-27", + "Asia/Aqtau", "1924-05-02", + "Asia/Aqtau", "1930-06-21", + "Asia/Aqtau", "1981-10-01", + "Asia/Aqtau", "2005-03-15", + "Asia/Aqtobe", "1924-05-02", + "Asia/Aqtobe", "1930-06-21", + "Asia/Ashgabat", "1924-05-02", + "Asia/Ashgabat", "1930-06-21", + "Asia/Ashgabat", "1992-01-19", + "Asia/Ashkhabad", "1924-05-02", + "Asia/Ashkhabad", "1930-06-21", + "Asia/Ashkhabad", "1992-01-19", + "Asia/Baghdad", "1918-01-01", + "Asia/Bahrain", "1920-01-01", + "Asia/Baku", "1957-03-01", + "Asia/Bangkok", "1920-04-01", + "Asia/Bishkek", "1924-05-02", + "Asia/Bishkek", "1930-06-21", + "Asia/Brunei", "1933-01-01", + "Asia/Calcutta", "1941-10-01", + "Asia/Choibalsan", "1978-01-01", + "Asia/Chongqing", "1980-05-01", + "Asia/Chungking", "1980-05-01", + "Asia/Colombo", "1880-01-01", + "Asia/Colombo", "1906-01-01", + "Asia/Colombo", "1996-05-25", + "Asia/Dacca", "1941-10-01", + "Asia/Dacca", "1942-09-01", + "Asia/Dhaka", "1941-10-01", + "Asia/Dhaka", "1942-09-01", + "Asia/Dili", "2000-09-17", + "Asia/Dubai", "1920-01-01", + "Asia/Dushanbe", "1924-05-02", + "Asia/Dushanbe", "1930-06-21", + "Asia/Harbin", "1928-01-01", + "Asia/Harbin", "1940-01-01", + "Asia/Ho_Chi_Minh", "1912-05-01", + "Asia/Hong_Kong", "1904-10-30", + "Asia/Hong_Kong", "1941-12-25", + "Asia/Hovd", "1978-01-01", + "Asia/Irkutsk", "1920-01-25", + "Asia/Irkutsk", "1930-06-21", + "Asia/Irkutsk", "1992-01-19", + "Asia/Irkutsk", "2011-03-27", + "Asia/Istanbul", "1880-01-01", + "Asia/Istanbul", "1910-10-01", + "Asia/Istanbul", "1978-10-15", + "Asia/Jakarta", "1932-11-01", + "Asia/Jakarta", "1942-03-23", + "Asia/Jakarta", "1948-05-01", + "Asia/Jayapura", "1944-09-01", + "Asia/Kabul", "1945-01-01", + "Asia/Kamchatka", "1922-11-10", + "Asia/Kamchatka", "1930-06-21", + "Asia/Kamchatka", "1992-01-19", + "Asia/Kamchatka", "2011-03-27", + "Asia/Karachi", "1907-01-01", + "Asia/Kashgar", "1928-01-01", + "Asia/Kashgar", "1980-05-01", + "Asia/Kathmandu", "1986-01-01", + "Asia/Katmandu", "1986-01-01", + "Asia/Kolkata", "1941-10-01", + "Asia/Krasnoyarsk", "1930-06-21", + "Asia/Krasnoyarsk", "1992-01-19", + "Asia/Krasnoyarsk", "2011-03-27", + "Asia/Kuala_Lumpur", "1901-01-01", + "Asia/Kuala_Lumpur", "1905-06-01", + "Asia/Kuala_Lumpur", "1941-09-01", + "Asia/Kuala_Lumpur", "1942-02-16", + "Asia/Kuala_Lumpur", "1982-01-01", + "Asia/Kuching", "1926-03-01", + "Asia/Kuching", "1933-01-01", + "Asia/Kuching", "1942-02-16", + "Asia/Macao", "1912-01-01", + "Asia/Macau", "1912-01-01", + "Asia/Magadan", "1930-06-21", + "Asia/Magadan", "1992-01-19", + "Asia/Magadan", "2011-03-27", + "Asia/Makassar", "1932-11-01", + "Asia/Makassar", "1942-02-09", + "Asia/Manila", "1942-05-01", + "Asia/Muscat", "1920-01-01", + "Asia/Novokuznetsk", "1920-01-06", + "Asia/Novokuznetsk", "1930-06-21", + "Asia/Novokuznetsk", "1992-01-19", + "Asia/Novokuznetsk", "2011-03-27", + "Asia/Novosibirsk", "1930-06-21", + "Asia/Novosibirsk", "1992-01-19", + "Asia/Novosibirsk", "2011-03-27", + "Asia/Omsk", "1919-11-14", + "Asia/Omsk", "1930-06-21", + "Asia/Omsk", "1992-01-19", + "Asia/Omsk", "2011-03-27", + "Asia/Oral", "1924-05-02", + "Asia/Oral", "1930-06-21", + "Asia/Oral", "2005-03-15", + "Asia/Phnom_Penh", "1906-06-09", + "Asia/Phnom_Penh", "1912-05-01", + "Asia/Pontianak", "1932-11-01", + "Asia/Pontianak", "1942-01-29", + "Asia/Pontianak", "1948-05-01", + "Asia/Pontianak", "1964-01-01", + "Asia/Pyongyang", "1890-01-01", + "Asia/Pyongyang", "1904-12-01", + "Asia/Pyongyang", "1932-01-01", + "Asia/Pyongyang", "1961-08-10", + "Asia/Qatar", "1920-01-01", + "Asia/Qyzylorda", "1930-06-21", + "Asia/Qyzylorda", "1992-01-19", + "Asia/Rangoon", "1920-01-01", + "Asia/Rangoon", "1942-05-01", + "Asia/Saigon", "1912-05-01", + "Asia/Sakhalin", "1945-08-25", + "Asia/Sakhalin", "1992-01-19", + "Asia/Sakhalin", "2011-03-27", + "Asia/Samarkand", "1930-06-21", + "Asia/Seoul", "1890-01-01", + "Asia/Seoul", "1904-12-01", + "Asia/Seoul", "1932-01-01", + "Asia/Seoul", "1961-08-10", + "Asia/Seoul", "1968-10-01", + "Asia/Singapore", "1905-06-01", + "Asia/Singapore", "1941-09-01", + "Asia/Singapore", "1942-02-16", + "Asia/Singapore", "1982-01-01", + "Asia/Tashkent", "1924-05-02", + "Asia/Tashkent", "1930-06-21", + "Asia/Tbilisi", "1924-05-02", + "Asia/Tbilisi", "1957-03-01", + "Asia/Tbilisi", "2005-03-27", + "Asia/Tehran", "1946-01-01", + "Asia/Tehran", "1977-11-01", + "Asia/Thimbu", "1987-10-01", + "Asia/Thimphu", "1987-10-01", + "Asia/Ujung_Pandang", "1932-11-01", + "Asia/Ujung_Pandang", "1942-02-09", + "Asia/Ulaanbaatar", "1978-01-01", + "Asia/Ulan_Bator", "1978-01-01", + "Asia/Urumqi", "1928-01-01", + "Asia/Urumqi", "1980-05-01", + "Asia/Vientiane", "1906-06-09", + "Asia/Vientiane", "1912-05-01", + "Asia/Vladivostok", "1922-11-15", + "Asia/Vladivostok", "1930-06-21", + "Asia/Vladivostok", "1992-01-19", + "Asia/Vladivostok", "2011-03-27", + "Asia/Yakutsk", "1930-06-21", + "Asia/Yakutsk", "1992-01-19", + "Asia/Yakutsk", "2011-03-27", + "Asia/Yekaterinburg", "1930-06-21", + "Asia/Yekaterinburg", "1992-01-19", + "Asia/Yekaterinburg", "2011-03-27", + "Asia/Yerevan", "1924-05-02", + "Asia/Yerevan", "1957-03-01", + "Atlantic/Azores", "1884-01-01", + "Atlantic/Azores", "1911-05-24", + "Atlantic/Cape_Verde", "1907-01-01", + "Atlantic/Jan_Mayen", "1895-01-01", + "Atlantic/Reykjavik", "1837-01-01", + "Atlantic/Stanley", "1912-03-12", + "Australia/Adelaide", "1899-05-01", + "Australia/Broken_Hill", "1895-02-01", + "Australia/Broken_Hill", "1899-05-01", + "Australia/Currie", "1895-09-01", + "Australia/Darwin", "1895-02-01", + "Australia/Darwin", "1899-05-01", + "Australia/Eucla", "1895-12-01", + "Australia/Hobart", "1895-09-01", + "Australia/LHI", "1981-03-01", + "Australia/Lindeman", "1895-01-01", + "Australia/Lord_Howe", "1981-03-01", + "Australia/Melbourne", "1895-02-01", + "Australia/North", "1895-02-01", + "Australia/North", "1899-05-01", + "Australia/Perth", "1895-12-01", + "Australia/South", "1899-05-01", + "Australia/Tasmania", "1895-09-01", + "Australia/Victoria", "1895-02-01", + "Australia/West", "1895-12-01", + "Australia/Yancowinna", "1895-02-01", + "Australia/Yancowinna", "1899-05-01", + "Brazil/Acre", "1914-01-01", + "Canada/East-Saskatchewan", "1905-09-01", + "Canada/Saskatchewan", "1905-09-01", + "Chile/Continental", "1910-01-01", + "Chile/Continental", "1919-07-01", + "Chile/EasterIsland", "1932-09-01", + "Cuba", "1890-01-01", + "Eire", "1880-08-02", + "Europe/Amsterdam", "1937-07-01", + "Europe/Andorra", "1946-09-30", + "Europe/Athens", "1916-07-28", + "Europe/Athens", "1944-04-04", + "Europe/Berlin", "1893-04-01", + "Europe/Bratislava", "1891-10-01", + "Europe/Brussels", "1914-11-08", + "Europe/Bucharest", "1931-07-24", + "Europe/Chisinau", "1931-07-24", + "Europe/Copenhagen", "1894-01-01", + "Europe/Dublin", "1880-08-02", + "Europe/Helsinki", "1921-05-01", + "Europe/Istanbul", "1880-01-01", + "Europe/Istanbul", "1910-10-01", + "Europe/Istanbul", "1978-10-15", + "Europe/Kaliningrad", "1945-01-01", + "Europe/Kaliningrad", "1946-01-01", + "Europe/Kaliningrad", "2011-03-27", + "Europe/Kiev", "1930-06-21", + "Europe/Kiev", "1943-11-06", + "Europe/Luxembourg", "1904-06-01", + "Europe/Malta", "1893-11-02", + "Europe/Mariehamn", "1921-05-01", + "Europe/Minsk", "1924-05-02", + "Europe/Minsk", "1930-06-21", + "Europe/Minsk", "2011-03-27", + "Europe/Moscow", "1916-07-03", + "Europe/Moscow", "1930-06-21", + "Europe/Moscow", "1992-01-19", + "Europe/Moscow", "2011-03-27", + "Europe/Oslo", "1895-01-01", + "Europe/Prague", "1891-10-01", + "Europe/Riga", "1926-05-11", + "Europe/Riga", "1940-08-05", + "Europe/Riga", "1944-10-13", + "Europe/Rome", "1893-11-01", + "Europe/Samara", "1930-06-21", + "Europe/Samara", "1991-10-20", + "Europe/Samara", "2011-03-27", + "Europe/San_Marino", "1893-11-01", + "Europe/Simferopol", "1930-06-21", + "Europe/Simferopol", "1994-05-01", + "Europe/Sofia", "1880-01-01", + "Europe/Sofia", "1894-11-30", + "Europe/Tallinn", "1919-07-01", + "Europe/Tallinn", "1921-05-01", + "Europe/Tallinn", "1940-08-06", + "Europe/Tiraspol", "1931-07-24", + "Europe/Uzhgorod", "1945-06-29", + "Europe/Vaduz", "1894-06-01", + "Europe/Vatican", "1893-11-01", + "Europe/Vilnius", "1917-01-01", + "Europe/Vilnius", "1920-07-12", + "Europe/Vilnius", "1940-08-03", + "Europe/Volgograd", "1920-01-03", + "Europe/Volgograd", "1930-06-21", + "Europe/Volgograd", "1991-03-31", + "Europe/Volgograd", "2011-03-27", + "Europe/Zaporozhye", "1930-06-21", + "Europe/Zaporozhye", "1943-10-25", + "Europe/Zurich", "1894-06-01", + "Hongkong", "1904-10-30", + "Hongkong", "1941-12-25", + "Iceland", "1837-01-01", + "Indian/Chagos", "1907-01-01", + "Indian/Chagos", "1996-01-01", + "Indian/Cocos", "1900-01-01", + "Indian/Comoro", "1911-07-01", + "Indian/Kerguelen", "1950-01-01", + "Indian/Mahe", "1906-06-01", + "Indian/Maldives", "1960-01-01", + "Indian/Mauritius", "1907-01-01", + "Indian/Reunion", "1911-06-01", + "Iran", "1946-01-01", + "Iran", "1977-11-01", + "Libya", "1920-01-01", + "Libya", "1959-01-01", + "Libya", "1990-05-04", + "Mexico/BajaNorte", "1924-01-01", + "Mexico/BajaNorte", "1930-11-15", + "Mexico/BajaSur", "1930-11-15", + "Mexico/BajaSur", "1931-10-01", + "Mexico/BajaSur", "1942-04-24", + "Mexico/BajaSur", "1949-01-14", + "Mexico/General", "1930-11-15", + "Mexico/General", "1931-10-01", + "NZ-CHAT", "1957-01-01", + "Pacific/Apia", "1911-01-01", + "Pacific/Chatham", "1957-01-01", + "Pacific/Easter", "1932-09-01", + "Pacific/Enderbury", "1901-01-01", + "Pacific/Fiji", "1915-10-26", + "Pacific/Funafuti", "1901-01-01", + "Pacific/Galapagos", "1986-01-01", + "Pacific/Gambier", "1912-10-01", + "Pacific/Guadalcanal", "1912-10-01", + "Pacific/Guam", "1901-01-01", + "Pacific/Kiritimati", "1901-01-01", + "Pacific/Kosrae", "1901-01-01", + "Pacific/Kosrae", "1969-10-01", + "Pacific/Majuro", "1969-10-01", + "Pacific/Marquesas", "1912-10-01", + "Pacific/Nauru", "1921-01-15", + "Pacific/Nauru", "1944-08-15", + "Pacific/Nauru", "1979-05-01", + "Pacific/Niue", "1901-01-01", + "Pacific/Niue", "1951-01-01", + "Pacific/Norfolk", "1901-01-01", + "Pacific/Norfolk", "1951-01-01", + "Pacific/Pago_Pago", "1911-01-01", + "Pacific/Palau", "1901-01-01", + "Pacific/Pohnpei", "1901-01-01", + "Pacific/Ponape", "1901-01-01", + "Pacific/Port_Moresby", "1895-01-01", + "Pacific/Rarotonga", "1978-11-12", + "Pacific/Saipan", "1969-10-01", + "Pacific/Samoa", "1911-01-01", + "Pacific/Tahiti", "1912-10-01", + "Pacific/Tarawa", "1901-01-01", + "Pacific/Tongatapu", "1901-01-01", + "Pacific/Tongatapu", "1941-01-01", + "Pacific/Wake", "1901-01-01", + "ROK", "1890-01-01", + "ROK", "1904-12-01", + "ROK", "1932-01-01", + "ROK", "1961-08-10", + "ROK", "1968-10-01", + "Singapore", "1905-06-01", + "Singapore", "1941-09-01", + "Singapore", "1942-02-16", + "Singapore", "1982-01-01", + "Turkey", "1880-01-01", + "Turkey", "1910-10-01", + "Turkey", "1978-10-15", + "US/Michigan", "1905-01-01", + "US/Samoa", "1911-01-01", + "W-SU", "1916-07-03", + "W-SU", "1930-06-21", + "W-SU", "1992-01-19", + "W-SU", "2011-03-27" + }; + + LanguageType eLang = LANGUAGE_ENGLISH_US; + SvNumberFormatter aFormatter(m_xContext, eLang); + + for (size_t i=0; i < SAL_N_ELEMENTS(aData); ++i) + { + checkDateInput( aFormatter, aData[i][0], aData[i][1]); + } +} + +void Test::checkDateInput( SvNumberFormatter& rFormatter, const char* pTimezone, const char* pIsoDate ) +{ + icu::TimeZone::adoptDefault( icu::TimeZone::createTimeZone( pTimezone)); + OUString aDate( OUString::createFromAscii(pIsoDate)); + sal_uInt32 nIndex = 0; + double fVal = 0.0; + bool bVal = rFormatter.IsNumberFormat( aDate, nIndex, fVal); + CPPUNIT_ASSERT_MESSAGE("Date not recognized.", bVal); + CPPUNIT_ASSERT_MESSAGE("Format parsed is not date.", + ((rFormatter.GetType(nIndex) & NUMBERFORMAT_DATE) == NUMBERFORMAT_DATE)); + OUString aOutString; + Color *pColor; + rFormatter.GetOutputString( fVal, nIndex, aOutString, &pColor); + CPPUNIT_ASSERT_EQUAL( aDate, aOutString); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } commit c72cd80f4503f54f6c79cdc1ab03b0654663f488 Author: Eike Rathke <er...@redhat.com> Date: Sat Jan 24 02:15:44 2015 +0100 use XCalendar4 local date/time in CalendarWrapper, tdf#63230 Replaces the three-step timezone+DST correction. Hopefully ICU does take these into account, but this needs to be double-rechecked and if necessary correction be implemented at XCalendar4::setLocalDateTime() See also http://userguide.icu-project.org/datetime/calendar#TOC-Ambiguous-Wall-Clock-Time-Resolution Interpreting as standard time for non-existing times sounds like what we need and covers the dreaded "00:00-01:00 doesn't exist" case that decremented the day and was fixed here with the now removed workaround. diff --git a/unotools/source/i18n/calendarwrapper.cxx b/unotools/source/i18n/calendarwrapper.cxx index 6d082f2..27c1b47 100644 --- a/unotools/source/i18n/calendarwrapper.cxx +++ b/unotools/source/i18n/calendarwrapper.cxx @@ -165,42 +165,7 @@ void CalendarWrapper::setLocalDateTime( double fTimeInDays ) { if ( xC.is() ) { - // First set a nearby value to obtain the timezone and DST offset. - // This is necessary to let ICU choose the corresponding - // OlsonTimeZone transitions. Since ICU incorporates also - // historical data even the timezone may differ for different - // dates! (Which was the cause for #i76623# when the timezone of a - // previously set date was used.) Timezone may also include - // seconds, so use milliseconds field as well. - xC->setDateTime( fTimeInDays ); - sal_Int32 nZone1 = getZoneOffsetInMillis(); - sal_Int32 nDST1 = getDSTOffsetInMillis(); - double fLoc = fTimeInDays - (double)(nZone1 + nDST1) / MILLISECONDS_PER_DAY; - xC->setDateTime( fLoc ); - sal_Int32 nZone2 = getZoneOffsetInMillis(); - sal_Int32 nDST2 = getDSTOffsetInMillis(); - // If DSTs differ after calculation, we crossed boundaries. Do it - // again, this time using the DST corrected initial value for the - // real local time. - // See also localtime/gmtime conversion pitfalls at - // http://www.erack.de/download/timetest.c - if ( nDST1 != nDST2 ) - { - fLoc = fTimeInDays - (double)(nZone2 + nDST2) / MILLISECONDS_PER_DAY; - xC->setDateTime( fLoc ); - // #i17222# If the DST onset rule says to switch from 00:00 to - // 01:00 and we tried to set onsetDay 00:00 with DST, the - // result was onsetDay-1 23:00 and no DST, which is not what we - // want. So once again without DST, resulting in onsetDay - // 01:00 and DST. Yes, this seems to be weird, but logically - // correct. - sal_Int32 nDST3 = getDSTOffsetInMillis(); - if ( nDST2 != nDST3 && !nDST3 ) - { - fLoc = fTimeInDays - (double)(nZone2 + nDST3) / MILLISECONDS_PER_DAY; - xC->setDateTime( fLoc ); - } - } + xC->setLocalDateTime( fTimeInDays ); } } catch (const Exception& e) @@ -215,11 +180,7 @@ double CalendarWrapper::getLocalDateTime() const { if ( xC.is() ) { - double fTimeInDays = xC->getDateTime(); - sal_Int32 nZone = getZoneOffsetInMillis(); - sal_Int32 nDST = getDSTOffsetInMillis(); - fTimeInDays += (double)(nZone + nDST) / MILLISECONDS_PER_DAY; - return fTimeInDays; + return xC->getLocalDateTime(); } } catch (const Exception& e) commit cd528c3099ffec4f34565820b923d6385478e44b Author: Eike Rathke <er...@redhat.com> Date: Fri Jan 23 23:10:41 2015 +0100 implement css::i18n::XCalendar4 and LocaleCalendar2 service, tdf#63230 Implementation only, new local date/time routines not used yet from the outside in this step. diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index 3877ca6..11c8bd6 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -57,7 +57,7 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/i18n/LocaleCalendar.hpp> +#include <com/sun/star/i18n/LocaleCalendar2.hpp> #include <com/sun/star/sheet/XFunctionAccess.hpp> #include <boost/scoped_array.hpp> @@ -67,13 +67,13 @@ using namespace com::sun::star::lang; using namespace com::sun::star::sheet; using namespace com::sun::star::uno; -static Reference< XCalendar3 > getLocaleCalendar( void ) +static Reference< XCalendar4 > getLocaleCalendar( void ) { - static Reference< XCalendar3 > xCalendar; + static Reference< XCalendar4 > xCalendar; if( !xCalendar.is() ) { Reference< XComponentContext > xContext = getProcessComponentContext(); - xCalendar = LocaleCalendar::create(xContext); + xCalendar = LocaleCalendar2::create(xContext); } static com::sun::star::lang::Locale aLastLocale; @@ -1857,7 +1857,7 @@ RTLFUNC(MonthName) return; } - Reference< XCalendar3 > xCalendar = getLocaleCalendar(); + Reference< XCalendar4 > xCalendar = getLocaleCalendar(); if( !xCalendar.is() ) { StarBASIC::Error( SbERR_INTERNAL_ERROR ); @@ -1897,7 +1897,7 @@ RTLFUNC(WeekdayName) return; } - Reference< XCalendar3 > xCalendar = getLocaleCalendar(); + Reference< XCalendar4 > xCalendar = getLocaleCalendar(); if( !xCalendar.is() ) { StarBASIC::Error( SbERR_INTERNAL_ERROR ); @@ -2246,7 +2246,7 @@ RTLFUNC(DateDiff) } if( nFirstDay == 0 ) { - Reference< XCalendar3 > xCalendar = getLocaleCalendar(); + Reference< XCalendar4 > xCalendar = getLocaleCalendar(); if( !xCalendar.is() ) { StarBASIC::Error( SbERR_INTERNAL_ERROR ); @@ -2304,7 +2304,7 @@ double implGetDateOfFirstDayInFirstWeek if( nFirstWeek < 0 || nFirstWeek > 3 ) nError = SbERR_BAD_ARGUMENT; - Reference< XCalendar3 > xCalendar; + Reference< XCalendar4 > xCalendar; if( nFirstDay == 0 || nFirstWeek == 0 ) { xCalendar = getLocaleCalendar(); @@ -2505,7 +2505,7 @@ RTLFUNC(FormatDateTime) } } - Reference< XCalendar3 > xCalendar = getLocaleCalendar(); + Reference< XCalendar4 > xCalendar = getLocaleCalendar(); if( !xCalendar.is() ) { StarBASIC::Error( SbERR_INTERNAL_ERROR ); @@ -3329,7 +3329,7 @@ sal_Int16 implGetWeekDay( double aDate, bool bFirstDayParam, sal_Int16 nFirstDay } if( nFirstDay == 0 ) { - Reference< XCalendar3 > xCalendar = getLocaleCalendar(); + Reference< XCalendar4 > xCalendar = getLocaleCalendar(); if( !xCalendar.is() ) { #if HAVE_FEATURE_SCRIPTING diff --git a/i18npool/inc/calendarImpl.hxx b/i18npool/inc/calendarImpl.hxx index 7ec10de..0f67c1e 100644 --- a/i18npool/inc/calendarImpl.hxx +++ b/i18npool/inc/calendarImpl.hxx @@ -19,7 +19,7 @@ #ifndef INCLUDED_I18NPOOL_INC_CALENDARIMPL_HXX #define INCLUDED_I18NPOOL_INC_CALENDARIMPL_HXX -#include <com/sun/star/i18n/XCalendar3.hpp> +#include <com/sun/star/i18n/XCalendar4.hpp> #include <com/sun/star/i18n/CalendarDisplayCode.hpp> #include <com/sun/star/i18n/CalendarFieldIndex.hpp> #include <com/sun/star/i18n/CalendarDisplayIndex.hpp> @@ -36,7 +36,7 @@ namespace com { namespace sun { namespace star { namespace i18n { class CalendarImpl : public cppu::WeakImplHelper2 < - com::sun::star::i18n::XCalendar3, + com::sun::star::i18n::XCalendar4, com::sun::star::lang::XServiceInfo > { @@ -84,6 +84,10 @@ public: virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getGenitiveMonths2() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getPartitiveMonths2() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + // XCalendar4 + virtual void SAL_CALL setLocalDateTime(double TimeInDays) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual double SAL_CALL getLocalDateTime() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + //XServiceInfo virtual OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; @@ -91,14 +95,14 @@ public: private: struct lookupTableItem { - lookupTableItem(const OUString& _uniqueID, com::sun::star::uno::Reference < com::sun::star::i18n::XCalendar3 >& _xCalendar) : + lookupTableItem(const OUString& _uniqueID, com::sun::star::uno::Reference < com::sun::star::i18n::XCalendar4 >& _xCalendar) : uniqueID(_uniqueID), xCalendar(_xCalendar) {} OUString uniqueID; - com::sun::star::uno::Reference < com::sun::star::i18n::XCalendar3 > xCalendar; + com::sun::star::uno::Reference < com::sun::star::i18n::XCalendar4 > xCalendar; }; std::vector<lookupTableItem*> lookupTable; com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xContext; - com::sun::star::uno::Reference < com::sun::star::i18n::XCalendar3 > xCalendar; + com::sun::star::uno::Reference < com::sun::star::i18n::XCalendar4 > xCalendar; }; } } } } diff --git a/i18npool/inc/calendar_gregorian.hxx b/i18npool/inc/calendar_gregorian.hxx index ea06b00..f270779 100644 --- a/i18npool/inc/calendar_gregorian.hxx +++ b/i18npool/inc/calendar_gregorian.hxx @@ -85,6 +85,10 @@ public: virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getGenitiveMonths2() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; virtual com::sun::star::uno::Sequence < CalendarItem2 > SAL_CALL getPartitiveMonths2() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + // XCalendar4 + virtual void SAL_CALL setLocalDateTime(double TimeInDays) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual double SAL_CALL getLocalDateTime() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + //XServiceInfo virtual OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; diff --git a/i18npool/source/calendar/calendarImpl.cxx b/i18npool/source/calendar/calendarImpl.cxx index 4780ce6..68cf9c2 100644 --- a/i18npool/source/calendar/calendarImpl.cxx +++ b/i18npool/source/calendar/calendarImpl.cxx @@ -57,7 +57,7 @@ CalendarImpl::loadDefaultCalendar( const Locale& rLocale ) throw(RuntimeExceptio void SAL_CALL CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) throw (RuntimeException, std::exception) { - Reference < XCalendar3 > xOldCalendar( xCalendar ); // backup + Reference < XCalendar4 > xOldCalendar( xCalendar ); // backup sal_Int32 i; for (i = 0; i < sal::static_int_cast<sal_Int32>(lookupTable.size()); i++) { @@ -155,6 +155,24 @@ CalendarImpl::getDateTime() throw(RuntimeException, std::exception) throw ERROR ; } +void SAL_CALL +CalendarImpl::setLocalDateTime( double fTimeInDays ) throw(RuntimeException, std::exception) +{ + if (xCalendar.is()) + xCalendar->setLocalDateTime( fTimeInDays ); + else + throw ERROR ; +} + +double SAL_CALL +CalendarImpl::getLocalDateTime() throw(RuntimeException, std::exception) +{ + if (xCalendar.is()) + return xCalendar->getLocalDateTime(); + else + throw ERROR ; +} + OUString SAL_CALL CalendarImpl::getUniqueID() throw(RuntimeException, std::exception) { @@ -352,8 +370,9 @@ CalendarImpl::supportsService(const OUString& rServiceName) throw( RuntimeExcept Sequence< OUString > SAL_CALL CalendarImpl::getSupportedServiceNames(void) throw( RuntimeException, std::exception ) { - Sequence< OUString > aRet(1); + Sequence< OUString > aRet(2); aRet[0] = "com.sun.star.i18n.LocaleCalendar"; + aRet[1] = "com.sun.star.i18n.LocaleCalendar2"; return aRet; } diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx index a634c52..d2f513c 100644 --- a/i18npool/source/calendar/calendar_gregorian.cxx +++ b/i18npool/source/calendar/calendar_gregorian.cxx @@ -317,6 +317,40 @@ Calendar_gregorian::getDateTime() throw(RuntimeException, std::exception) return fR / U_MILLIS_PER_DAY; } +void SAL_CALL +Calendar_gregorian::setLocalDateTime( double fTimeInDays ) throw(RuntimeException, std::exception) +{ + // See setDateTime() for why the rounding. + double fM = fTimeInDays * U_MILLIS_PER_DAY; + double fR = rtl::math::round( fM ); + SAL_INFO_IF( fM != fR, "i18npool", + "Calendar_gregorian::setLocalDateTime: " << std::fixed << fM << " rounded to " << fR); + int32_t nZoneOffset, nDSTOffset; + UErrorCode status; + body->getTimeZone().getOffset( fR, TRUE, nZoneOffset, nDSTOffset, status = U_ZERO_ERROR ); + if ( !U_SUCCESS(status) ) throw ERROR; + body->setTime( fR - (nZoneOffset + nDSTOffset), status = U_ZERO_ERROR ); + if ( !U_SUCCESS(status) ) throw ERROR; + getValue(); +} + +double SAL_CALL +Calendar_gregorian::getLocalDateTime() throw(RuntimeException, std::exception) +{ + if (fieldSet) { + setValue(); + getValue(); + } + UErrorCode status; + double fTime = body->getTime( status = U_ZERO_ERROR ); + if ( !U_SUCCESS(status) ) throw ERROR; + int32_t nZoneOffset = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR ); + if ( !U_SUCCESS(status) ) throw ERROR; + int32_t nDSTOffset = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR ); + if ( !U_SUCCESS(status) ) throw ERROR; + return (fTime + (nZoneOffset + nDSTOffset)) / U_MILLIS_PER_DAY; +} + // map field value from gregorian calendar to other calendar, it can be overwritten by derived class. // By using eraArray, it can take care Japanese and Taiwan ROC calendar. void Calendar_gregorian::mapFromGregorian() throw(RuntimeException) diff --git a/i18npool/source/registerservices/registerservices.cxx b/i18npool/source/registerservices/registerservices.cxx index 634c711..a38e969 100644 --- a/i18npool/source/registerservices/registerservices.cxx +++ b/i18npool/source/registerservices/registerservices.cxx @@ -288,6 +288,9 @@ static const struct InstancesArray { { "com.sun.star.i18n.LocaleCalendar", "com.sun.star.i18n.CalendarImpl", &CalendarImpl_CreateInstance }, + { "com.sun.star.i18n.LocaleCalendar2", + "com.sun.star.i18n.CalendarImpl", + &CalendarImpl_CreateInstance }, { "com.sun.star.i18n.Calendar_gregorian", "com.sun.star.i18n.Calendar_gregorian", &Calendar_gregorian_CreateInstance }, diff --git a/i18npool/util/i18npool.component b/i18npool/util/i18npool.component index 9617a8b..1b74fd7 100644 --- a/i18npool/util/i18npool.component +++ b/i18npool/util/i18npool.component @@ -44,6 +44,7 @@ </implementation> <implementation name="com.sun.star.i18n.CalendarImpl"> <service name="com.sun.star.i18n.LocaleCalendar"/> + <service name="com.sun.star.i18n.LocaleCalendar2"/> </implementation> <implementation name="com.sun.star.i18n.Calendar_ROC"> <service name="com.sun.star.i18n.Calendar_ROC"/> diff --git a/include/unotools/calendarwrapper.hxx b/include/unotools/calendarwrapper.hxx index a03f906..de7443b 100644 --- a/include/unotools/calendarwrapper.hxx +++ b/include/unotools/calendarwrapper.hxx @@ -35,13 +35,13 @@ namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star { namespace i18n { - class XCalendar3; + class XCalendar4; } }}} class UNOTOOLS_DLLPUBLIC CalendarWrapper { - ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCalendar3 > xC; + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCalendar4 > xC; DateTime aEpochStart; // 1Jan1970 @@ -61,10 +61,9 @@ public: void setDateTime( double fTimeInDays ); /// get UTC date/time double getDateTime() const; - /// convenience method to set local date/time - void setLocalDateTime( double fTimeInDays ); - /// convenience method to get local date/time - double getLocalDateTime() const; + + // For local setDateTime() and getDateTime() see further down at wrapper + // implementations of XCalendar4. // wrapper implementations of XCalendar @@ -96,6 +95,13 @@ public: ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getGenitiveMonths() const; ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getPartitiveMonths() const; + // wrapper implementations of XCalendar4 + + /// set local date/time + void setLocalDateTime( double fTimeInDays ); + /// get local date/time + double getLocalDateTime() const; + // convenience methods /// get epoch start (should be 01Jan1970) diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 0028b46..63f242c 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -224,6 +224,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/i18n,\ IndexEntrySupplier \ InputSequenceChecker \ LocaleCalendar \ + LocaleCalendar2 \ LocaleData \ NativeNumberSupplier \ NumberFormatMapper \ @@ -2752,6 +2753,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/i18n,\ XBreakIterator \ XCalendar \ XCalendar3 \ + XCalendar4 \ XCharacterClassification \ XCollator \ XExtendedCalendar \ diff --git a/offapi/com/sun/star/i18n/LocaleCalendar2.idl b/offapi/com/sun/star/i18n/LocaleCalendar2.idl new file mode 100644 index 0000000..fd878af --- /dev/null +++ b/offapi/com/sun/star/i18n/LocaleCalendar2.idl @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef __com_sun_star_i18n_LocaleCalendar2_idl__ +#define __com_sun_star_i18n_LocaleCalendar2_idl__ + +#include <com/sun/star/i18n/XCalendar4.idl> + +module com { module sun { module star { module i18n { + +/** Access a locale specific calendar. + + @since LibreOffice 4.5 + */ +published service LocaleCalendar2 : XCalendar4; + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/i18n/XCalendar.idl b/offapi/com/sun/star/i18n/XCalendar.idl index 4dd5dda..fd89a52 100644 --- a/offapi/com/sun/star/i18n/XCalendar.idl +++ b/offapi/com/sun/star/i18n/XCalendar.idl @@ -53,17 +53,17 @@ published interface XCalendar : com::sun::star::uno::XInterface string getUniqueID(); /** - Set the date/time as an offset to the start of the calendar at - 1-Jan-1970 00:00. The integer part represents the number of days - passed since start date. The fractional part represents + Set the UTC date/time as an offset to the start of the calendar + at 1-Jan-1970 00:00. The integer part represents the number of + days passed since start date. The fractional part represents fractions of a day, thus 0.5 means 12 hours. */ void setDateTime( [in] double nTimeInDays ); /** - Get the date/time as an offset to the start of the calendar at - 1-Jan-1970 00:00. The integer part represents the number of days - passed since start date. The fractional part represents + Get the UTC date/time as an offset to the start of the calendar + at 1-Jan-1970 00:00. The integer part represents the number of + days passed since start date. The fractional part represents fractions of a day, thus 0.5 means 12 hours. */ double getDateTime(); diff --git a/offapi/com/sun/star/i18n/XCalendar4.idl b/offapi/com/sun/star/i18n/XCalendar4.idl new file mode 100644 index 0000000..4a1cffa --- /dev/null +++ b/offapi/com/sun/star/i18n/XCalendar4.idl @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef __com_sun_star_i18n_XCalendar4_idl__ +#define __com_sun_star_i18n_XCalendar4_idl__ + +#include <com/sun/star/i18n/Calendar3.idl> + + +module com { module sun { module star { module i18n { + + + +/** This interface provides access to locale specific calendar + systems. + + <p> It is derived from ::com::sun::star::i18n::XCalendar3 and + provides additional methods to set and get the local time. </p> + + @since LibreOffice 4.5 + */ +published interface XCalendar4 : com::sun::star::i18n::XCalendar3 +{ + /** Set the local date/time as an offset to the start of the + calendar at 1-Jan-1970 00:00. The integer part represents the + number of days passed since start date. The fractional part + represents fractions of a day, thus 0.5 means 12 hours. + + The actual timezone and daylight saving time offsets effective + at the given date and time are considered and subtracted before + setting the UTC time at the calendar. + */ + void setLocalDateTime( [in] double TimeInDays ); + + /** Get the local date/time as an offset to the start of the + calendar at 1-Jan-1970 00:00. The integer part represents the + number of days passed since start date. The fractional part + represents fractions of a day, thus 0.5 means 12 hours. + + The actual timezone and daylight saving time offsets effective + at the given date and time are considered and added to the UTC + time at the calendar. + */ + double getLocalDateTime(); + +}; + +}; }; }; }; + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index 4e1f3cd..9449874 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -28,7 +28,7 @@ #include <unotools/calendarwrapper.hxx> #include <unotools/localedatawrapper.hxx> #include <com/sun/star/i18n/CalendarFieldIndex.hpp> -#include <com/sun/star/i18n/LocaleCalendar.hpp> +#include <com/sun/star/i18n/LocaleCalendar2.hpp> #include <unotools/digitgroupingiterator.hxx> #include <svl/zforlist.hxx> @@ -44,7 +44,7 @@ #endif #if NF_TEST_CALENDAR #include <comphelper/processfactory.hxx> -#include <com/sun/star/i18n/XCalendar3.hpp> +#include <com/sun/star/i18n/XCalendar4.hpp> #endif @@ -1974,7 +1974,7 @@ input for the following reasons: sal_Int32 nZoneInMillis, nDST1InMillis, nDST2InMillis; uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - uno::Reference< i18n::XCalendar3 > xCal = i18n::LocaleCalendar::create(xContext); + uno::Reference< i18n::XCalendar4 > xCal = i18n::LocaleCalendar2::create(xContext); for ( const entry* p = cals; p->lan; ++p ) { aLocale.Language = OUString::createFromAscii( p->lan ); diff --git a/unotools/source/i18n/calendarwrapper.cxx b/unotools/source/i18n/calendarwrapper.cxx index c39f5f7..6d082f2 100644 --- a/unotools/source/i18n/calendarwrapper.cxx +++ b/unotools/source/i18n/calendarwrapper.cxx @@ -20,7 +20,7 @@ #include <rtl/strbuf.hxx> #include <unotools/calendarwrapper.hxx> #include <com/sun/star/i18n/CalendarFieldIndex.hpp> -#include <com/sun/star/i18n/LocaleCalendar.hpp> +#include <com/sun/star/i18n/LocaleCalendar2.hpp> using namespace ::com::sun::star; using namespace ::com::sun::star::i18n; @@ -34,7 +34,7 @@ CalendarWrapper::CalendarWrapper( : aEpochStart( Date( 1, 1, 1970 ) ) { - xC = LocaleCalendar::create(rxContext); + xC = LocaleCalendar2::create(rxContext); } CalendarWrapper::~CalendarWrapper() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits