Code Duplication    Length = 13-13 lines in 2 locations

src/date/Calendar.class.php 2 locations

@@ 997-1009 (lines=13) @@
994
                }
995
            }
996
            // Do a binary search
997
            while (($max - $min) > 1) {
998
                $t = (int) (($min + $max) / 2);
999
                $this->setTimeInMillis($startMs);
1000
                $this->add($field, $t);
1001
                $ms = (float) $this->getTimeInMillis();
1002
                if ($ms == $targetMs) {
1003
                    return $t;
1004
                } elseif ($ms > $targetMs) {
1005
                    $max = $t;
1006
                } else {
1007
                    $min = $t;
1008
                }
1009
            }
1010
        } elseif ($startMs > $targetMs) {
1011
            $max = -1;
1012
            // Find a value that is too small
@@ 1031-1043 (lines=13) @@
1028
                }
1029
            }
1030
            // Do a binary search
1031
            while (($min - $max) > 1) {
1032
                $t = (int) (($min + $max) / 2);
1033
                $this->setTimeInMillis($startMs);
1034
                $this->add($field, $t);
1035
                $ms = (float) $this->getTimeInMillis();
1036
                if ($ms == $targetMs) {
1037
                    return $t;
1038
                } elseif ($ms < $targetMs) {
1039
                    $max = $t;
1040
                } else {
1041
                    $min = $t;
1042
                }
1043
            }
1044
        }
1045
        // Set calendar to end point
1046
        $this->setTimeInMillis($startMs);