| 1045 | //------------------------------------- |
| 1046 | |
| 1047 | TimeZoneRuleIterator::TimeZoneRuleIterator(USHORT aId, const ISC_TIMESTAMP_TZ& aFrom, const ISC_TIMESTAMP_TZ& aTo) |
| 1048 | : id(aId), |
| 1049 | icuLib(Jrd::UnicodeUtil::getConversionICU()), |
| 1050 | toTicks(TimeStamp::timeStampToTicks(aTo.utc_timestamp)), |
| 1051 | icuCalendar(getDesc(aId)->getCalendar(icuLib)) |
| 1052 | { |
| 1053 | UErrorCode icuErrorCode = U_ZERO_ERROR; |
| 1054 | |
| 1055 | if (!icuCalendar) |
| 1056 | status_exception::raise(Arg::Gds(isc_random) << "Error calling ICU's ucal_open."); |
| 1057 | |
| 1058 | icuDate = TimeZoneUtil::timeStampToIcuDate(aFrom.utc_timestamp); |
| 1059 | |
| 1060 | icuLib.ucalSetMillis(icuCalendar, icuDate, &icuErrorCode); |
| 1061 | |
| 1062 | if (U_FAILURE(icuErrorCode)) |
| 1063 | { |
| 1064 | fb_assert(false); |
| 1065 | status_exception::raise(Arg::Gds(isc_random) << "Error calling ICU's ucal_setMillis."); |
| 1066 | } |
| 1067 | |
| 1068 | UBool hasInitial = icuLib.ucalGetTimeZoneTransitionDate(icuCalendar, UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE, |
| 1069 | &icuDate, &icuErrorCode); |
| 1070 | |
| 1071 | if (U_FAILURE(icuErrorCode)) |
| 1072 | { |
| 1073 | fb_assert(false); |
| 1074 | status_exception::raise(Arg::Gds(isc_random) << "Error calling ICU's ucal_getTimeZoneTransitionDate."); |
| 1075 | } |
| 1076 | |
| 1077 | if (!hasInitial) |
| 1078 | icuDate = MIN_ICU_TIMESTAMP; |
| 1079 | |
| 1080 | icuLib.ucalSetMillis(icuCalendar, icuDate, &icuErrorCode); |
| 1081 | |
| 1082 | if (U_FAILURE(icuErrorCode)) |
| 1083 | { |
| 1084 | fb_assert(false); |
| 1085 | status_exception::raise(Arg::Gds(isc_random) << "Error calling ICU's ucal_setMillis."); |
| 1086 | } |
| 1087 | |
| 1088 | startTicks = TimeStamp::timeStampToTicks(TimeZoneUtil::icuDateToTimeStamp(icuDate)); |
| 1089 | } |
| 1090 | |
| 1091 | bool TimeZoneRuleIterator::next() |
| 1092 | { |
nothing calls this directly
no test coverage detected