go-openapi / strfmt

openapi toolkit common string formats
Apache License 2.0
102 stars 62 forks source link

Add Equal methods to DateTime and Date #76

Closed dominikznidar closed 3 years ago

dominikznidar commented 3 years ago

Adds support for for DateTime.Equal(DateTime) and Date.Equal(Date) that uses time's Equal method.

This would simplify our testing flow a lot as the dependency we use (github.com go-test/deep) skips checking time.Time's internal properties (exp, loc, ...) by default.

codecov[bot] commented 3 years ago

Codecov Report

Merging #76 (03523a5) into master (ccdb72d) will increase coverage by 0.02%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #76      +/-   ##
==========================================
+ Coverage   81.64%   81.67%   +0.02%     
==========================================
  Files          10       10              
  Lines        1286     1288       +2     
==========================================
+ Hits         1050     1052       +2     
  Misses        164      164              
  Partials       72       72              
Impacted Files Coverage Δ
date.go 86.15% <100.00%> (+0.21%) :arrow_up:
time.go 95.29% <100.00%> (+0.05%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ccdb72d...03523a5. Read the comment docs.

fredbi commented 3 years ago

@dominikznidar

If I understand correctly, this is just about avoiding the type conversion?

e.g.

var t1,t2 strfmt.Date

isEqual := t1.Equal(t2)

isAlsoEqual := time.Time(t1).Equal(time.Time(t2))
dominikznidar commented 3 years ago

@fredbi Yes. We would have to add additional checks for each DateTime or Date field in a struct.