void CalendarRegressionTest::test4096231()
{
    UErrorCode status = U_ZERO_ERROR;
    TimeZone *GMT = TimeZone::createTimeZone("GMT");
    TimeZone *PST = TimeZone::createTimeZone("PST");
    int32_t sec = 0, min = 0, hr = 0, day = 1, month = 10, year = 1997;

    Calendar *cal1 = new GregorianCalendar(*PST,status);
    if (U_FAILURE(status)) {
        dataerrln("Failure new GregorianCalendar: %s", u_errorName(status));
        delete GMT;
        delete PST;
        delete cal1;
        return;
    }
    cal1->setTime(880698639000.0,status);
    // Issue 1: Changing the timezone doesn't change the
    //          represented time.  The old API, pre 1.2.2a requires
    // setTime to be called in order to update the time fields after the time
    // zone has been set.
    int32_t h1,h2;
    logln(UnicodeString("PST 1 is: ") + (h1=cal1->get(UCAL_HOUR_OF_DAY, status)));
    cal1->setTimeZone(*GMT);
    logln(UnicodeString("GMT 2 is: ") + (h2=cal1->get(UCAL_HOUR_OF_DAY, status)));
    if ((*GMT != *PST) && (h1 == h2))
        errln("Fail: Hour same in different zones");

    Calendar *cal2 = new GregorianCalendar(*GMT,status);
    Calendar *cal3 = new GregorianCalendar(*PST,status);
    cal2->set(UCAL_MILLISECOND, 0);
    cal3->set(UCAL_MILLISECOND, 0);

    cal2->set(cal1->get(UCAL_YEAR,status),
             cal1->get(UCAL_MONTH,status),
             cal1->get(UCAL_DATE,status),
             cal1->get(UCAL_HOUR_OF_DAY,status),
             cal1->get(UCAL_MINUTE,status),
             cal1->get(UCAL_SECOND,status));

    double t1,t2,t3,t4;
    logln(UnicodeString("RGMT 1 is: ") + (t1=cal2->getTime(status)));
    cal3->set(year, month, day, hr, min, sec);
    logln(UnicodeString("RPST 1 is: ") + (t2=cal3->getTime(status)));
    cal3->setTimeZone(*GMT);
    logln(UnicodeString("RGMT 2 is: ") + (t3=cal3->getTime(status)));
    cal3->set(cal1->get(UCAL_YEAR,status),
             cal1->get(UCAL_MONTH,status),
             cal1->get(UCAL_DATE,status),
             cal1->get(UCAL_HOUR_OF_DAY,status),
             cal1->get(UCAL_MINUTE,status),
             cal1->get(UCAL_SECOND,status));
    // Issue 2: Calendar continues to use the timezone in its
    //          constructor for set() conversions, regardless
    //          of calls to setTimeZone()
    logln(UnicodeString("RGMT 3 is: ") + (t4=cal3->getTime(status)));
    if (t1 == t2 ||
        t1 != t4 ||
        t2 != t3)
        errln("Fail: Calendar zone behavior faulty");

    delete cal1;
    delete cal2;
    delete cal3;
    delete GMT;
    delete PST;
}
void CalendarRegressionTest::test4096231()
{
    UErrorCode status = U_ZERO_ERROR;
    TimeZone *GMT = TimeZone::createTimeZone("GMT");
    TimeZone *PST = TimeZone::createTimeZone("PST");
    int32_t sec = 0, min = 0, hr = 0, day = 1, month = 10, year = 1997;

    Calendar *cal1 = new GregorianCalendar(*PST,status);
    if (U_FAILURE(status)) {
        dataerrln("Failure new GregorianCalendar: %s", u_errorName(status));
        delete GMT;
        delete PST;
        delete cal1;
        return;
    }
    cal1->setTime(880698639000.0,status);
     
     
     
     
    int32_t h1,h2;
    logln(UnicodeString("PST 1 is: ") + (h1=cal1->get(UCAL_HOUR_OF_DAY, status)));
    cal1->setTimeZone(*GMT);
    logln(UnicodeString("GMT 2 is: ") + (h2=cal1->get(UCAL_HOUR_OF_DAY, status)));
    if ((*GMT != *PST) && (h1 == h2))
        errln("Fail: Hour same in different zones");

    Calendar *cal2 = new GregorianCalendar(*GMT,status);
    Calendar *cal3 = new GregorianCalendar(*PST,status);
    cal2->set(UCAL_MILLISECOND, 0);
    cal3->set(UCAL_MILLISECOND, 0);

    cal2->set(cal1->get(UCAL_YEAR,status),
             cal1->get(UCAL_MONTH,status),
             cal1->get(UCAL_DATE,status),
             cal1->get(UCAL_HOUR_OF_DAY,status),
             cal1->get(UCAL_MINUTE,status),
             cal1->get(UCAL_SECOND,status));

    double t1,t2,t3,t4;
    logln(UnicodeString("RGMT 1 is: ") + (t1=cal2->getTime(status)));
    cal3->set(year, month, day, hr, min, sec);
    logln(UnicodeString("RPST 1 is: ") + (t2=cal3->getTime(status)));
    cal3->setTimeZone(*GMT);
    logln(UnicodeString("RGMT 2 is: ") + (t3=cal3->getTime(status)));
    cal3->set(cal1->get(UCAL_YEAR,status),
             cal1->get(UCAL_MONTH,status),
             cal1->get(UCAL_DATE,status),
             cal1->get(UCAL_HOUR_OF_DAY,status),
             cal1->get(UCAL_MINUTE,status),
             cal1->get(UCAL_SECOND,status));
     
     
     
    logln(UnicodeString("RGMT 3 is: ") + (t4=cal3->getTime(status)));
    if (t1 == t2 ||
        t1 != t4 ||
        t2 != t3)
        errln("Fail: Calendar zone behavior faulty");

    delete cal1;
    delete cal2;
    delete cal3;
    delete GMT;
    delete PST;
}