FreeWRL

 view release on metacpan or  search on metacpan

JS/js/jsdate.c  view on Meta::CPAN

    if (hi < lo) {
        jsint temp = lo;
        lo = hi;
        hi = temp;
    }

    /* Use a simple binary search algorithm to find the right
       year.  This seems like brute force... but the computation
       of hi and lo years above lands within one year of the
       correct answer for years within a thousand years of
       1970; the loop below only requires six iterations
       for year 270000. */
    while (hi > lo) {
        mid = (hi + lo) / 2;
        if (TimeFromYear(mid) > t) {
            hi = mid - 1;
        } else {
            if (TimeFromYear(mid) <= t) {
                jsint temp = mid + 1;
                if (TimeFromYear(temp) > t) {
                    return mid;



( run in 0.851 second using v1.01-cache-2.11-cpan-71847e10f99 )