From 38fbf2fd31f5cd99b500914d6037b1d06b608645 Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 30 Aug 2018 08:41:25 +0000 Subject: [PATCH] ICU-59180.0.1.tar.gz --- icuSources/common/rbtok.cpp | 1 + icuSources/data/misc/metaZones.txt | 8 +- icuSources/data/misc/windowsZones.txt | 2 +- icuSources/data/misc/zoneinfo64.txt | 31 +- icuSources/i18n/islamcal.cpp | 2 +- icuSources/test/intltest/calregts.cpp | 454 +++++++++++++++----------- icuSources/test/intltest/calregts.h | 14 +- icuSources/tools/tzcode/icuzones | 49 +++ 8 files changed, 344 insertions(+), 217 deletions(-) diff --git a/icuSources/common/rbtok.cpp b/icuSources/common/rbtok.cpp index edf9f8a9..6104c127 100644 --- a/icuSources/common/rbtok.cpp +++ b/icuSources/common/rbtok.cpp @@ -61,6 +61,7 @@ int32_t RuleBasedTokenizer::tokenize(int32_t maxTokens, RuleBasedTokenRange *out const UTrie *trie = &fData->fTrie; while (outTokenP < outTokenLimit) { // LookAheadResults lookAheadMatches; // added in RBBI, #12081/r38387 + result = prev; // fallback initialization, prevent uninitialized use c = UTEXT_NEXT32(text); if (c == U_SENTINEL) { diff --git a/icuSources/data/misc/metaZones.txt b/icuSources/data/misc/metaZones.txt index e90883d2..564992a3 100644 --- a/icuSources/data/misc/metaZones.txt +++ b/icuSources/data/misc/metaZones.txt @@ -344,7 +344,6 @@ metaZones:table(nofallback){ SH{"Atlantic/St_Helena"} SL{"Africa/Freetown"} SN{"Africa/Dakar"} - ST{"Africa/Sao_Tome"} TG{"Africa/Lome"} } Galapagos{ @@ -1030,6 +1029,13 @@ metaZones:table(nofallback){ "Africa:Sao_Tome"{ { "GMT", + "1970-01-01 00:00", + "2018-01-01 01:00", + } + { + "Africa_Western", + "2018-01-01 01:00", + "9999-12-31 23:59", } } "Africa:Tripoli"{ diff --git a/icuSources/data/misc/windowsZones.txt b/icuSources/data/misc/windowsZones.txt index ec393d91..d7f143cf 100644 --- a/icuSources/data/misc/windowsZones.txt +++ b/icuSources/data/misc/windowsZones.txt @@ -316,7 +316,6 @@ windowsZones:table(nofallback){ SH{"Atlantic/St_Helena"} SL{"Africa/Freetown"} SN{"Africa/Dakar"} - ST{"Africa/Sao_Tome"} TG{"Africa/Lome"} } "Haiti Standard Time"{ @@ -744,6 +743,7 @@ windowsZones:table(nofallback){ GQ{"Africa/Malabo"} NE{"Africa/Niamey"} NG{"Africa/Lagos"} + ST{"Africa/Sao_Tome"} TD{"Africa/Ndjamena"} TN{"Africa/Tunis"} ZZ{"Etc/GMT-1"} diff --git a/icuSources/data/misc/zoneinfo64.txt b/icuSources/data/misc/zoneinfo64.txt index 154470b3..8eed0199 100644 --- a/icuSources/data/misc/zoneinfo64.txt +++ b/icuSources/data/misc/zoneinfo64.txt @@ -3,9 +3,9 @@ // License & terms of use: http://www.unicode.org/copyright.html#License //--------------------------------------------------------- // Build tool: tz2icu -// Build date: Tue Oct 24 17:35:27 2017 +// Build date: Tue Jan 23 20:51:55 2018 // tz database: ftp://ftp.iana.org/tz/ -// tz version: 2017c +// tz version: 2018c // ICU version: 60.1 //--------------------------------------------------------- // >> !!! >> THIS IS A MACHINE-GENERATED FILE << !!! << @@ -13,7 +13,7 @@ //--------------------------------------------------------- zoneinfo64:table(nofallback) { - TZVersion { "2017c" } + TZVersion { "2018c" } Zones:array { /* ACT */ :int { 354 } //Z#0 /* AET */ :int { 366 } //Z#1 @@ -24,7 +24,7 @@ zoneinfo64:table(nofallback) { trans:intvector { -1830383032 } typeOffsets:intvector { -968, 0, 0, 0 } typeMap:bin { "01" } - links:intvector { 5, 11, 13, 21, 22, 27, 38, 51, 52, 54, 55, 346 } + links:intvector { 5, 11, 13, 21, 22, 27, 38, 51, 52, 55, 346 } } //Z#5 /* Africa/Accra */ :table { trans:intvector { -1640995148, -1556841600, -1546388400, -1525305600, -1514852400, -1493769600, -1483316400, -1462233600, -1451780400, -1430611200, -1420158000, -1399075200, -1388622000, -1367539200, -1357086000, -1336003200, -1325550000, -1304380800, -1293927600, -1272844800, -1262391600, -1241308800, -1230855600, -1209772800, -1199319600, -1178150400, -1167697200, -1146614400, -1136161200, -1115078400, -1104625200, -1083542400, -1073089200, -1051920000, -1041466800, -1020384000, -1009930800, -988848000, -978394800, -957312000, -946858800, -925689600, -915236400, -894153600, -883700400, -862617600, -852164400 } @@ -154,7 +154,12 @@ zoneinfo64:table(nofallback) { /* Africa/Nouakchott */ :int { 5 } //Z#51 /* Africa/Ouagadougou */ :int { 5 } //Z#52 /* Africa/Porto-Novo */ :int { 36 } //Z#53 - /* Africa/Sao_Tome */ :int { 5 } //Z#54 + /* Africa/Sao_Tome */ :table { + transPre32:intvector { -1, 1581055280 } + trans:intvector { -1830381795, 1514768400 } + typeOffsets:intvector { 1616, 0, -2205, 0, 0, 0, 3600, 0 } + typeMap:bin { "010203" } + } //Z#54 /* Africa/Timbuktu */ :int { 5 } //Z#55 /* Africa/Tripoli */ :table { trans:intvector { -1577926364, -574902000, -568087200, -512175600, -504928800, -449888400, -441856800, -347158800, 378684000, 386463600, 402271200, 417999600, 433807200, 449622000, 465429600, 481590000, 496965600, 512953200, 528674400, 544230000, 560037600, 575852400, 591660000, 607388400, 623196000, 641775600, 844034400, 860108400, 875916000, 1352505600, 1364515200, 1382659200 } @@ -358,8 +363,8 @@ zoneinfo64:table(nofallback) { finalYear:int { 2008 } } //Z#91 /* America/Campo_Grande */ :table { - trans:intvector { -1767212492, -1206954000, -1191358800, -1175371200, -1159822800, -633816000, -622065600, -602280000, -591829200, -570744000, -560206800, -539121600, -531349200, -191361600, -184194000, -155160000, -150066000, -128894400, -121122000, -99950400, -89586000, -68414400, -57963600, 499752000, 511239600, 530596800, 540270000, 562132800, 571201200, 592977600, 602046000, 624427200, 634705200, 656481600, 666759600, 687931200, 697604400, 719985600, 728449200, 750830400, 761713200, 782280000, 793162800, 813729600, 824007600, 844574400, 856062000, 876110400, 888721200, 908078400, 919566000, 938923200, 951620400, 970977600, 982465200, 1003032000, 1013914800, 1036296000, 1045364400, 1066536000, 1076814000, 1099368000, 1108868400, 1129435200, 1140318000, 1162699200, 1172372400, 1192334400, 1203217200, 1224388800, 1234666800, 1255838400, 1266721200, 1287288000, 1298170800, 1318737600, 1330225200, 1350792000, 1361070000, 1382241600, 1392519600, 1413691200, 1424574000, 1445140800, 1456023600, 1476590400, 1487473200, 1508040000, 1518922800, 1540094400, 1550372400, 1571544000, 1581822000, 1602993600, 1613876400, 1634443200, 1645326000, 1665892800, 1677380400, 1697342400, 1708225200, 1729396800, 1739674800, 1760846400, 1771729200, 1792296000, 1803178800, 1823745600, 1834628400, 1855195200, 1866078000, 1887249600, 1897527600, 1918699200, 1928977200, 1950148800, 1960426800, 1981598400, 1992481200, 2013048000, 2024535600, 2044497600, 2055380400, 2076552000, 2086830000, 2108001600, 2118884400, 2139451200 } - transPost32:intvector { 0, -2144633296, 0, -2124066496 } + trans:intvector { -1767212492, -1206954000, -1191358800, -1175371200, -1159822800, -633816000, -622065600, -602280000, -591829200, -570744000, -560206800, -539121600, -531349200, -191361600, -184194000, -155160000, -150066000, -128894400, -121122000, -99950400, -89586000, -68414400, -57963600, 499752000, 511239600, 530596800, 540270000, 562132800, 571201200, 592977600, 602046000, 624427200, 634705200, 656481600, 666759600, 687931200, 697604400, 719985600, 728449200, 750830400, 761713200, 782280000, 793162800, 813729600, 824007600, 844574400, 856062000, 876110400, 888721200, 908078400, 919566000, 938923200, 951620400, 970977600, 982465200, 1003032000, 1013914800, 1036296000, 1045364400, 1066536000, 1076814000, 1099368000, 1108868400, 1129435200, 1140318000, 1162699200, 1172372400, 1192334400, 1203217200, 1224388800, 1234666800, 1255838400, 1266721200, 1287288000, 1298170800, 1318737600, 1330225200, 1350792000, 1361070000, 1382241600, 1392519600, 1413691200, 1424574000, 1445140800, 1456023600, 1476590400, 1487473200, 1508040000, 1518922800, 1541304000, 1550372400, 1572753600, 1581822000, 1604203200, 1613876400, 1636257600, 1645326000, 1667707200, 1677380400, 1699156800, 1708225200, 1730606400, 1739674800, 1762056000, 1771729200, 1793505600, 1803178800, 1825560000, 1834628400, 1857009600, 1866078000, 1888459200, 1897527600, 1919908800, 1928977200, 1951358400, 1960426800, 1983412800, 1992481200, 2014862400, 2024535600, 2046312000, 2055380400, 2077761600, 2086830000, 2109211200, 2118884400, 2140660800 } + transPost32:intvector { 0, -2144633296, 0, -2122252096 } typeOffsets:intvector { -13108, 0, -14400, 0, -14400, 3600 } typeMap:bin { "01020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102" } finalRule { "Brazil" } @@ -416,8 +421,8 @@ zoneinfo64:table(nofallback) { typeMap:bin { "020102" } } //Z#103 /* America/Cuiaba */ :table { - trans:intvector { -1767212140, -1206954000, -1191358800, -1175371200, -1159822800, -633816000, -622065600, -602280000, -591829200, -570744000, -560206800, -539121600, -531349200, -191361600, -184194000, -155160000, -150066000, -128894400, -121122000, -99950400, -89586000, -68414400, -57963600, 499752000, 511239600, 530596800, 540270000, 562132800, 571201200, 592977600, 602046000, 624427200, 634705200, 656481600, 666759600, 687931200, 697604400, 719985600, 728449200, 750830400, 761713200, 782280000, 793162800, 813729600, 824007600, 844574400, 856062000, 876110400, 888721200, 908078400, 919566000, 938923200, 951620400, 970977600, 982465200, 1003032000, 1013914800, 1036296000, 1045364400, 1099368000, 1108868400, 1129435200, 1140318000, 1162699200, 1172372400, 1192334400, 1203217200, 1224388800, 1234666800, 1255838400, 1266721200, 1287288000, 1298170800, 1318737600, 1330225200, 1350792000, 1361070000, 1382241600, 1392519600, 1413691200, 1424574000, 1445140800, 1456023600, 1476590400, 1487473200, 1508040000, 1518922800, 1540094400, 1550372400, 1571544000, 1581822000, 1602993600, 1613876400, 1634443200, 1645326000, 1665892800, 1677380400, 1697342400, 1708225200, 1729396800, 1739674800, 1760846400, 1771729200, 1792296000, 1803178800, 1823745600, 1834628400, 1855195200, 1866078000, 1887249600, 1897527600, 1918699200, 1928977200, 1950148800, 1960426800, 1981598400, 1992481200, 2013048000, 2024535600, 2044497600, 2055380400, 2076552000, 2086830000, 2108001600, 2118884400, 2139451200 } - transPost32:intvector { 0, -2144633296, 0, -2124066496 } + trans:intvector { -1767212140, -1206954000, -1191358800, -1175371200, -1159822800, -633816000, -622065600, -602280000, -591829200, -570744000, -560206800, -539121600, -531349200, -191361600, -184194000, -155160000, -150066000, -128894400, -121122000, -99950400, -89586000, -68414400, -57963600, 499752000, 511239600, 530596800, 540270000, 562132800, 571201200, 592977600, 602046000, 624427200, 634705200, 656481600, 666759600, 687931200, 697604400, 719985600, 728449200, 750830400, 761713200, 782280000, 793162800, 813729600, 824007600, 844574400, 856062000, 876110400, 888721200, 908078400, 919566000, 938923200, 951620400, 970977600, 982465200, 1003032000, 1013914800, 1036296000, 1045364400, 1099368000, 1108868400, 1129435200, 1140318000, 1162699200, 1172372400, 1192334400, 1203217200, 1224388800, 1234666800, 1255838400, 1266721200, 1287288000, 1298170800, 1318737600, 1330225200, 1350792000, 1361070000, 1382241600, 1392519600, 1413691200, 1424574000, 1445140800, 1456023600, 1476590400, 1487473200, 1508040000, 1518922800, 1541304000, 1550372400, 1572753600, 1581822000, 1604203200, 1613876400, 1636257600, 1645326000, 1667707200, 1677380400, 1699156800, 1708225200, 1730606400, 1739674800, 1762056000, 1771729200, 1793505600, 1803178800, 1825560000, 1834628400, 1857009600, 1866078000, 1888459200, 1897527600, 1919908800, 1928977200, 1951358400, 1960426800, 1983412800, 1992481200, 2014862400, 2024535600, 2046312000, 2055380400, 2077761600, 2086830000, 2109211200, 2118884400, 2140660800 } + transPost32:intvector { 0, -2144633296, 0, -2122252096 } typeOffsets:intvector { -13460, 0, -14400, 0, -14400, 3600 } typeMap:bin { "0102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102" } finalRule { "Brazil" } @@ -1040,8 +1045,8 @@ zoneinfo64:table(nofallback) { typeMap:bin { "0401030102010201020102010201050105" } } //Z#201 /* America/Sao_Paulo */ :table { - trans:intvector { -1767214412, -1206957600, -1191362400, -1175374800, -1159826400, -633819600, -622069200, -602283600, -591832800, -570747600, -560210400, -539125200, -531352800, -195426000, -184197600, -155163600, -150069600, -128898000, -121125600, -99954000, -89589600, -68418000, -57967200, 499748400, 511236000, 530593200, 540266400, 562129200, 571197600, 592974000, 602042400, 624423600, 634701600, 656478000, 666756000, 687927600, 697600800, 719982000, 728445600, 750826800, 761709600, 782276400, 793159200, 813726000, 824004000, 844570800, 856058400, 876106800, 888717600, 908074800, 919562400, 938919600, 951616800, 970974000, 982461600, 1003028400, 1013911200, 1036292400, 1045360800, 1066532400, 1076810400, 1099364400, 1108864800, 1129431600, 1140314400, 1162695600, 1172368800, 1192330800, 1203213600, 1224385200, 1234663200, 1255834800, 1266717600, 1287284400, 1298167200, 1318734000, 1330221600, 1350788400, 1361066400, 1382238000, 1392516000, 1413687600, 1424570400, 1445137200, 1456020000, 1476586800, 1487469600, 1508036400, 1518919200, 1540090800, 1550368800, 1571540400, 1581818400, 1602990000, 1613872800, 1634439600, 1645322400, 1665889200, 1677376800, 1697338800, 1708221600, 1729393200, 1739671200, 1760842800, 1771725600, 1792292400, 1803175200, 1823742000, 1834624800, 1855191600, 1866074400, 1887246000, 1897524000, 1918695600, 1928973600, 1950145200, 1960423200, 1981594800, 1992477600, 2013044400, 2024532000, 2044494000, 2055376800, 2076548400, 2086826400, 2107998000, 2118880800, 2139447600 } - transPost32:intvector { 0, -2144636896, 0, -2124070096 } + trans:intvector { -1767214412, -1206957600, -1191362400, -1175374800, -1159826400, -633819600, -622069200, -602283600, -591832800, -570747600, -560210400, -539125200, -531352800, -195426000, -184197600, -155163600, -150069600, -128898000, -121125600, -99954000, -89589600, -68418000, -57967200, 499748400, 511236000, 530593200, 540266400, 562129200, 571197600, 592974000, 602042400, 624423600, 634701600, 656478000, 666756000, 687927600, 697600800, 719982000, 728445600, 750826800, 761709600, 782276400, 793159200, 813726000, 824004000, 844570800, 856058400, 876106800, 888717600, 908074800, 919562400, 938919600, 951616800, 970974000, 982461600, 1003028400, 1013911200, 1036292400, 1045360800, 1066532400, 1076810400, 1099364400, 1108864800, 1129431600, 1140314400, 1162695600, 1172368800, 1192330800, 1203213600, 1224385200, 1234663200, 1255834800, 1266717600, 1287284400, 1298167200, 1318734000, 1330221600, 1350788400, 1361066400, 1382238000, 1392516000, 1413687600, 1424570400, 1445137200, 1456020000, 1476586800, 1487469600, 1508036400, 1518919200, 1541300400, 1550368800, 1572750000, 1581818400, 1604199600, 1613872800, 1636254000, 1645322400, 1667703600, 1677376800, 1699153200, 1708221600, 1730602800, 1739671200, 1762052400, 1771725600, 1793502000, 1803175200, 1825556400, 1834624800, 1857006000, 1866074400, 1888455600, 1897524000, 1919905200, 1928973600, 1951354800, 1960423200, 1983409200, 1992477600, 2014858800, 2024532000, 2046308400, 2055376800, 2077758000, 2086826400, 2109207600, 2118880800, 2140657200 } + transPost32:intvector { 0, -2144636896, 0, -2122255696 } typeOffsets:intvector { -11188, 0, -10800, 0, -10800, 3600 } typeMap:bin { "01020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102010201020102" } finalRule { "Brazil" } @@ -1645,7 +1650,7 @@ zoneinfo64:table(nofallback) { } //Z#322 /* Asia/Tokyo */ :table { transPre32:intvector { -1, 1707254896 } - trans:intvector { -683794800, -672393600, -654764400, -640944000, -620290800, -609494400, -588841200, -578044800 } + trans:intvector { -683802000, -672314400, -654771600, -640864800, -620298000, -609415200, -588848400, -577965600 } typeOffsets:intvector { 33539, 0, 32400, 0, 32400, 3600 } typeMap:bin { "010201020102010201" } links:intvector { 323, 527, 529 } @@ -3083,7 +3088,7 @@ zoneinfo64:table(nofallback) { 9, 1, -1, 7200, 1, 3, 1, -1, 7200, 1, 3600 } //_#3 Brazil:intvector { - 9, 15, -1, 0, 0, 1, 15, -1, 0, 0, 3600 + 10, 1, -1, 0, 0, 1, 15, -1, 0, 0, 3600 } //_#4 C-Eur:intvector { 2, -31, -1, 7200, 1, 9, -31, -1, 7200, 1, 3600 diff --git a/icuSources/i18n/islamcal.cpp b/icuSources/i18n/islamcal.cpp index 4fd0e07d..b84bedfa 100644 --- a/icuSources/i18n/islamcal.cpp +++ b/icuSources/i18n/islamcal.cpp @@ -614,7 +614,7 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status) days = julianDay - ASTRONOMICAL_EPOC; } // Use the civil calendar approximation, which is just arithmetic - year = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631.0 ); + year = (int32_t)ClockMath::floorDivide(30 * (int64_t)days + 10646, (int64_t)10631); month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 ); month = month<11?month:11; startDate = monthStart(year, month); diff --git a/icuSources/test/intltest/calregts.cpp b/icuSources/test/intltest/calregts.cpp index a3c4afaf..a95bd238 100644 --- a/icuSources/test/intltest/calregts.cpp +++ b/icuSources/test/intltest/calregts.cpp @@ -1,17 +1,18 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /******************************************************************** - * COPYRIGHT: + * COPYRIGHT: * Copyright (c) 1997-2016, International Business Machines Corporation * and others. All Rights Reserved. ********************************************************************/ - + #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING #include "calregts.h" +#include "unicode/calendar.h" #include "unicode/gregocal.h" #include "unicode/simpletz.h" #include "unicode/smpdtfmt.h" @@ -33,7 +34,7 @@ const UDate CalendarRegressionTest::LATEST_SUPPORTED_MILLIS = 4503599627370 #define CASE(id,test) case id: name = #test; if (exec) { logln(#test "---"); logln((UnicodeString)""); test(); } break -void +void CalendarRegressionTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ ) { // if (exec) logln((UnicodeString)"TestSuite NumberFormatRegressionTest"); @@ -68,7 +69,7 @@ CalendarRegressionTest::runIndexedTest( int32_t index, UBool exec, const char* & CASE(27,test4145158); CASE(28,test4145983); CASE(29,test4147269); - + CASE(30,Test4149677); CASE(31,Test4162587); CASE(32,Test4165343); @@ -90,33 +91,35 @@ CalendarRegressionTest::runIndexedTest( int32_t index, UBool exec, const char* & CASE(48,TestT8596); CASE(49,Test9019); CASE(50,TestT9452); + CASE(51,TestPersianCalOverflow); + CASE(52,TestIslamicCalOverflow); default: name = ""; break; } } const char* CalendarRegressionTest::FIELD_NAME [] = { - "ERA", - "YEAR", - "MONTH", - "WEEK_OF_YEAR", - "WEEK_OF_MONTH", - "DAY_OF_MONTH", - "DAY_OF_YEAR", - "DAY_OF_WEEK", - "DAY_OF_WEEK_IN_MONTH", - "AM_PM", - "HOUR", - "HOUR_OF_DAY", - "MINUTE", - "SECOND", - "MILLISECOND", - "ZONE_OFFSET", + "ERA", + "YEAR", + "MONTH", + "WEEK_OF_YEAR", + "WEEK_OF_MONTH", + "DAY_OF_MONTH", + "DAY_OF_YEAR", + "DAY_OF_WEEK", + "DAY_OF_WEEK_IN_MONTH", + "AM_PM", + "HOUR", + "HOUR_OF_DAY", + "MINUTE", + "SECOND", + "MILLISECOND", + "ZONE_OFFSET", "DST_OFFSET", "YEAR_WOY", "DOW_LOCAL" }; -UBool +UBool CalendarRegressionTest::failure(UErrorCode status, const char* msg) { if(U_FAILURE(status)) { @@ -130,7 +133,7 @@ CalendarRegressionTest::failure(UErrorCode status, const char* msg) /* * bug 4100311 */ -void +void CalendarRegressionTest::test4100311() { UErrorCode status = U_ZERO_ERROR; @@ -223,14 +226,14 @@ CalendarRegressionTest::Test9019() failure(status, "->add(UCAL_MONTH,8)"); printdate(cal1.getAlias(), "cal1 (lenient) after adding 8 months:") ; printdate(cal2.getAlias(), "cal2 (expected date):") ; - + if(!cal1->equals(*cal2,status)) { errln("Error: cal1 != cal2.\n"); } failure(status, "equals"); } -void +void CalendarRegressionTest::printdate(GregorianCalendar *cal, const char *string) { UErrorCode status = U_ZERO_ERROR; @@ -247,8 +250,8 @@ CalendarRegressionTest::printdate(GregorianCalendar *cal, const char *string) /** * @bug 4031502 */ -void -CalendarRegressionTest::test4031502() +void +CalendarRegressionTest::test4031502() { // This bug actually occurs on Windows NT as well, and doesn't // require the host zone to be set; it can be set in Java. @@ -290,7 +293,7 @@ CalendarRegressionTest::test4031502() } delete cal; } - if (bad) + if (bad) errln("TimeZone problems with GC"); // delete [] ids; // TODO: bad APIs delete ids; @@ -299,7 +302,7 @@ CalendarRegressionTest::test4031502() /** * @bug 4035301 */ -void CalendarRegressionTest::test4035301() +void CalendarRegressionTest::test4035301() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *c = new GregorianCalendar(98, 8, 7,status); @@ -318,7 +321,7 @@ void CalendarRegressionTest::test4035301() /** * @bug 4040996 */ -void CalendarRegressionTest::test4040996() +void CalendarRegressionTest::test4040996() { int32_t count = 0; StringEnumeration* ids = TimeZone::createEnumeration(-8 * 60 * 60 * 1000); @@ -326,7 +329,7 @@ void CalendarRegressionTest::test4040996() dataerrln("Unable to create TimeZone enumeration."); return; } - UErrorCode status = U_ZERO_ERROR; + UErrorCode status = U_ZERO_ERROR; count = ids->count(status); (void)count; // Suppress set but not used warning. SimpleTimeZone *pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, *ids->snext(status)); @@ -342,7 +345,7 @@ void CalendarRegressionTest::test4040996() calendar->set(UCAL_SECOND, 30); logln(UnicodeString("MONTH: ") + calendar->get(UCAL_MONTH, status)); - logln(UnicodeString("DAY_OF_MONTH: ") + + logln(UnicodeString("DAY_OF_MONTH: ") + calendar->get(UCAL_DATE, status)); logln(UnicodeString("MINUTE: ") + calendar->get(UCAL_MINUTE, status)); logln(UnicodeString("SECOND: ") + calendar->get(UCAL_SECOND, status)); @@ -352,7 +355,7 @@ void CalendarRegressionTest::test4040996() //instead of the date it was set to. //This happens when adding MILLISECOND or MINUTE also logln(UnicodeString("MONTH: ") + calendar->get(UCAL_MONTH, status)); - logln(UnicodeString("DAY_OF_MONTH: ") + + logln(UnicodeString("DAY_OF_MONTH: ") + calendar->get(UCAL_DATE, status)); logln(UnicodeString("MINUTE: ") + calendar->get(UCAL_MINUTE, status)); logln(UnicodeString("SECOND: ") + calendar->get(UCAL_SECOND, status)); @@ -369,7 +372,7 @@ void CalendarRegressionTest::test4040996() /** * @bug 4051765 */ -void CalendarRegressionTest::test4051765() +void CalendarRegressionTest::test4051765() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); @@ -400,12 +403,12 @@ void CalendarRegressionTest::test4059524() { logln("ERA: " + Calendar::get(Calendar::ERA)); logln("YEAR: " + Calendar::get(Calendar::YEAR)); logln("MONTH: " + Calendar::get(Calendar::MONTH)); - logln("WEEK_OF_YEAR: " + + logln("WEEK_OF_YEAR: " + Calendar::get(Calendar::WEEK_OF_YEAR)); - logln("WEEK_OF_MONTH: " + + logln("WEEK_OF_MONTH: " + Calendar::get(Calendar::WEEK_OF_MONTH)); logln("DATE: " + Calendar::get(Calendar::DATE)); - logln("DAY_OF_MONTH: " + + logln("DAY_OF_MONTH: " + Calendar::get(Calendar::DAY_OF_MONTH)); logln("DAY_OF_YEAR: " + Calendar::get(Calendar::DAY_OF_YEAR)); logln("DAY_OF_WEEK: " + Calendar::get(Calendar::DAY_OF_WEEK)); @@ -421,18 +424,18 @@ void CalendarRegressionTest::test4059524() { + (Calendar::get(Calendar::ZONE_OFFSET)/(60*60*1000))); logln("DST_OFFSET: " + (Calendar::get(Calendar::DST_OFFSET)/(60*60*1000))); - calendar = new GregorianCalendar(1997,3,10); - Calendar::getTime(); + calendar = new GregorianCalendar(1997,3,10); + Calendar::getTime(); logln("April 10, 1997"); logln("ERA: " + Calendar::get(Calendar::ERA)); logln("YEAR: " + Calendar::get(Calendar::YEAR)); logln("MONTH: " + Calendar::get(Calendar::MONTH)); - logln("WEEK_OF_YEAR: " + + logln("WEEK_OF_YEAR: " + Calendar::get(Calendar::WEEK_OF_YEAR)); - logln("WEEK_OF_MONTH: " + + logln("WEEK_OF_MONTH: " + Calendar::get(Calendar::WEEK_OF_MONTH)); logln("DATE: " + Calendar::get(Calendar::DATE)); - logln("DAY_OF_MONTH: " + + logln("DAY_OF_MONTH: " + Calendar::get(Calendar::DAY_OF_MONTH)); logln("DAY_OF_YEAR: " + Calendar::get(Calendar::DAY_OF_YEAR)); logln("DAY_OF_WEEK: " + Calendar::get(Calendar::DAY_OF_WEEK)); @@ -461,7 +464,7 @@ void CalendarRegressionTest::test4059654() { delete gc; return; } - + gc->set(1997, 3, 1, 15, 16, 17); // April 1, 1997 gc->set(UCAL_HOUR, 0); @@ -482,11 +485,11 @@ void CalendarRegressionTest::test4059654() { /** * @bug 4061476 */ -void CalendarRegressionTest::test4061476() +void CalendarRegressionTest::test4061476() { UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("ddMMMyy"), Locale::getUK(),status); - Calendar *cal = Calendar::createInstance(TimeZone::createTimeZone("GMT"), + Calendar *cal = Calendar::createInstance(TimeZone::createTimeZone("GMT"), Locale::getUK(),status); if(U_FAILURE(status)) { dataerrln("Error creating Calendar: %s", u_errorName(status)); @@ -515,7 +518,7 @@ void CalendarRegressionTest::test4061476() /** * @bug 4070502 */ -void CalendarRegressionTest::test4070502() +void CalendarRegressionTest::test4070502() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = new GregorianCalendar(status); @@ -540,12 +543,12 @@ void CalendarRegressionTest::test4070502() *

* @param date The date to start from */ -UDate -CalendarRegressionTest::getAssociatedDate(UDate d, UErrorCode& status) +UDate +CalendarRegressionTest::getAssociatedDate(UDate d, UErrorCode& status) { GregorianCalendar *cal = new GregorianCalendar(status); cal->setTime(d,status); - //cal.add(field, amount); //<-- PROBLEM SEEN WITH field = DATE,MONTH + //cal.add(field, amount); //<-- PROBLEM SEEN WITH field = DATE,MONTH // cal.getTime(); // <--- REMOVE THIS TO SEE BUG for (;;) { int32_t wd = cal->get(UCAL_DAY_OF_WEEK, status); @@ -556,7 +559,7 @@ CalendarRegressionTest::getAssociatedDate(UDate d, UErrorCode& status) else break; } - + UDate dd = cal->getTime(status); delete cal; return dd; @@ -565,13 +568,13 @@ CalendarRegressionTest::getAssociatedDate(UDate d, UErrorCode& status) /** * @bug 4071197 */ -void CalendarRegressionTest::test4071197() +void CalendarRegressionTest::test4071197() { dowTest(FALSE); dowTest(TRUE); } -void CalendarRegressionTest::dowTest(UBool lenient) +void CalendarRegressionTest::dowTest(UBool lenient) { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = new GregorianCalendar(status); @@ -590,9 +593,9 @@ void CalendarRegressionTest::dowTest(UBool lenient) //logln(cal.getTime().toString()); if (min != UCAL_SUNDAY || max != UCAL_SATURDAY) errln("FAIL: Min/max bad"); - if (dow < min || dow > max) + if (dow < min || dow > max) errln("FAIL: Day of week %d out of range [%d,%d]\n", dow, min, max); - if (dow != UCAL_SUNDAY) + if (dow != UCAL_SUNDAY) errln(UnicodeString("FAIL: Day of week should be SUNDAY Got ") + dow); if(U_FAILURE(status)) { @@ -621,14 +624,14 @@ void CalendarRegressionTest::dowTest(UBool lenient) errln("Error getting actual minimum: %s", u_errorName(status)); return; } - + delete cal; } /** * @bug 4071385 */ -void CalendarRegressionTest::test4071385() +void CalendarRegressionTest::test4071385() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); @@ -649,7 +652,7 @@ void CalendarRegressionTest::test4071385() /** * @bug 4073929 */ -void CalendarRegressionTest::test4073929() +void CalendarRegressionTest::test4073929() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *foo1 = new GregorianCalendar(1997, 8, 27,status); @@ -700,7 +703,7 @@ void CalendarRegressionTest::test4073929() /** * @bug 4083167 */ -void CalendarRegressionTest::test4083167() +void CalendarRegressionTest::test4083167() { UErrorCode status = U_ZERO_ERROR; TimeZone *saveZone = TimeZone::createDefault(); @@ -720,7 +723,7 @@ void CalendarRegressionTest::test4083167() int32_t sec = cal->get(UCAL_SECOND, status); int32_t msec = cal->get(UCAL_MILLISECOND, status); double firstMillisInDay = hr * 3600000 + min * 60000 + sec * 1000 + msec; - + //logln("Current time: " + firstDate.toString()); for (int32_t validity=0; validity<30; validity++) { @@ -731,7 +734,7 @@ void CalendarRegressionTest::test4083167() sec = cal->get(UCAL_SECOND, status); msec = cal->get(UCAL_MILLISECOND, status); double millisInDay = hr * 3600000.0 + min * 60000.0 + sec * 1000.0 + msec; - if (firstMillisInDay != millisInDay) + if (firstMillisInDay != millisInDay) errln(UnicodeString("Day has shifted ") + lastDate); } //} @@ -747,18 +750,18 @@ void CalendarRegressionTest::test4083167() /** * @bug 4086724 */ -void CalendarRegressionTest::test4086724() +void CalendarRegressionTest::test4086724() { UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *date; TimeZone *saveZone = TimeZone::createDefault(); Locale saveLocale = Locale::getDefault(); //try { - Locale::setDefault(Locale::getUK(),status); + Locale::setDefault(Locale::getUK(),status); TimeZone *newZone = TimeZone::createTimeZone("GMT"); TimeZone::setDefault(*newZone); - date = new SimpleDateFormat(UnicodeString("dd MMM yyy (zzzz) 'is in week' ww"),status); - Calendar *cal = Calendar::createInstance(status); + date = new SimpleDateFormat(UnicodeString("dd MMM yyy (zzzz) 'is in week' ww"),status); + Calendar *cal = Calendar::createInstance(status); if(U_FAILURE(status)) { dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal; @@ -766,20 +769,20 @@ void CalendarRegressionTest::test4086724() delete date; return; } - cal->set(1997,UCAL_SEPTEMBER,30); - UDate now = cal->getTime(status); + cal->set(1997,UCAL_SEPTEMBER,30); + UDate now = cal->getTime(status); UnicodeString temp; FieldPosition pos(FieldPosition::DONT_CARE); - logln(date->format(now, temp, pos)); - cal->set(1997,UCAL_JANUARY,1); - now=cal->getTime(status); - logln(date->format(now,temp, pos)); - cal->set(1997,UCAL_JANUARY,8); - now=cal->getTime(status); - logln(date->format(now,temp, pos)); - cal->set(1996,UCAL_DECEMBER,31); - now=cal->getTime(status); - logln(date->format(now,temp, pos)); + logln(date->format(now, temp, pos)); + cal->set(1997,UCAL_JANUARY,1); + now=cal->getTime(status); + logln(date->format(now,temp, pos)); + cal->set(1997,UCAL_JANUARY,8); + now=cal->getTime(status); + logln(date->format(now,temp, pos)); + cal->set(1996,UCAL_DECEMBER,31); + now=cal->getTime(status); + logln(date->format(now,temp, pos)); //} //finally { Locale::setDefault(saveLocale,status); @@ -798,35 +801,35 @@ delete saveZone; */ void CalendarRegressionTest::test4092362() { UErrorCode status = U_ZERO_ERROR; - GregorianCalendar *cal1 = new GregorianCalendar(1997, 10, 11, 10, 20, 40,status); + GregorianCalendar *cal1 = new GregorianCalendar(1997, 10, 11, 10, 20, 40,status); if (U_FAILURE(status)) { dataerrln("Fail new GregorianCalendar: %s", u_errorName(status)); delete cal1; return; } - /*cal1.set( Calendar::YEAR, 1997 ); - cal1.set( Calendar::MONTH, 10 ); - cal1.set( Calendar::DATE, 11 ); - cal1.set( Calendar::HOUR, 10 ); - cal1.set( Calendar::MINUTE, 20 ); + /*cal1.set( Calendar::YEAR, 1997 ); + cal1.set( Calendar::MONTH, 10 ); + cal1.set( Calendar::DATE, 11 ); + cal1.set( Calendar::HOUR, 10 ); + cal1.set( Calendar::MINUTE, 20 ); cal1.set( Calendar::SECOND, 40 ); */ - logln( UnicodeString(" Cal1 = ") + cal1->getTime(status) ); - logln( UnicodeString(" Cal1 time in ms = ") + cal1->get(UCAL_MILLISECOND,status) ); + logln( UnicodeString(" Cal1 = ") + cal1->getTime(status) ); + logln( UnicodeString(" Cal1 time in ms = ") + cal1->get(UCAL_MILLISECOND,status) ); for (int32_t k = 0; k < 100 ; k++) ; - GregorianCalendar *cal2 = new GregorianCalendar(1997, 10, 11, 10, 20, 40,status); - /*cal2.set( Calendar::YEAR, 1997 ); - cal2.set( Calendar::MONTH, 10 ); - cal2.set( Calendar::DATE, 11 ); - cal2.set( Calendar::HOUR, 10 ); - cal2.set( Calendar::MINUTE, 20 ); + GregorianCalendar *cal2 = new GregorianCalendar(1997, 10, 11, 10, 20, 40,status); + /*cal2.set( Calendar::YEAR, 1997 ); + cal2.set( Calendar::MONTH, 10 ); + cal2.set( Calendar::DATE, 11 ); + cal2.set( Calendar::HOUR, 10 ); + cal2.set( Calendar::MINUTE, 20 ); cal2.set( Calendar::SECOND, 40 ); */ - logln( UnicodeString(" Cal2 = ") + cal2->getTime(status) ); - logln( UnicodeString(" Cal2 time in ms = ") + cal2->get(UCAL_MILLISECOND,status) ); - if( *cal1 != *cal2 ) + logln( UnicodeString(" Cal2 = ") + cal2->getTime(status) ); + logln( UnicodeString(" Cal2 time in ms = ") + cal2->get(UCAL_MILLISECOND,status) ); + if( *cal1 != *cal2 ) errln("Fail: Milliseconds randomized"); delete cal1; @@ -836,7 +839,7 @@ void CalendarRegressionTest::test4092362() { /** * @bug 4095407 */ -void CalendarRegressionTest::test4095407() +void CalendarRegressionTest::test4095407() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *a = new GregorianCalendar(1997,UCAL_NOVEMBER, 13,status); @@ -855,13 +858,13 @@ void CalendarRegressionTest::test4095407() /** * @bug 4096231 */ -void CalendarRegressionTest::test4096231() +void CalendarRegressionTest::test4096231() { UErrorCode status = U_ZERO_ERROR; TimeZone *GMT = TimeZone::createTimeZone("GMT"); TimeZone *PST = TimeZone::createTimeZone("PST"); int32_t sec = 0, min = 0, hr = 0, day = 1, month = 10, year = 1997; - + Calendar *cal1 = new GregorianCalendar(*PST,status); if (U_FAILURE(status)) { dataerrln("Failure new GregorianCalendar: %s", u_errorName(status)); @@ -872,7 +875,7 @@ void CalendarRegressionTest::test4096231() } cal1->setTime(880698639000.0,status); // Issue 1: Changing the timezone doesn't change the - // represented time. The old API, pre 1.2.2a requires + // represented time. The old API, pre 1.2.2a requires // setTime to be called in order to update the time fields after the time // zone has been set. int32_t h1,h2; @@ -925,13 +928,13 @@ void CalendarRegressionTest::test4096231() /** * @bug 4096539 */ -void CalendarRegressionTest::test4096539() +void CalendarRegressionTest::test4096539() { UErrorCode status = U_ZERO_ERROR; int32_t y [] = {31,28,31,30,31,30,31,31,30,31,30,31}; for (int32_t x=0;x<12;x++) { - GregorianCalendar *gc = new + GregorianCalendar *gc = new GregorianCalendar(1997,x,y[x], status); if (U_FAILURE(status)) { dataerrln("Fail new GregorianCalendar: %s", u_errorName(status)); @@ -952,13 +955,13 @@ void CalendarRegressionTest::test4096539() errln(UnicodeString("Fail: Want ") + m + " Got " + m2); delete gc; } - + } /** * @bug 4100311 */ -void CalendarRegressionTest::test41003112() +void CalendarRegressionTest::test41003112() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = (GregorianCalendar*)Calendar::createInstance(status); @@ -979,51 +982,51 @@ void CalendarRegressionTest::test41003112() /** * @bug 4103271 */ -void CalendarRegressionTest::test4103271() +void CalendarRegressionTest::test4103271() { UErrorCode status = U_ZERO_ERROR; - SimpleDateFormat sdf(status); - int32_t numYears=40, startYear=1997, numDays=15; - UnicodeString output, testDesc, str, str2; - GregorianCalendar *testCal = (GregorianCalendar*)Calendar::createInstance(status); + SimpleDateFormat sdf(status); + int32_t numYears=40, startYear=1997, numDays=15; + UnicodeString output, testDesc, str, str2; + GregorianCalendar *testCal = (GregorianCalendar*)Calendar::createInstance(status); if(U_FAILURE(status)) { dataerrln("Error creating calendar: %s", u_errorName(status)); delete testCal; return; } testCal->clear(); - sdf.adoptCalendar(testCal); - sdf.applyPattern("EEE dd MMM yyyy 'WOY'ww'-'YYYY 'DOY'DDD"); + sdf.adoptCalendar(testCal); + sdf.applyPattern("EEE dd MMM yyyy 'WOY'ww'-'YYYY 'DOY'DDD"); UBool fail = FALSE; - for (int32_t firstDay=1; firstDay<=2; firstDay++) { - for (int32_t minDays=1; minDays<=7; minDays++) { - testCal->setMinimalDaysInFirstWeek((uint8_t)minDays); - testCal->setFirstDayOfWeek((UCalendarDaysOfWeek)firstDay); - testDesc = (UnicodeString("Test") + firstDay + minDays); + for (int32_t firstDay=1; firstDay<=2; firstDay++) { + for (int32_t minDays=1; minDays<=7; minDays++) { + testCal->setMinimalDaysInFirstWeek((uint8_t)minDays); + testCal->setFirstDayOfWeek((UCalendarDaysOfWeek)firstDay); + testDesc = (UnicodeString("Test") + firstDay + minDays); logln(testDesc + " => 1st day of week=" + firstDay + ", minimum days in first week=" + - minDays); - for (int32_t j=startYear; j<=startYear+numYears; j++) { - testCal->set(j,11,25); - for(int32_t i=0; iadd(UCAL_DATE,1,status); - UnicodeString calWOY; + minDays); + for (int32_t j=startYear; j<=startYear+numYears; j++) { + testCal->set(j,11,25); + for(int32_t i=0; iadd(UCAL_DATE,1,status); + UnicodeString calWOY; int32_t actWOY = testCal->get(UCAL_WEEK_OF_YEAR,status); if (actWOY < 1 || actWOY > 53) { - UDate d = testCal->getTime(status); + UDate d = testCal->getTime(status); //calWOY = String.valueOf(actWOY); UnicodeString temp; FieldPosition pos(FieldPosition::DONT_CARE); - output = testDesc + " - " + sdf.format(d,temp,pos) + "\t"; - output = output + "\t" + actWOY; - logln(output); + output = testDesc + " - " + sdf.format(d,temp,pos) + "\t"; + output = output + "\t" + actWOY; + logln(output); fail = TRUE; } - } - } - } - } + } + } + } + } int32_t DATA [] = { 3, 52, 52, 52, 52, 52, 52, 52, @@ -1049,7 +1052,7 @@ void CalendarRegressionTest::test4103271() fail = TRUE; } logln(""); - + // Now compute the time from the fields, and make sure we // get the same answer back. This is a round-trip test. UDate save = testCal->getTime(status); @@ -1084,7 +1087,7 @@ void CalendarRegressionTest::test4103271() makeDate(1998, UCAL_DECEMBER, 31), makeDate(1999, UCAL_JANUARY, 1) }; - + testCal->setMinimalDaysInFirstWeek(3); testCal->setFirstDayOfWeek(UCAL_SUNDAY); int32_t i = 0; @@ -1183,9 +1186,9 @@ void CalendarRegressionTest::test4103271() UDate after = ADDROLL_date[i+1]; testCal->setTime(before,status); - if (ADDROLL_bool[i/2]) + if (ADDROLL_bool[i/2]) testCal->add(UCAL_WEEK_OF_YEAR, amount,status); - else + else testCal->roll(UCAL_WEEK_OF_YEAR, amount,status); UDate got = testCal->getTime(status); str.remove(); @@ -1206,9 +1209,9 @@ void CalendarRegressionTest::test4103271() else logln(" ok"); testCal->setTime(after,status); - if (ADDROLL_bool[i/2]) + if (ADDROLL_bool[i/2]) testCal->add(UCAL_WEEK_OF_YEAR, -amount,status); - else + else testCal->roll(UCAL_WEEK_OF_YEAR, -amount,status); got = testCal->getTime(status); str.remove(); @@ -1222,14 +1225,14 @@ void CalendarRegressionTest::test4103271() } else logln(" ok"); } - if (fail) + if (fail) errln("Fail: Week of year misbehaving"); -} +} /** * @bug 4106136 */ -void CalendarRegressionTest::test4106136() +void CalendarRegressionTest::test4106136() { UErrorCode status = U_ZERO_ERROR; Locale saveLocale = Locale::getDefault(); @@ -1260,10 +1263,10 @@ void CalendarRegressionTest::test4106136() /** * @bug 4108764 */ -void CalendarRegressionTest::test4108764() +void CalendarRegressionTest::test4108764() { UErrorCode status = U_ZERO_ERROR; - Calendar *cal = Calendar::createInstance(status); + Calendar *cal = Calendar::createInstance(status); if(U_FAILURE(status)) { dataerrln("Error creating calendar %s", u_errorName(status)); delete cal; @@ -1277,29 +1280,29 @@ void CalendarRegressionTest::test4108764() cal->setTime(d11,status); - cal->clear( UCAL_MINUTE ); - logln(UnicodeString("") + cal->getTime(status)); + cal->clear( UCAL_MINUTE ); + logln(UnicodeString("") + cal->getTime(status)); if (cal->getTime(status) != d01) errln("Fail: clear(MINUTE) broken"); - cal->set( UCAL_SECOND, 0 ); - logln(UnicodeString("") + cal->getTime(status)); + cal->set( UCAL_SECOND, 0 ); + logln(UnicodeString("") + cal->getTime(status)); if (cal->getTime(status) != d00) errln("Fail: set(SECOND, 0) broken"); cal->setTime(d11,status); - cal->set( UCAL_SECOND, 0 ); - logln(UnicodeString("") + cal->getTime(status)); + cal->set( UCAL_SECOND, 0 ); + logln(UnicodeString("") + cal->getTime(status)); if (cal->getTime(status) != d10) errln("Fail: set(SECOND, 0) broken #2"); - cal->clear( UCAL_MINUTE ); - logln(UnicodeString("") + cal->getTime(status)); + cal->clear( UCAL_MINUTE ); + logln(UnicodeString("") + cal->getTime(status)); if (cal->getTime(status) != d00) errln("Fail: clear(MINUTE) broken #2"); cal->clear(); - logln(UnicodeString("") + cal->getTime(status)); + logln(UnicodeString("") + cal->getTime(status)); if (cal->getTime(status) != epoch) errln(UnicodeString("Fail: clear() broken Want ") + epoch); @@ -1309,7 +1312,7 @@ void CalendarRegressionTest::test4108764() /** * @bug 4114578 */ -void CalendarRegressionTest::test4114578() +void CalendarRegressionTest::test4114578() { UErrorCode status = U_ZERO_ERROR; double ONE_HOUR = 60*60*1000; @@ -1324,7 +1327,7 @@ void CalendarRegressionTest::test4114578() UDate cease = makeDate(1998, UCAL_OCTOBER, 25, 0, 0) + 2*ONE_HOUR; UBool fail = FALSE; - + const int32_t ADD = 1; const int32_t ROLL = 2; @@ -1344,7 +1347,7 @@ void CalendarRegressionTest::test4114578() UDate date = DATA[i]; int32_t amt = (int32_t) DATA[i+2]; double expectedChange = DATA[i+3]; - + log(UnicodeString("") + date); cal->setTime(date,status); @@ -1378,7 +1381,7 @@ void CalendarRegressionTest::test4114578() * @bug 4118384 * Make sure maximum for HOUR field is 11, not 12. */ -void CalendarRegressionTest::test4118384() +void CalendarRegressionTest::test4118384() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); @@ -1436,7 +1439,7 @@ void CalendarRegressionTest::test4118384() * @bug 4125881 * Check isLeapYear for BC years. */ -void CalendarRegressionTest::test4125881() +void CalendarRegressionTest::test4125881() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = (GregorianCalendar*) Calendar::createInstance(status); @@ -1505,7 +1508,7 @@ void CalendarRegressionTest::test4125892() { * @bug 4141665 * GregorianCalendar::equals() ignores cutover date */ -void CalendarRegressionTest::test4141665() +void CalendarRegressionTest::test4141665() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = new GregorianCalendar(status); @@ -1534,7 +1537,7 @@ void CalendarRegressionTest::test4141665() * Bug states that ArrayIndexOutOfBoundsException is thrown by GregorianCalendar::roll() * when IllegalArgumentException should be. */ -void CalendarRegressionTest::test4142933() +void CalendarRegressionTest::test4142933() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(status); @@ -1555,7 +1558,7 @@ void CalendarRegressionTest::test4142933() //catch (Exception e) { //errln("Test failed. Unexpected exception is thrown: " + e); //e.printStackTrace(); - //} + //} delete calendar; } @@ -1568,7 +1571,7 @@ void CalendarRegressionTest::test4142933() * report to therefore only check the behavior of a calendar with a zero raw * offset zone. */ -void CalendarRegressionTest::test4145158() +void CalendarRegressionTest::test4145158() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(status); @@ -1587,7 +1590,7 @@ void CalendarRegressionTest::test4145158() calendar->setTime(makeDate(INT32_MAX),status); int32_t year2 = calendar->get(UCAL_YEAR,status); int32_t era2 = calendar->get(UCAL_ERA,status); - + if (year1 == year2 && era1 == era2) { errln("Fail: Long.MIN_VALUE or Long.MAX_VALUE wrapping around"); } @@ -1601,13 +1604,13 @@ void CalendarRegressionTest::test4145158() */ // {sfb} this is not directly applicable in C++, since all // possible doubles are not representable by our Calendar. -// In Java, all longs are representable. +// In Java, all longs are representable. // We can determine limits programmatically // Using DBL_MAX is a bit of a hack, since for large doubles // Calendar gets squirrely and doesn't behave in any sort // of linear fashion (ie years jump around, up/down, etc) for a // small change in millis. -void CalendarRegressionTest::test4145983() +void CalendarRegressionTest::test4145983() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(status); @@ -1638,7 +1641,7 @@ void CalendarRegressionTest::test4145983() * report test was written. In reality the bug is restricted to the DAY_OF_YEAR * field. - liu 6/29/98 */ -void CalendarRegressionTest::test4147269() +void CalendarRegressionTest::test4147269() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(status); @@ -1656,7 +1659,7 @@ void CalendarRegressionTest::test4147269() // use getActualMaximum(), since that's too costly. int32_t max = calendar->getMaximum((UCalendarDateFields)field); int32_t value = max+1; - calendar->set((UCalendarDateFields)field, value); + calendar->set((UCalendarDateFields)field, value); //try { calendar->getTime(status); // Force time computation // We expect an exception to be thrown. If we fall through @@ -1666,7 +1669,7 @@ void CalendarRegressionTest::test4147269() ", date before: " + date + ", date after: " + calendar->getTime(status) + ", value: " + value + " (max = " + max +")"); - //} catch (IllegalArgumentException e) {} + //} catch (IllegalArgumentException e) {} } delete calendar; @@ -1678,15 +1681,15 @@ void CalendarRegressionTest::test4147269() * doesn't behave as a pure Julian calendar. * CANNOT REPRODUCE THIS BUG */ -void -CalendarRegressionTest::Test4149677() +void +CalendarRegressionTest::Test4149677() { UErrorCode status = U_ZERO_ERROR; - TimeZone *zones [] = { + TimeZone *zones [] = { TimeZone::createTimeZone("GMT"), TimeZone::createTimeZone("PST"), - TimeZone::createTimeZone("EAT") + TimeZone::createTimeZone("EAT") }; if(U_FAILURE(status)) { errln("Couldn't create zones"); @@ -1719,7 +1722,7 @@ CalendarRegressionTest::Test4149677() if(U_FAILURE(status)) errln("setGregorianChange failed"); // to obtain a pure Julian calendar - + UBool is100Leap = calendar->isLeapYear(100); if (!is100Leap) { UnicodeString temp; @@ -1729,7 +1732,7 @@ CalendarRegressionTest::Test4149677() } delete calendar; } - + // no need for cleanup- zones were adopted } @@ -1738,22 +1741,22 @@ CalendarRegressionTest::Test4149677() * Calendar and Date HOUR broken. If HOUR is out-of-range, Calendar * and Date classes will misbehave. */ -void -CalendarRegressionTest::Test4162587() +void +CalendarRegressionTest::Test4162587() { UErrorCode status = U_ZERO_ERROR; TimeZone *savedef = TimeZone::createDefault(); TimeZone *tz = TimeZone::createTimeZone("PST"); //TimeZone::adoptDefault(tz); TimeZone::setDefault(*tz); - + GregorianCalendar *cal = new GregorianCalendar(tz, status); if(U_FAILURE(status)) { dataerrln("Couldn't create calendar.: %s", u_errorName(status)); return; } UDate d0, dPlus, dMinus; - + for(int32_t i=0; i<5; ++i) { if (i>0) logln("---"); @@ -1795,8 +1798,8 @@ CalendarRegressionTest::Test4162587() * @bug 4165343 * Adding 12 months behaves differently from adding 1 year */ -void -CalendarRegressionTest::Test4165343() +void +CalendarRegressionTest::Test4165343() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(1996, UCAL_FEBRUARY, 29, status); @@ -1808,7 +1811,7 @@ CalendarRegressionTest::Test4165343() if(U_FAILURE(status)) errln("Couldn't getTime (1)"); logln(UnicodeString("init date: ") + start); - calendar->add(UCAL_MONTH, 12, status); + calendar->add(UCAL_MONTH, 12, status); if(U_FAILURE(status)) errln("Couldn't add(MONTH, 12)"); UDate date1 = calendar->getTime(status); @@ -1837,8 +1840,8 @@ CalendarRegressionTest::Test4165343() * @bug 4166109 * GregorianCalendar.getActualMaximum() does not account for first day of week. */ -void -CalendarRegressionTest::Test4166109() +void +CalendarRegressionTest::Test4166109() { /* Test month: * @@ -1862,7 +1865,7 @@ CalendarRegressionTest::Test4166109() calendar->set(1998, UCAL_MARCH, 1); calendar->setMinimalDaysInFirstWeek(1); logln(UnicodeString("Date: ") + calendar->getTime(status)); // 888817448000 - + int32_t firstInMonth = calendar->get(UCAL_DATE, status); if(U_FAILURE(status)) errln("get(D_O_M) failed"); @@ -1892,8 +1895,8 @@ CalendarRegressionTest::Test4166109() * @bug 4167060 * Calendar.getActualMaximum(YEAR) works wrong. */ -void -CalendarRegressionTest::Test4167060() +void +CalendarRegressionTest::Test4167060() { UErrorCode status = U_ZERO_ERROR; UCalendarDateFields field = UCAL_YEAR; @@ -1924,7 +1927,7 @@ CalendarRegressionTest::Test4167060() GregorianCalendar *calendar = calendars[j]; if (k == 1) { calendar->setGregorianChange(EARLIEST_SUPPORTED_MILLIS, status); - } + } else if (k == 2) { calendar->setGregorianChange(LATEST_SUPPORTED_MILLIS, status); } @@ -1963,7 +1966,7 @@ CalendarRegressionTest::Test4167060() " => " + format->format(dateAfter, temp)); if (valid && newYear != years[i]) { errln(UnicodeString(" FAIL: ") + newYear + " should be valid; date, month and time shouldn't change"); - } + } // {sfb} this next line is a hack, but it should work since if a // double has an exponent, adding 1 should not yield the same double else if (!valid && /*newYear == years[i]*/ dateAfter + 1.0 == dateAfter) { @@ -2206,9 +2209,9 @@ void CalendarRegressionTest::TestJ81() { } status = U_ZERO_ERROR; int32_t amount = DATA[i].amount * (sign==MINUS?-1:1); - UDate date = cutover + + UDate date = cutover + (sign==PLUS ? DATA[i].before : DATA[i].after); - UDate expected = cutover + + UDate expected = cutover + (sign==PLUS ? DATA[i].after : DATA[i].before); cal.setTime(date, status); if (U_FAILURE(status)) { @@ -2232,18 +2235,18 @@ void CalendarRegressionTest::TestJ81() { continue; } if (result == expected) { - logln((UnicodeString)"Ok: {" + + logln((UnicodeString)"Ok: {" + fmt.format(date, temp.remove()) + "}(" + date/ONE_DAY + - (action==ADD?") add ":") roll ") + + (action==ADD?") add ":") roll ") + amount + " " + FIELD_NAME[DATA[i].field] + " -> {" + fmt.format(result, temp2.remove()) + - "}(" + result/ONE_DAY + ")"); + "}(" + result/ONE_DAY + ")"); } else { - errln((UnicodeString)"FAIL: {" + + errln((UnicodeString)"FAIL: {" + fmt.format(date, temp.remove()) + "}(" + date/ONE_DAY + - (action==ADD?") add ":") roll ") + + (action==ADD?") add ":") roll ") + amount + " " + FIELD_NAME[DATA[i].field] + " -> {" + fmt.format(result, temp2.remove()) + "}(" + result/ONE_DAY + "), expect {" + @@ -2254,7 +2257,7 @@ void CalendarRegressionTest::TestJ81() { } } } - + /** * Test fieldDifference(). */ @@ -2306,11 +2309,11 @@ void CalendarRegressionTest::TestJ438(void) { if (failure(ec, "fieldDifference")) break; - { + { Calendar *cal2 = cal.clone(); UErrorCode ec2 = U_ZERO_ERROR; - cal2->setTime(date1, ec2); + cal2->setTime(date1, ec2); int32_t dy2 = cal2->fieldDifference(date2, Calendar::YEAR, ec2); int32_t dm2 = cal2->fieldDifference(date2, Calendar::MONTH, ec2); @@ -2574,13 +2577,13 @@ void CalendarRegressionTest::TestWeekShift() { // In pass one, change the first day of week so that the weeks // shift in August 2001. In pass two, change the minimal days // in the first week so that the weeks shift in August 2001. - // August 2001 + // August 2001 // Su Mo Tu We Th Fr Sa // 1 2 3 4 // 5 6 7 8 9 10 11 // 12 13 14 15 16 17 18 // 19 20 21 22 23 24 25 - // 26 27 28 29 30 31 + // 26 27 28 29 30 31 for (int32_t pass=0; pass<2; ++pass) { if (pass==0) { cal.setFirstDayOfWeek(UCAL_WEDNESDAY); @@ -2659,7 +2662,7 @@ void CalendarRegressionTest::TestTimeZoneTransitionAdd() { errln("FAIL: StringEnumeration::unext"); break; } - + TimeZone *t = TimeZone::createTimeZone(id); if (t == NULL) { errln("FAIL: TimeZone::createTimeZone"); @@ -2713,7 +2716,7 @@ CalendarRegressionTest::makeDate(int32_t y, int32_t m, int32_t d, cal->clear(); cal->set(UCAL_YEAR, y); - + if(m != 0) cal->set(UCAL_MONTH, m); if(d != 0) cal->set(UCAL_DATE, d); if(hr != 0) cal->set(UCAL_HOUR, hr); @@ -2946,4 +2949,65 @@ void CalendarRegressionTest::TestT9452(void) { } } +/** + * @bug ticket 13454 + */ +void CalendarRegressionTest::TestPersianCalOverflow(void) { + const char* localeID = "bs_Cyrl@calendar=persian"; + UErrorCode status = U_ZERO_ERROR; + Calendar* cal = Calendar::createInstance(Locale(localeID), status); + if(U_FAILURE(status)) { + dataerrln("FAIL: Calendar::createInstance for localeID %s: %s", localeID, u_errorName(status)); + } else { + int32_t maxMonth = cal->getMaximum(UCAL_MONTH); + int32_t maxDayOfMonth = cal->getMaximum(UCAL_DATE); + int32_t jd, month, dayOfMonth; + for (jd = 67023580; jd <= 67023584; jd++) { // year 178171, int32_t overflow if jd >= 67023582 + status = U_ZERO_ERROR; + cal->clear(); + cal->set(UCAL_JULIAN_DAY, jd); + month = cal->get(UCAL_MONTH, status); + dayOfMonth = cal->get(UCAL_DATE, status); + if ( U_FAILURE(status) ) { + errln("FAIL: Calendar->get MONTH/DATE for localeID %s, julianDay %d, status %s", localeID, jd, u_errorName(status)); + } else if (month > maxMonth || dayOfMonth > maxDayOfMonth) { + errln("FAIL: localeID %s, julianDay %d; maxMonth %d, got month %d; maxDayOfMonth %d, got dayOfMonth %d", + localeID, jd, maxMonth, month, maxDayOfMonth, dayOfMonth); + } + } + delete cal; + } +} + +/** + * @bug tickets 12661, 13538 + */ +void CalendarRegressionTest::TestIslamicCalOverflow(void) { + const char* localeID = "ar@calendar=islamic-civil"; + UErrorCode status = U_ZERO_ERROR; + Calendar* cal = Calendar::createInstance(Locale(localeID), status); + if(U_FAILURE(status)) { + dataerrln("FAIL: Calendar::createInstance for localeID %s: %s", localeID, u_errorName(status)); + } else { + int32_t maxMonth = cal->getMaximum(UCAL_MONTH); + int32_t maxDayOfMonth = cal->getMaximum(UCAL_DATE); + int32_t jd, year, month, dayOfMonth; + for (jd = 73530872; jd <= 73530876; jd++) { // year 202002, int32_t overflow if jd >= 73530874 + status = U_ZERO_ERROR; + cal->clear(); + cal->set(UCAL_JULIAN_DAY, jd); + year = cal->get(UCAL_YEAR, status); + month = cal->get(UCAL_MONTH, status); + dayOfMonth = cal->get(UCAL_DATE, status); + if ( U_FAILURE(status) ) { + errln("FAIL: Calendar->get YEAR/MONTH/DATE for localeID %s, julianDay %d, status %s", localeID, jd, u_errorName(status)); + } else if (month > maxMonth || dayOfMonth > maxDayOfMonth) { + errln("FAIL: localeID %s, julianDay %d; got year %d; maxMonth %d, got month %d; maxDayOfMonth %d, got dayOfMonth %d", + localeID, jd, year, maxMonth, month, maxDayOfMonth, dayOfMonth); + } + } + delete cal; + } +} + #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/icuSources/test/intltest/calregts.h b/icuSources/test/intltest/calregts.h index e4c89dc2..d1da7173 100644 --- a/icuSources/test/intltest/calregts.h +++ b/icuSources/test/intltest/calregts.h @@ -1,14 +1,14 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /******************************************************************** - * COPYRIGHT: + * COPYRIGHT: * Copyright (c) 1997-2012, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ #ifndef _CALENDARREGRESSIONTEST_ #define _CALENDARREGRESSIONTEST_ - + #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING @@ -17,11 +17,11 @@ #include "unicode/gregocal.h" #include "intltest.h" -/** +/** * Performs regression test for Calendar **/ -class CalendarRegressionTest: public IntlTest { - +class CalendarRegressionTest: public IntlTest { + // IntlTest override void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par ); public: @@ -77,6 +77,8 @@ public: void TestT8596(void); void Test9019(void); void TestT9452(void); + void TestPersianCalOverflow(void); + void TestIslamicCalOverflow(void); void printdate(GregorianCalendar *cal, const char *string); void dowTest(UBool lenient) ; @@ -94,6 +96,6 @@ protected: }; #endif /* #if !UCONFIG_NO_FORMATTING */ - + #endif // _CALENDARREGRESSIONTEST_ //eof diff --git a/icuSources/tools/tzcode/icuzones b/icuSources/tools/tzcode/icuzones index 9e3c7c9c..168a86f9 100644 --- a/icuSources/tools/tzcode/icuzones +++ b/icuSources/tools/tzcode/icuzones @@ -78,3 +78,52 @@ Link Asia/Ho_Chi_Minh VST # Link America/Regina Canada/East-Saskatchewan # removed from backward in 2017c + +# Note: +# Following section was added for tz database 2018a and 2018b. +# ICU has a bug handling negative DST, and we also don't want to +# flip sumer time name and winter time name for Dublin at least for +# now. Because the change had major impacts to tz database external +# consumers, the tz database maintainer once reverted the Europe/Dublin +# rules (same as 2017c or older) in 2018c. The tz database maintainer +# thinks the changes in 2018a should be brought back when external +# tz database consumers are ready to adopt the change. We don't know +# what CLDR TC want to do with this for now. But if tz database brings +# back the change, and CLDR TC (and ICU TC) want to keep the display name +# unchanged, then we can uncomment the block below to restore ICU +# custom override. (Yoshito 2018-01-23) + +# +# tzdata2018a changed Europe/Dublin to use IST (UTC+1) as the standard time +# of the region, and GMT (UTC) as the daylight saving time with negative +# offset (-1 hour) in winter. ICU SimpleTimeZone rejects a zone with negative +# daylight saving time offset. We could remove the restriction in newer version +# of ICU, but such data does not work well with older ICU runtime without +# fixing the issue. For now, we define our own Europe/Dubin in ICU, replacing +# Europe/Dublin data from the tz database. +# + +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +# Rule Eire--ICU 1971 only - Oct 31 2:00u 0 GMT +# Rule Eire--ICU 1972 1980 - Mar Sun>=16 2:00u 1:00 IST +# Rule Eire--ICU 1972 1980 - Oct Sun>=23 2:00u 0 GMT +# Rule Eire--ICU 1981 max - Mar lastSun 1:00u 1:00 IST +# Rule Eire--ICU 1981 1989 - Oct Sun>=23 1:00u 0 GMT +# Rule Eire--ICU 1990 1995 - Oct Sun>=22 1:00u 0 GMT +# Rule Eire--ICU 1996 max - Oct lastSun 1:00u 0 GMT + +# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone Europe/Dublin--ICU -0:25:00 - LMT 1880 Aug 2 +# -0:25:21 - DMT 1916 May 21 2:00s +# -0:25:21 1:00 IST 1916 Oct 1 2:00s +# 0:00 GB-Eire %s 1921 Dec 6 # independence +# 0:00 GB-Eire GMT/IST 1940 Feb 25 2:00s +# 0:00 1:00 IST 1946 Oct 6 2:00s +# 0:00 - GMT 1947 Mar 16 2:00s +# 0:00 1:00 IST 1947 Nov 2 2:00s +# 0:00 - GMT 1948 Apr 18 2:00s +# 0:00 GB-Eire GMT/IST 1968 Oct 27 +# 0:00 Eire--ICU GMT/IST + +# Link Europe/Dublin--ICU Eire--ICU + -- 2.45.2