mirror of https://github.com/emirpasic/gods
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
429 B
Go
22 lines
429 B
Go
// Copyright (c) 2015, Emir Pasic. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package utils
|
|
|
|
import "time"
|
|
|
|
type Comparator[T any] func(x, y T) int
|
|
|
|
// TimeComparator provides a basic comparison on time.Time
|
|
func TimeComparator(a, b time.Time) int {
|
|
switch {
|
|
case a.After(b):
|
|
return 1
|
|
case a.Before(b):
|
|
return -1
|
|
default:
|
|
return 0
|
|
}
|
|
}
|