Debian Codegraph @

utils/comparator.go

raw symbols SCIP
1 // Copyright (c) 2015, Emir Pasic. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package utils
6
7 import "time"
8
9 type Comparator[T any] func(x, y T) int
10
11 // TimeComparator provides a basic comparison on time.Time
12 func TimeComparator(a, b time.Time) int {
13 switch {
14 case a.After(b):
15 return 1
16 case a.Before(b):
17 return -1
18 default:
19 return 0
20 }
21 }