OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011,2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011,2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "platform/text/LocaleICU.h" | 31 #include "platform/text/LocaleICU.h" |
32 | 32 |
33 #include "wtf/DateMath.h" | |
34 #include "wtf/PtrUtil.h" | |
35 #include "wtf/text/StringBuffer.h" | |
36 #include "wtf/text/StringBuilder.h" | |
37 #include <limits> | |
38 #include <memory> | |
39 #include <unicode/udatpg.h> | 33 #include <unicode/udatpg.h> |
40 #include <unicode/udisplaycontext.h> | 34 #include <unicode/udisplaycontext.h> |
41 #include <unicode/uloc.h> | 35 #include <unicode/uloc.h> |
| 36 #include <limits> |
| 37 #include "wtf/DateMath.h" |
| 38 #include "wtf/PassOwnPtr.h" |
| 39 #include "wtf/text/StringBuffer.h" |
| 40 #include "wtf/text/StringBuilder.h" |
42 | 41 |
43 using namespace icu; | 42 using namespace icu; |
44 | 43 |
45 namespace blink { | 44 namespace blink { |
46 | 45 |
47 std::unique_ptr<Locale> Locale::create(const String& locale) | 46 PassOwnPtr<Locale> Locale::create(const String& locale) |
48 { | 47 { |
49 return LocaleICU::create(locale.utf8().data()); | 48 return LocaleICU::create(locale.utf8().data()); |
50 } | 49 } |
51 | 50 |
52 LocaleICU::LocaleICU(const char* locale) | 51 LocaleICU::LocaleICU(const char* locale) |
53 : m_locale(locale) | 52 : m_locale(locale) |
54 , m_numberFormat(0) | 53 , m_numberFormat(0) |
55 , m_shortDateFormat(0) | 54 , m_shortDateFormat(0) |
56 , m_didCreateDecimalFormat(false) | 55 , m_didCreateDecimalFormat(false) |
57 , m_didCreateShortDateFormat(false) | 56 , m_didCreateShortDateFormat(false) |
58 , m_firstDayOfWeek(0) | 57 , m_firstDayOfWeek(0) |
59 , m_mediumTimeFormat(0) | 58 , m_mediumTimeFormat(0) |
60 , m_shortTimeFormat(0) | 59 , m_shortTimeFormat(0) |
61 , m_didCreateTimeFormat(false) | 60 , m_didCreateTimeFormat(false) |
62 { | 61 { |
63 } | 62 } |
64 | 63 |
65 LocaleICU::~LocaleICU() | 64 LocaleICU::~LocaleICU() |
66 { | 65 { |
67 unum_close(m_numberFormat); | 66 unum_close(m_numberFormat); |
68 udat_close(m_shortDateFormat); | 67 udat_close(m_shortDateFormat); |
69 udat_close(m_mediumTimeFormat); | 68 udat_close(m_mediumTimeFormat); |
70 udat_close(m_shortTimeFormat); | 69 udat_close(m_shortTimeFormat); |
71 } | 70 } |
72 | 71 |
73 std::unique_ptr<LocaleICU> LocaleICU::create(const char* localeString) | 72 PassOwnPtr<LocaleICU> LocaleICU::create(const char* localeString) |
74 { | 73 { |
75 return wrapUnique(new LocaleICU(localeString)); | 74 return adoptPtr(new LocaleICU(localeString)); |
76 } | 75 } |
77 | 76 |
78 String LocaleICU::decimalSymbol(UNumberFormatSymbol symbol) | 77 String LocaleICU::decimalSymbol(UNumberFormatSymbol symbol) |
79 { | 78 { |
80 UErrorCode status = U_ZERO_ERROR; | 79 UErrorCode status = U_ZERO_ERROR; |
81 int32_t bufferLength = unum_getSymbol(m_numberFormat, symbol, 0, 0, &status)
; | 80 int32_t bufferLength = unum_getSymbol(m_numberFormat, symbol, 0, 0, &status)
; |
82 ASSERT(U_SUCCESS(status) || status == U_BUFFER_OVERFLOW_ERROR); | 81 ASSERT(U_SUCCESS(status) || status == U_BUFFER_OVERFLOW_ERROR); |
83 if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) | 82 if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) |
84 return String(); | 83 return String(); |
85 StringBuffer<UChar> buffer(bufferLength); | 84 StringBuffer<UChar> buffer(bufferLength); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 if (status != U_BUFFER_OVERFLOW_ERROR || !length) | 173 if (status != U_BUFFER_OVERFLOW_ERROR || !length) |
175 return emptyString(); | 174 return emptyString(); |
176 StringBuffer<UChar> buffer(length); | 175 StringBuffer<UChar> buffer(length); |
177 status = U_ZERO_ERROR; | 176 status = U_ZERO_ERROR; |
178 udat_toPattern(dateFormat, TRUE, buffer.characters(), length, &status); | 177 udat_toPattern(dateFormat, TRUE, buffer.characters(), length, &status); |
179 if (U_FAILURE(status)) | 178 if (U_FAILURE(status)) |
180 return emptyString(); | 179 return emptyString(); |
181 return String::adopt(buffer); | 180 return String::adopt(buffer); |
182 } | 181 } |
183 | 182 |
184 std::unique_ptr<Vector<String>> LocaleICU::createLabelVector(const UDateFormat*
dateFormat, UDateFormatSymbolType type, int32_t startIndex, int32_t size) | 183 PassOwnPtr<Vector<String>> LocaleICU::createLabelVector(const UDateFormat* dateF
ormat, UDateFormatSymbolType type, int32_t startIndex, int32_t size) |
185 { | 184 { |
186 if (!dateFormat) | 185 if (!dateFormat) |
187 return std::unique_ptr<Vector<String>>(); | 186 return PassOwnPtr<Vector<String>>(); |
188 if (udat_countSymbols(dateFormat, type) != startIndex + size) | 187 if (udat_countSymbols(dateFormat, type) != startIndex + size) |
189 return std::unique_ptr<Vector<String>>(); | 188 return PassOwnPtr<Vector<String>>(); |
190 | 189 |
191 std::unique_ptr<Vector<String>> labels = wrapUnique(new Vector<String>()); | 190 OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>()); |
192 labels->reserveCapacity(size); | 191 labels->reserveCapacity(size); |
193 bool isStandAloneMonth = (type == UDAT_STANDALONE_MONTHS) || (type == UDAT_S
TANDALONE_SHORT_MONTHS); | 192 bool isStandAloneMonth = (type == UDAT_STANDALONE_MONTHS) || (type == UDAT_S
TANDALONE_SHORT_MONTHS); |
194 for (int32_t i = 0; i < size; ++i) { | 193 for (int32_t i = 0; i < size; ++i) { |
195 UErrorCode status = U_ZERO_ERROR; | 194 UErrorCode status = U_ZERO_ERROR; |
196 int32_t length; | 195 int32_t length; |
197 static const UDate kEpoch = U_MILLIS_PER_DAY * 15u; // 1970-01-15 | 196 static const UDate kEpoch = U_MILLIS_PER_DAY * 15u; // 1970-01-15 |
198 static const UDate kMonth = U_MILLIS_PER_DAY * 30u; // 30 days in ms | 197 static const UDate kMonth = U_MILLIS_PER_DAY * 30u; // 30 days in ms |
199 if (isStandAloneMonth) { | 198 if (isStandAloneMonth) { |
200 length = udat_format(dateFormat, kEpoch + i * kMonth, 0, 0, 0, &stat
us); | 199 length = udat_format(dateFormat, kEpoch + i * kMonth, 0, 0, 0, &stat
us); |
201 } else { | 200 } else { |
202 length = udat_getSymbols(dateFormat, type, startIndex + i, 0, 0, &st
atus); | 201 length = udat_getSymbols(dateFormat, type, startIndex + i, 0, 0, &st
atus); |
203 } | 202 } |
204 if (status != U_BUFFER_OVERFLOW_ERROR) | 203 if (status != U_BUFFER_OVERFLOW_ERROR) |
205 return std::unique_ptr<Vector<String>>(); | 204 return PassOwnPtr<Vector<String>>(); |
206 StringBuffer<UChar> buffer(length); | 205 StringBuffer<UChar> buffer(length); |
207 status = U_ZERO_ERROR; | 206 status = U_ZERO_ERROR; |
208 if (isStandAloneMonth) { | 207 if (isStandAloneMonth) { |
209 udat_format(dateFormat, kEpoch + i * kMonth, buffer.characters(), le
ngth, 0, &status); | 208 udat_format(dateFormat, kEpoch + i * kMonth, buffer.characters(), le
ngth, 0, &status); |
210 } else { | 209 } else { |
211 udat_getSymbols(dateFormat, type, startIndex + i, buffer.characters(
), length, &status); | 210 udat_getSymbols(dateFormat, type, startIndex + i, buffer.characters(
), length, &status); |
212 } | 211 } |
213 if (U_FAILURE(status)) | 212 if (U_FAILURE(status)) |
214 return std::unique_ptr<Vector<String>>(); | 213 return PassOwnPtr<Vector<String>>(); |
215 labels->append(String::adopt(buffer)); | 214 labels->append(String::adopt(buffer)); |
216 } | 215 } |
217 return labels; | 216 return labels; |
218 } | 217 } |
219 | 218 |
220 static std::unique_ptr<Vector<String>> createFallbackWeekDayShortLabels() | 219 static PassOwnPtr<Vector<String>> createFallbackWeekDayShortLabels() |
221 { | 220 { |
222 std::unique_ptr<Vector<String>> labels = wrapUnique(new Vector<String>()); | 221 OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>()); |
223 labels->reserveCapacity(7); | 222 labels->reserveCapacity(7); |
224 labels->append("Sun"); | 223 labels->append("Sun"); |
225 labels->append("Mon"); | 224 labels->append("Mon"); |
226 labels->append("Tue"); | 225 labels->append("Tue"); |
227 labels->append("Wed"); | 226 labels->append("Wed"); |
228 labels->append("Thu"); | 227 labels->append("Thu"); |
229 labels->append("Fri"); | 228 labels->append("Fri"); |
230 labels->append("Sat"); | 229 labels->append("Sat"); |
231 return labels; | 230 return labels; |
232 } | 231 } |
233 | 232 |
234 void LocaleICU::initializeCalendar() | 233 void LocaleICU::initializeCalendar() |
235 { | 234 { |
236 if (m_weekDayShortLabels) | 235 if (m_weekDayShortLabels) |
237 return; | 236 return; |
238 | 237 |
239 if (!initializeShortDateFormat()) { | 238 if (!initializeShortDateFormat()) { |
240 m_firstDayOfWeek = 0; | 239 m_firstDayOfWeek = 0; |
241 m_weekDayShortLabels = createFallbackWeekDayShortLabels(); | 240 m_weekDayShortLabels = createFallbackWeekDayShortLabels(); |
242 return; | 241 return; |
243 } | 242 } |
244 m_firstDayOfWeek = ucal_getAttribute(udat_getCalendar(m_shortDateFormat), UC
AL_FIRST_DAY_OF_WEEK) - UCAL_SUNDAY; | 243 m_firstDayOfWeek = ucal_getAttribute(udat_getCalendar(m_shortDateFormat), UC
AL_FIRST_DAY_OF_WEEK) - UCAL_SUNDAY; |
245 | 244 |
246 m_weekDayShortLabels = createLabelVector(m_shortDateFormat, UDAT_SHORT_WEEKD
AYS, UCAL_SUNDAY, 7); | 245 m_weekDayShortLabels = createLabelVector(m_shortDateFormat, UDAT_SHORT_WEEKD
AYS, UCAL_SUNDAY, 7); |
247 if (!m_weekDayShortLabels) | 246 if (!m_weekDayShortLabels) |
248 m_weekDayShortLabels = createFallbackWeekDayShortLabels(); | 247 m_weekDayShortLabels = createFallbackWeekDayShortLabels(); |
249 } | 248 } |
250 | 249 |
251 static std::unique_ptr<Vector<String>> createFallbackMonthLabels() | 250 static PassOwnPtr<Vector<String>> createFallbackMonthLabels() |
252 { | 251 { |
253 std::unique_ptr<Vector<String>> labels = wrapUnique(new Vector<String>()); | 252 OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>()); |
254 labels->reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName)); | 253 labels->reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName)); |
255 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i) | 254 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i) |
256 labels->append(WTF::monthFullName[i]); | 255 labels->append(WTF::monthFullName[i]); |
257 return labels; | 256 return labels; |
258 } | 257 } |
259 | 258 |
260 const Vector<String>& LocaleICU::monthLabels() | 259 const Vector<String>& LocaleICU::monthLabels() |
261 { | 260 { |
262 if (m_monthLabels) | 261 if (m_monthLabels) |
263 return *m_monthLabels; | 262 return *m_monthLabels; |
(...skipping 17 matching lines...) Expand all Loading... |
281 initializeCalendar(); | 280 initializeCalendar(); |
282 return m_firstDayOfWeek; | 281 return m_firstDayOfWeek; |
283 } | 282 } |
284 | 283 |
285 bool LocaleICU::isRTL() | 284 bool LocaleICU::isRTL() |
286 { | 285 { |
287 UErrorCode status = U_ZERO_ERROR; | 286 UErrorCode status = U_ZERO_ERROR; |
288 return uloc_getCharacterOrientation(m_locale.data(), &status) == ULOC_LAYOUT
_RTL; | 287 return uloc_getCharacterOrientation(m_locale.data(), &status) == ULOC_LAYOUT
_RTL; |
289 } | 288 } |
290 | 289 |
291 static std::unique_ptr<Vector<String>> createFallbackAMPMLabels() | 290 static PassOwnPtr<Vector<String>> createFallbackAMPMLabels() |
292 { | 291 { |
293 std::unique_ptr<Vector<String>> labels = wrapUnique(new Vector<String>()); | 292 OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>()); |
294 labels->reserveCapacity(2); | 293 labels->reserveCapacity(2); |
295 labels->append("AM"); | 294 labels->append("AM"); |
296 labels->append("PM"); | 295 labels->append("PM"); |
297 return labels; | 296 return labels; |
298 } | 297 } |
299 | 298 |
300 void LocaleICU::initializeDateTimeFormat() | 299 void LocaleICU::initializeDateTimeFormat() |
301 { | 300 { |
302 if (m_didCreateTimeFormat) | 301 if (m_didCreateTimeFormat) |
303 return; | 302 return; |
304 | 303 |
305 // We assume ICU medium time pattern and short time pattern are compatible | 304 // We assume ICU medium time pattern and short time pattern are compatible |
306 // with LDML, because ICU specific pattern character "V" doesn't appear | 305 // with LDML, because ICU specific pattern character "V" doesn't appear |
307 // in both medium and short time pattern. | 306 // in both medium and short time pattern. |
308 m_mediumTimeFormat = openDateFormat(UDAT_MEDIUM, UDAT_NONE); | 307 m_mediumTimeFormat = openDateFormat(UDAT_MEDIUM, UDAT_NONE); |
309 m_timeFormatWithSeconds = getDateFormatPattern(m_mediumTimeFormat); | 308 m_timeFormatWithSeconds = getDateFormatPattern(m_mediumTimeFormat); |
310 | 309 |
311 m_shortTimeFormat = openDateFormat(UDAT_SHORT, UDAT_NONE); | 310 m_shortTimeFormat = openDateFormat(UDAT_SHORT, UDAT_NONE); |
312 m_timeFormatWithoutSeconds = getDateFormatPattern(m_shortTimeFormat); | 311 m_timeFormatWithoutSeconds = getDateFormatPattern(m_shortTimeFormat); |
313 | 312 |
314 UDateFormat* dateTimeFormatWithSeconds = openDateFormat(UDAT_MEDIUM, UDAT_SH
ORT); | 313 UDateFormat* dateTimeFormatWithSeconds = openDateFormat(UDAT_MEDIUM, UDAT_SH
ORT); |
315 m_dateTimeFormatWithSeconds = getDateFormatPattern(dateTimeFormatWithSeconds
); | 314 m_dateTimeFormatWithSeconds = getDateFormatPattern(dateTimeFormatWithSeconds
); |
316 udat_close(dateTimeFormatWithSeconds); | 315 udat_close(dateTimeFormatWithSeconds); |
317 | 316 |
318 UDateFormat* dateTimeFormatWithoutSeconds = openDateFormat(UDAT_SHORT, UDAT_
SHORT); | 317 UDateFormat* dateTimeFormatWithoutSeconds = openDateFormat(UDAT_SHORT, UDAT_
SHORT); |
319 m_dateTimeFormatWithoutSeconds = getDateFormatPattern(dateTimeFormatWithoutS
econds); | 318 m_dateTimeFormatWithoutSeconds = getDateFormatPattern(dateTimeFormatWithoutS
econds); |
320 udat_close(dateTimeFormatWithoutSeconds); | 319 udat_close(dateTimeFormatWithoutSeconds); |
321 | 320 |
322 std::unique_ptr<Vector<String>> timeAMPMLabels = createLabelVector(m_mediumT
imeFormat, UDAT_AM_PMS, UCAL_AM, 2); | 321 OwnPtr<Vector<String>> timeAMPMLabels = createLabelVector(m_mediumTimeFormat
, UDAT_AM_PMS, UCAL_AM, 2); |
323 if (!timeAMPMLabels) | 322 if (!timeAMPMLabels) |
324 timeAMPMLabels = createFallbackAMPMLabels(); | 323 timeAMPMLabels = createFallbackAMPMLabels(); |
325 m_timeAMPMLabels = *timeAMPMLabels; | 324 m_timeAMPMLabels = *timeAMPMLabels; |
326 | 325 |
327 m_didCreateTimeFormat = true; | 326 m_didCreateTimeFormat = true; |
328 } | 327 } |
329 | 328 |
330 String LocaleICU::dateFormat() | 329 String LocaleICU::dateFormat() |
331 { | 330 { |
332 if (!m_dateFormat.isNull()) | 331 if (!m_dateFormat.isNull()) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 { | 398 { |
400 initializeDateTimeFormat(); | 399 initializeDateTimeFormat(); |
401 return m_dateTimeFormatWithoutSeconds; | 400 return m_dateTimeFormatWithoutSeconds; |
402 } | 401 } |
403 | 402 |
404 const Vector<String>& LocaleICU::shortMonthLabels() | 403 const Vector<String>& LocaleICU::shortMonthLabels() |
405 { | 404 { |
406 if (!m_shortMonthLabels.isEmpty()) | 405 if (!m_shortMonthLabels.isEmpty()) |
407 return m_shortMonthLabels; | 406 return m_shortMonthLabels; |
408 if (initializeShortDateFormat()) { | 407 if (initializeShortDateFormat()) { |
409 if (std::unique_ptr<Vector<String>> labels = createLabelVector(m_shortDa
teFormat, UDAT_SHORT_MONTHS, UCAL_JANUARY, 12)) { | 408 if (OwnPtr<Vector<String>> labels = createLabelVector(m_shortDateFormat,
UDAT_SHORT_MONTHS, UCAL_JANUARY, 12)) { |
410 m_shortMonthLabels = *labels; | 409 m_shortMonthLabels = *labels; |
411 return m_shortMonthLabels; | 410 return m_shortMonthLabels; |
412 } | 411 } |
413 } | 412 } |
414 m_shortMonthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthName)); | 413 m_shortMonthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthName)); |
415 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthName); ++i) | 414 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthName); ++i) |
416 m_shortMonthLabels.append(WTF::monthName[i]); | 415 m_shortMonthLabels.append(WTF::monthName[i]); |
417 return m_shortMonthLabels; | 416 return m_shortMonthLabels; |
418 } | 417 } |
419 | 418 |
420 const Vector<String>& LocaleICU::standAloneMonthLabels() | 419 const Vector<String>& LocaleICU::standAloneMonthLabels() |
421 { | 420 { |
422 if (!m_standAloneMonthLabels.isEmpty()) | 421 if (!m_standAloneMonthLabels.isEmpty()) |
423 return m_standAloneMonthLabels; | 422 return m_standAloneMonthLabels; |
424 UDateFormat* monthFormatter = openDateFormatForStandAloneMonthLabels(false); | 423 UDateFormat* monthFormatter = openDateFormatForStandAloneMonthLabels(false); |
425 if (monthFormatter) { | 424 if (monthFormatter) { |
426 if (std::unique_ptr<Vector<String>> labels = createLabelVector(monthForm
atter, UDAT_STANDALONE_MONTHS, UCAL_JANUARY, 12)) { | 425 if (OwnPtr<Vector<String>> labels = createLabelVector(monthFormatter, UD
AT_STANDALONE_MONTHS, UCAL_JANUARY, 12)) { |
427 m_standAloneMonthLabels = *labels; | 426 m_standAloneMonthLabels = *labels; |
428 udat_close(monthFormatter); | 427 udat_close(monthFormatter); |
429 return m_standAloneMonthLabels; | 428 return m_standAloneMonthLabels; |
430 } | 429 } |
431 udat_close(monthFormatter); | 430 udat_close(monthFormatter); |
432 } | 431 } |
433 m_standAloneMonthLabels = monthLabels(); | 432 m_standAloneMonthLabels = monthLabels(); |
434 return m_standAloneMonthLabels; | 433 return m_standAloneMonthLabels; |
435 } | 434 } |
436 | 435 |
437 const Vector<String>& LocaleICU::shortStandAloneMonthLabels() | 436 const Vector<String>& LocaleICU::shortStandAloneMonthLabels() |
438 { | 437 { |
439 if (!m_shortStandAloneMonthLabels.isEmpty()) | 438 if (!m_shortStandAloneMonthLabels.isEmpty()) |
440 return m_shortStandAloneMonthLabels; | 439 return m_shortStandAloneMonthLabels; |
441 UDateFormat* monthFormatter = openDateFormatForStandAloneMonthLabels(true); | 440 UDateFormat* monthFormatter = openDateFormatForStandAloneMonthLabels(true); |
442 if (monthFormatter) { | 441 if (monthFormatter) { |
443 if (std::unique_ptr<Vector<String>> labels = createLabelVector(monthForm
atter, UDAT_STANDALONE_SHORT_MONTHS, UCAL_JANUARY, 12)) { | 442 if (OwnPtr<Vector<String>> labels = createLabelVector(monthFormatter, UD
AT_STANDALONE_SHORT_MONTHS, UCAL_JANUARY, 12)) { |
444 m_shortStandAloneMonthLabels = *labels; | 443 m_shortStandAloneMonthLabels = *labels; |
445 udat_close(monthFormatter); | 444 udat_close(monthFormatter); |
446 return m_shortStandAloneMonthLabels; | 445 return m_shortStandAloneMonthLabels; |
447 } | 446 } |
448 udat_close(monthFormatter); | 447 udat_close(monthFormatter); |
449 } | 448 } |
450 m_shortStandAloneMonthLabels = shortMonthLabels(); | 449 m_shortStandAloneMonthLabels = shortMonthLabels(); |
451 return m_shortStandAloneMonthLabels; | 450 return m_shortStandAloneMonthLabels; |
452 } | 451 } |
453 | 452 |
454 const Vector<String>& LocaleICU::timeAMPMLabels() | 453 const Vector<String>& LocaleICU::timeAMPMLabels() |
455 { | 454 { |
456 initializeDateTimeFormat(); | 455 initializeDateTimeFormat(); |
457 return m_timeAMPMLabels; | 456 return m_timeAMPMLabels; |
458 } | 457 } |
459 | 458 |
460 } // namespace blink | 459 } // namespace blink |
461 | 460 |
OLD | NEW |