diff --git a/map.go b/map.go index 5298e9a..1bac515 100644 --- a/map.go +++ b/map.go @@ -191,22 +191,22 @@ func EmptyMapValuesMatchAny() ContainsOption { // to parse any string values back into time.Time values. This allows correct processing of // the time.Time zero values. // -// If rounding is > 0, times will be rounded. If ignoreTimeZone is true, the location data will +// If truncation is > 0, times will be truncation. If ignoreTimeZone is true, the location data will // be stripped off the time values before comparison. -func ParseDates(rounding time.Duration, ignoreTimeZone bool) ContainsOption { +func ParseDates(truncation time.Duration, ignoreTimeZone bool) ContainsOption { return func(o *containsOptions) { o.parseDates = true - o.roundDates = rounding + o.truncateDates = truncation o.stripTimeZone = ignoreTimeZone } } -// TruncateDates is like ParseDates, but truncates time values rather than rounding them. +// RoundDates is like ParseDates, but rounds time values rather than truncating them. // If both options are specified, truncation will be applied first. -func TruncateDates(truncation time.Duration, ignoreTimeZone bool) ContainsOption { +func RoundDates(rounding time.Duration, ignoreTimeZone bool) ContainsOption { return func(o *containsOptions) { o.parseDates = true - o.truncateDates = truncation + o.roundDates = rounding o.stripTimeZone = ignoreTimeZone } } diff --git a/maps_test.go b/maps_test.go index 24b4ce2..d4d3c93 100644 --- a/maps_test.go +++ b/maps_test.go @@ -336,24 +336,24 @@ func TestContains(t *testing.T) { expected: false, }, { - name: "rounddates", - v1: map[string]interface{}{"t": t1}, - v2: map[string]interface{}{"t": t1.Add(time.Nanosecond)}, + name: "truncatedates", + v1: map[string]interface{}{"t": t1.Truncate(time.Microsecond).Add(900 * time.Nanosecond)}, + v2: map[string]interface{}{"t": t1.Truncate(time.Microsecond).Add(100 * time.Nanosecond)}, options: []ContainsOption{EmptyMapValuesMatchAny(), ParseDates(time.Microsecond, true)}, expected: true, }, { - name: "rounddoesnttruncatedates", + name: "rounddates", v1: map[string]interface{}{"t": t1.Truncate(time.Microsecond).Add(900 * time.Nanosecond)}, v2: map[string]interface{}{"t": t1.Truncate(time.Microsecond).Add(100 * time.Nanosecond)}, - options: []ContainsOption{EmptyMapValuesMatchAny(), ParseDates(time.Microsecond, true)}, + options: []ContainsOption{EmptyMapValuesMatchAny(), RoundDates(time.Microsecond, true)}, expected: false, }, { - name: "truncatedates", + name: "rounddates", v1: map[string]interface{}{"t": t1.Truncate(time.Microsecond).Add(900 * time.Nanosecond)}, - v2: map[string]interface{}{"t": t1.Truncate(time.Microsecond).Add(100 * time.Nanosecond)}, - options: []ContainsOption{EmptyMapValuesMatchAny(), TruncateDates(time.Microsecond, true)}, + v2: map[string]interface{}{"t": t1.Truncate(time.Microsecond).Add(700 * time.Nanosecond)}, + options: []ContainsOption{EmptyMapValuesMatchAny(), RoundDates(time.Microsecond, true)}, expected: true, }, {