| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * Copyright (C) 1997-2015, International Business Machines Corporation and | 3 * Copyright (C) 1997-2015, International Business Machines Corporation and |
| 4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
| 5 ******************************************************************************* | 5 ******************************************************************************* |
| 6 * | 6 * |
| 7 * File TIMEZONE.CPP | 7 * File TIMEZONE.CPP |
| 8 * | 8 * |
| 9 * Modification History: | 9 * Modification History: |
| 10 * | 10 * |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 /* We first try to lookup the zone ID in our system list. If this | 420 /* We first try to lookup the zone ID in our system list. If this |
| 421 * fails, we try to parse it as a custom string GMT[+-]hh:mm. If | 421 * fails, we try to parse it as a custom string GMT[+-]hh:mm. If |
| 422 * all else fails, we return GMT, which is probably not what the | 422 * all else fails, we return GMT, which is probably not what the |
| 423 * user wants, but at least is a functioning TimeZone object. | 423 * user wants, but at least is a functioning TimeZone object. |
| 424 * | 424 * |
| 425 * We cannot return NULL, because that would break compatibility | 425 * We cannot return NULL, because that would break compatibility |
| 426 * with the JDK. | 426 * with the JDK. |
| 427 */ | 427 */ |
| 428 TimeZone* result = createSystemTimeZone(ID); | 428 TimeZone* result = createSystemTimeZone(ID); |
| 429 | 429 |
| 430 if (result == 0) { | 430 if (result == NULL) { |
| 431 U_DEBUG_TZ_MSG(("failed to load system time zone with id - falling to cu
stom")); | 431 U_DEBUG_TZ_MSG(("failed to load system time zone with id - falling to cu
stom")); |
| 432 result = createCustomTimeZone(ID); | 432 result = createCustomTimeZone(ID); |
| 433 } | 433 } |
| 434 if (result == 0) { | 434 if (result == NULL) { |
| 435 U_DEBUG_TZ_MSG(("failed to load time zone with id - falling to Etc/Unkno
wn(GMT)")); | 435 U_DEBUG_TZ_MSG(("failed to load time zone with id - falling to Etc/Unkno
wn(GMT)")); |
| 436 result = getUnknown().clone(); | 436 const TimeZone& unknown = getUnknown(); |
| 437 if (_UNKNOWN_ZONE == NULL) { // Cannot test (&unknown
== NULL) because the |
| 438 U_DEBUG_TZ_MSG(("failed to getUnknown()")); // behavior of NULL refer
ences is undefined. |
| 439 } else { |
| 440 result = unknown.clone(); |
| 441 } |
| 437 } | 442 } |
| 438 return result; | 443 return result; |
| 439 } | 444 } |
| 440 | 445 |
| 441 // ------------------------------------- | 446 // ------------------------------------- |
| 442 | 447 |
| 443 TimeZone* U_EXPORT2 | 448 TimeZone* U_EXPORT2 |
| 444 TimeZone::detectHostTimeZone() | 449 TimeZone::detectHostTimeZone() |
| 445 { | 450 { |
| 446 // We access system timezone data through TPlatformUtilities, | 451 // We access system timezone data through TPlatformUtilities, |
| 447 // including tzset(), timezone, and tzname[]. | 452 // including tzset(), timezone, and tzname[]. |
| 448 int32_t rawOffset = 0; | 453 int32_t rawOffset = 0; |
| 449 const char *hostID; | 454 const char *hostID; |
| 450 | 455 |
| 451 // First, try to create a system timezone, based | 456 // First, try to create a system timezone, based |
| 452 // on the string ID in tzname[0]. | 457 // on the string ID in tzname[0]. |
| 453 | 458 |
| 454 uprv_tzset(); // Initialize tz... system data | 459 uprv_tzset(); // Initialize tz... system data |
| 455 | 460 |
| 456 uprv_tzname_clear_cache(); | |
| 457 | |
| 458 // Get the timezone ID from the host. This function should do | 461 // Get the timezone ID from the host. This function should do |
| 459 // any required host-specific remapping; e.g., on Windows this | 462 // any required host-specific remapping; e.g., on Windows this |
| 460 // function maps the Date and Time control panel setting to an | 463 // function maps the Date and Time control panel setting to an |
| 461 // ICU timezone ID. | 464 // ICU timezone ID. |
| 462 hostID = uprv_tzname(0); | 465 hostID = uprv_tzname(0); |
| 463 | 466 |
| 464 // Invert sign because UNIX semantics are backwards | 467 // Invert sign because UNIX semantics are backwards |
| 465 rawOffset = uprv_timezone() * -U_MILLIS_PER_SECOND; | 468 rawOffset = uprv_timezone() * -U_MILLIS_PER_SECOND; |
| 466 | 469 |
| 467 TimeZone* hostZone = NULL; | 470 TimeZone* hostZone = NULL; |
| (...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 isSystemID = TRUE; | 1540 isSystemID = TRUE; |
| 1538 } else { | 1541 } else { |
| 1539 // Not a system ID | 1542 // Not a system ID |
| 1540 status = U_ZERO_ERROR; | 1543 status = U_ZERO_ERROR; |
| 1541 getCustomID(id, canonicalID, status); | 1544 getCustomID(id, canonicalID, status); |
| 1542 } | 1545 } |
| 1543 } | 1546 } |
| 1544 return canonicalID; | 1547 return canonicalID; |
| 1545 } | 1548 } |
| 1546 | 1549 |
| 1547 #ifndef U_HIDE_DRAFT_API | |
| 1548 UnicodeString& | 1550 UnicodeString& |
| 1549 TimeZone::getWindowsID(const UnicodeString& id, UnicodeString& winid, UErrorCode
& status) { | 1551 TimeZone::getWindowsID(const UnicodeString& id, UnicodeString& winid, UErrorCode
& status) { |
| 1550 winid.remove(); | 1552 winid.remove(); |
| 1551 if (U_FAILURE(status)) { | 1553 if (U_FAILURE(status)) { |
| 1552 return winid; | 1554 return winid; |
| 1553 } | 1555 } |
| 1554 | 1556 |
| 1555 // canonicalize the input ID | 1557 // canonicalize the input ID |
| 1556 UnicodeString canonicalID; | 1558 UnicodeString canonicalID; |
| 1557 UBool isSystemID = FALSE; | 1559 UBool isSystemID = FALSE; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 tzid = ures_getStringByKey(zones, "001", &len, &status); // using sta
tus, because "001" must be | 1680 tzid = ures_getStringByKey(zones, "001", &len, &status); // using sta
tus, because "001" must be |
| 1679 // available at
this point | 1681 // available at
this point |
| 1680 if (U_SUCCESS(status)) { | 1682 if (U_SUCCESS(status)) { |
| 1681 id.setTo(tzid, len); | 1683 id.setTo(tzid, len); |
| 1682 } | 1684 } |
| 1683 } | 1685 } |
| 1684 | 1686 |
| 1685 ures_close(zones); | 1687 ures_close(zones); |
| 1686 return id; | 1688 return id; |
| 1687 } | 1689 } |
| 1688 #endif /* U_HIDE_DRAFT_API */ | |
| 1689 | 1690 |
| 1690 | 1691 |
| 1691 U_NAMESPACE_END | 1692 U_NAMESPACE_END |
| 1692 | 1693 |
| 1693 #endif /* #if !UCONFIG_NO_FORMATTING */ | 1694 #endif /* #if !UCONFIG_NO_FORMATTING */ |
| 1694 | 1695 |
| 1695 //eof | 1696 //eof |
| OLD | NEW |