Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for maxDuration (0.1 sec)

  1. src/time/time_test.go

    	want Duration
    }{
    	{0, 0},
    	{1, 1},
    	{-1, 1},
    	{1 * Minute, 1 * Minute},
    	{-1 * Minute, 1 * Minute},
    	{minDuration, maxDuration},
    	{minDuration + 1, maxDuration},
    	{minDuration + 2, maxDuration - 1},
    	{maxDuration, maxDuration},
    	{maxDuration - 1, maxDuration - 1},
    }
    
    func TestDurationAbs(t *testing.T) {
    	for _, tt := range durationAbsTests {
    		if got := tt.d.Abs(); got != tt.want {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 03:13:47 UTC 2024
    - 56.5K bytes
    - Viewed (0)
  2. src/time/time.go

    		return d - r
    	}
    	if d1 := d + m - r; d1 > d {
    		return d1
    	}
    	return maxDuration // overflow
    }
    
    // Abs returns the absolute value of d.
    // As a special case, [math.MinInt64] is converted to [math.MaxInt64].
    func (d Duration) Abs() Duration {
    	switch {
    	case d >= 0:
    		return d
    	case d == minDuration:
    		return maxDuration
    	default:
    		return -d
    	}
    }
    
    // Add returns the time t+d.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 29 17:58:53 UTC 2024
    - 50.7K bytes
    - Viewed (0)
Back to top