Logo Search packages:      
Sourcecode: icu version File versions  Download package

U_STABLE int32_t U_EXPORT2 ucal_getDSTSavings ( const UChar *  zoneID,
UErrorCode ec 

Return the amount of time in milliseconds that the clock is advanced during daylight savings time for the given time zone, or zero if the time zone does not observe daylight savings time.

zoneID null-terminated time zone ID
ec input/output error code
the number of milliseconds the time is advanced with respect to standard time when the daylight savings rules are in effect. This is always a non-negative number, most commonly either 3,600,000 (one hour) or zero.
ICU 2.6

Definition at line 82 of file ucal.cpp.

References FALSE, TimeZone::getDynamicClassID(), Calendar::getNow(), TimeZone::getOffset(), SimpleTimeZone::getStaticClassID(), U_FAILURE, U_MILLIS_PER_DAY, and U_SUCCESS.

    int32_t result = 0;
    TimeZone* zone = _createTimeZone(zoneID, -1, ec);
    if (U_SUCCESS(*ec)) {
        if (zone->getDynamicClassID() == SimpleTimeZone::getStaticClassID()) {
            result = ((SimpleTimeZone*) zone)->getDSTSavings();
        } else {
            // Since there is no getDSTSavings on TimeZone, we use a
            // heuristic: Starting with the current time, march
            // forwards for one year, looking for DST savings.
            // Stepping by weeks is sufficient.
            UDate d = Calendar::getNow();
            for (int32_t i=0; i<53; ++i, d+=U_MILLIS_PER_DAY*7.0) {
                int32_t raw, dst;
                zone->getOffset(d, FALSE, raw, dst, *ec);
                if (U_FAILURE(*ec)) {
                } else if (dst != 0) {
                    result = dst;
    delete zone;
    return result;

Generated by  Doxygen 1.6.0   Back to index