summaryrefslogtreecommitdiff
blob: be1f7ec59f25febb1b7c142c635cb75adef31678 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
https://bugs.icu-project.org/trac/ticket/6814
https://bugs.icu-project.org/trac/changeset/25681

--- i18n/olsontz.cpp
+++ i18n/olsontz.cpp
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-* Copyright (c) 2003-2008, International Business Machines
+* Copyright (c) 2003-2009, International Business Machines
 * Corporation and others.  All Rights Reserved.
 **********************************************************************
 * Author: Alan Liu
@@ -526,8 +526,8 @@
         if (transitionTimes[i] >= limit) {
             break;
         }
-        if (transitionTimes[i] >= start &&
-            dstOffset(typeData[i]) != 0) {
+        if ((transitionTimes[i] >= start && dstOffset(typeData[i]) != 0)
+                || (transitionTimes[i] > start && i > 0 && dstOffset(typeData[i - 1]) != 0)) {
             return TRUE;
         }
     }
--- i18n/timezone.cpp
+++ i18n/timezone.cpp
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-* Copyright (C) 1997-2008, International Business Machines Corporation and    *
+* Copyright (C) 1997-2009, International Business Machines Corporation and    *
 * others. All Rights Reserved.                                                *
 *******************************************************************************
 *
@@ -1240,6 +1240,8 @@
         }
     } else {
         // The display name for standard time was requested, but currently in DST
+        // or display name for daylight saving time was requested, but this zone no longer
+        // observes DST.
         tz = new SimpleTimeZone(rawOffset, tempID);
         if (U_FAILURE(status) || tz == NULL) {
             if (U_SUCCESS(status)) {
--- test/intltest/tztest.cpp
+++ test/intltest/tztest.cpp
@@ -34,6 +34,11 @@
 // class TimeZoneTest
 // *****************************************************************************
 
+// TODO: We should probably read following data at runtime, so we can update
+// the these values every release with necessary data changes.
+const int32_t TimeZoneTest::REFERENCE_YEAR = 2009;
+const char * TimeZoneTest::REFERENCE_DATA_VERSION = "2009d";
+
 void TimeZoneTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
 {
     if (exec) logln("TestSuite TestTimeZone");
@@ -579,18 +584,13 @@
  */
 void TimeZoneTest::TestShortZoneIDs()
 {
-    // TODO: This test case is tzdata sensitive.
-    // We should actually put the data version in this test code
-    // at build time.  For now, we just hardcode the version string
-    // and display warning instead of error if non-reference tzdata
-    // version is used.
-    const char *REFERENCE_DATA_VERSION = "2008i";
-
     UErrorCode status = U_ZERO_ERROR;
+
+    // This test case is tzdata version sensitive.
     UBool isNonReferenceTzdataVersion = FALSE;
     const char *tzdataVer = TimeZone::getTZDataVersion(status);
     if (failure(status, "getTZDataVersion")) return;
-    if (uprv_strcmp(tzdataVer, REFERENCE_DATA_VERSION) != 0) {
+    if (uprv_strcmp(tzdataVer, TimeZoneTest::REFERENCE_DATA_VERSION) != 0) {
         // Note: We want to display a warning message here if
         // REFERENCE_DATA_VERSION is out of date - so we
         // do not forget to update the value before GA.
@@ -603,11 +603,11 @@
     // Note: useDaylightTime returns true if DST is observed
     // in the time zone in the current calendar year.  The test
     // data is valid for the date after the reference year below.
-    // If system clock is before the year, some test cases may fail.
-    const int32_t REFERENCE_YEAR = 2009;
+    // If system clock is before the year, some test cases may
+    // fail.
     GregorianCalendar cal(*TimeZone::getGMT(), status);
     if (failure(status, "GregorianCalendar")) return;
-    cal.set(REFERENCE_YEAR, UCAL_JANUARY, 2); // day 2 in GMT
+    cal.set(TimeZoneTest::REFERENCE_YEAR, UCAL_JANUARY, 2); // day 2 in GMT
 
     UBool isDateBeforeReferenceYear = ucal_getNow() < cal.getTime(status);
     if (failure(status, "Calendar::getTime")) return;
@@ -1898,6 +1898,15 @@
     };
 
 void TimeZoneTest::TestDisplayNamesMeta() {
+    UErrorCode status = U_ZERO_ERROR;
+    GregorianCalendar cal(*TimeZone::getGMT(), status);
+    if (failure(status, "GregorianCalendar")) return;
+
+    UBool isReferenceYear = TRUE;
+    if (cal.get(UCAL_YEAR, status) != TimeZoneTest::REFERENCE_YEAR) {
+        isReferenceYear = FALSE;
+    }
+
     UBool sawAnError = FALSE;
     for (int testNum   = 0; zoneDisplayTestData[testNum].zoneName != NULL; testNum++) {
         Locale locale  = Locale::createFromName(zoneDisplayTestData[testNum].localeName);
@@ -1908,20 +1917,33 @@
                              locale,
                              displayName);
         if (displayName != zoneDisplayTestData[testNum].expectedDisplayName) {
-            sawAnError = TRUE;
             char  name[100];
             UErrorCode status = U_ZERO_ERROR;
             displayName.extract(name, 100, NULL, status);
-            errln("Incorrect time zone display name.  zone = \"%s\",\n"
-                  "   locale = \"%s\",   style = %s,  Summertime = %d\n"
-                  "   Expected \"%s\", "
-                  "   Got \"%s\"\n", zoneDisplayTestData[testNum].zoneName,
-                                     zoneDisplayTestData[testNum].localeName,
-                                     zoneDisplayTestData[testNum].style==TimeZone::SHORT ?
-                                        "SHORT" : "LONG",
-                                     zoneDisplayTestData[testNum].summerTime,
-                                     zoneDisplayTestData[testNum].expectedDisplayName,
-                                     name);
+            if (isReferenceYear) {
+                sawAnError = TRUE;
+                errln("Incorrect time zone display name.  zone = \"%s\",\n"
+                      "   locale = \"%s\",   style = %s,  Summertime = %d\n"
+                      "   Expected \"%s\", "
+                      "   Got \"%s\"\n", zoneDisplayTestData[testNum].zoneName,
+                                         zoneDisplayTestData[testNum].localeName,
+                                         zoneDisplayTestData[testNum].style==TimeZone::SHORT ?
+                                            "SHORT" : "LONG",
+                                         zoneDisplayTestData[testNum].summerTime,
+                                         zoneDisplayTestData[testNum].expectedDisplayName,
+                                         name);
+            } else {
+                logln("Incorrect time zone display name.  zone = \"%s\",\n"
+                      "   locale = \"%s\",   style = %s,  Summertime = %d\n"
+                      "   Expected \"%s\", "
+                      "   Got \"%s\"\n", zoneDisplayTestData[testNum].zoneName,
+                                         zoneDisplayTestData[testNum].localeName,
+                                         zoneDisplayTestData[testNum].style==TimeZone::SHORT ?
+                                            "SHORT" : "LONG",
+                                         zoneDisplayTestData[testNum].summerTime,
+                                         zoneDisplayTestData[testNum].expectedDisplayName,
+                                         name);
+            }
         }
         delete zone;
     }
--- test/intltest/tztest.h
+++ test/intltest/tztest.h
@@ -1,6 +1,6 @@
 
 /********************************************************************
- * Copyright (c) 1997-2008, International Business Machines
+ * Copyright (c) 1997-2009, International Business Machines
  * Corporation and others. All Rights Reserved.
  ********************************************************************/
  
@@ -98,6 +98,11 @@
     // internal functions
     static UnicodeString& formatOffset(int32_t offset, UnicodeString& rv);
     static UnicodeString& formatTZID(int32_t offset, UnicodeString& rv);
+
+    // Some test case data is current date/tzdata version sensitive and producing errors
+    // when year/rule are changed.
+    static const int32_t REFERENCE_YEAR;
+    static const char *REFERENCE_DATA_VERSION;
 };
 
 #endif /* #if !UCONFIG_NO_FORMATTING */