hako / durafmt

:clock8: Better time duration formatting in Go!
MIT License
496 stars 49 forks source link

Add LimitToUnit() method to limit conversion until this unit. #21

Closed syrm closed 4 years ago

syrm commented 4 years ago

Example :

       duration, _ := ParseString("354h22m3.24s")
       fmt.Println(duration) // 2 weeks 18 hours 22 minutes 3 seconds

       duration, _ = ParseString("354h22m3.24s")
       duration = duration.LimitToUnit("days")
       fmt.Println(duration) // 14 days 18 hours 22 minutes 3 seconds
codecov-commenter commented 4 years ago

Codecov Report

Merging #21 into master will increase coverage by 0.70%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #21      +/-   ##
==========================================
+ Coverage   97.36%   98.07%   +0.70%     
==========================================
  Files           1        1              
  Lines          76      104      +28     
==========================================
+ Hits           74      102      +28     
  Misses          1        1              
  Partials        1        1              
Impacted Files Coverage Δ
durafmt.go 98.07% <100.00%> (+0.70%) :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 3f39dc1...6519680. Read the comment docs.

hako commented 4 years ago

@syrm Thanks for the PR, LGTM 👍