/** * Call this once to get a consistent timezone. Use ctest_resetTimeZone to set it back to the original value. * @param optionalTimeZone Set this to a requested timezone. * Set to NULL to use the standard test timezone (Pacific Time) */ U_CFUNC void ctest_setTimeZone(const char *optionalTimeZone, UErrorCode *status) { #if !UCONFIG_NO_FORMATTING UChar zoneID[CTEST_MAX_TIMEZONE_SIZE]; if (optionalTimeZone == NULL) { optionalTimeZone = "America/Los_Angeles"; } if (gOriginalTimeZone[0]) { log_data_err("*** Error: time zone saved twice. New value will be %s (Are you missing data?)\n", optionalTimeZone); } ucal_getDefaultTimeZone(gOriginalTimeZone, CTEST_MAX_TIMEZONE_SIZE, status); if (U_FAILURE(*status)) { log_err("*** Error: Failed to save default time zone: %s\n", u_errorName(*status)); *status = U_ZERO_ERROR; } u_uastrncpy(zoneID, optionalTimeZone, CTEST_MAX_TIMEZONE_SIZE-1); zoneID[CTEST_MAX_TIMEZONE_SIZE-1] = 0; ucal_setDefaultTimeZone(zoneID, status); if (U_FAILURE(*status)) { log_err("*** Error: Failed to set default time zone to \"%s\": %s\n", optionalTimeZone, u_errorName(*status)); } #endif }
/** * call-seq: * UCalendar.default_tz = ustring * * Set the default time zone. * * UCalendar.default_tz="GMT+00".u * UCalendar.default_tz="Europe/Paris".u */ VALUE icu4r_cal_set_default_tz(VALUE obj, VALUE tz) { UErrorCode status = U_ZERO_ERROR; Check_Class(tz, rb_cUString); ucal_setDefaultTimeZone (ICU_PTR(tz), &status); ICU_RAISE(status); return tz; }
/** * Call this once get back the original timezone */ U_CFUNC void ctest_resetTimeZone(void) { #if !UCONFIG_NO_FORMATTING UErrorCode status = U_ZERO_ERROR; ucal_setDefaultTimeZone(gOriginalTimeZone, &status); if (U_FAILURE(status)) { log_err("*** Error: Failed to reset default time zone: %s\n", u_errorName(status)); } /* Set to an empty state */ gOriginalTimeZone[0] = 0; #endif }