github.com/blend/go-sdk@v1.20220411.3/timeutil/min_max.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package timeutil 9 10 import "time" 11 12 // MinMax returns the minimum and maximum times in a given range. 13 func MinMax(times ...time.Time) (min time.Time, max time.Time) { 14 if len(times) == 0 { 15 return 16 } 17 min = times[0] 18 max = times[0] 19 20 for index := 1; index < len(times); index++ { 21 if times[index].Before(min) { 22 min = times[index] 23 } 24 if times[index].After(max) { 25 max = times[index] 26 } 27 } 28 return 29 }