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