packages feed

human-readable-duration 0.2.0.3 → 0.2.1.0

raw patch · 2 files changed

+51/−18 lines, 2 filesdep ~Globdep ~criteriondep ~doctestPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: Glob, criterion, doctest, human-readable-duration

API changes (from Hackage documentation)

Files

human-readable-duration.cabal view
@@ -1,11 +1,11 @@-name: human-readable-duration-version: 0.2.0.3 cabal-version: >=1.10-build-type: Simple+name: human-readable-duration+version: 0.2.1.0 license: BSD3 license-file: LICENSE maintainer: yann.esposito@gmail.com-homepage: http://github.com/yogsototh/human-readable-duration#readme+author: Yann Esposito+homepage: https://gitlab.esy.fun/yogsototh/human-readable-duration#readme synopsis: Provide duration helper description:     This is a minimal Haskell library to display duration.@@ -20,7 +20,7 @@     > getMs duration     > -- will return 65923323002 category: Time-author: Yann Esposito+build-type: Simple  source-repository head     type: git@@ -30,30 +30,30 @@     exposed-modules:         Data.Duration         Data.Duration.Tutorial+    hs-source-dirs: src+    default-language: Haskell2010     build-depends:         base >=4.7 && <5-    default-language: Haskell2010-    hs-source-dirs: src  test-suite doctest     type: exitcode-stdio-1.0     main-is: DocTest.hs+    hs-source-dirs: test+    default-language: Haskell2010+    ghc-options: -Wall     build-depends:         base >=4.7 && <5,-        Glob >=0.7,-        human-readable-duration >=0.2.0.3,-        doctest >=0.9.12-    default-language: Haskell2010-    hs-source-dirs: test-    ghc-options: -O2 -Wall+        Glob >=0.7 && <0.10,+        human-readable-duration -any,+        doctest >=0.9.12 && <0.17  benchmark hrd-bench     type: exitcode-stdio-1.0     main-is: Main.hs+    hs-source-dirs: bench+    default-language: Haskell2010+    ghc-options: -Wall -threaded     build-depends:         base >=4.7 && <5,-        criterion >=1.1.0.0,-        human-readable-duration >=0.2.0.3-    default-language: Haskell2010-    hs-source-dirs: bench-    ghc-options: -O2 -Wall -threaded+        criterion >=1.1.0.0 && <1.6,+        human-readable-duration -any
src/Data/Duration.hs view
@@ -54,6 +54,39 @@   | n < year   = let d  = getDays    n in if d  > 0 then show d  ++ " days " ++ humanReadableDuration (n `mod'` day) else ""   | otherwise  = let y  = getYears   n in if y  > 0 then show y  ++ " years " ++ humanReadableDuration (n `mod'` year) else "" ++{- | `humanReadableDuration` take some time in micro-second precision and render a human readable duration.++>>> let duration = 2 * ms + 3 * oneSecond + 2 * minute + 33*day + 2*year+>>> duration+65923323.002000+>>> approximativeDuration duration+"2 years"+>>> let duration = 2 * ms + 3 * oneSecond + 2 * minute + 33*day+>>> approximativeDuration duration+"33 days"+>>> let duration = 2 * ms + 3 * oneSecond + 280 * minute+>>> approximativeDuration duration+"4 hours"+>>> let duration = 2 * ms + 3 * oneSecond + 22 * minute+>>> approximativeDuration duration+"22 min"+>>> let duration = 2 * ms + 3 * oneSecond+>>> approximativeDuration duration+"3s"+>>> let duration = 12 * ms+>>> approximativeDuration duration+"12ms"+-}+approximativeDuration :: Micro -> String+approximativeDuration n+  | n < oneSecond = let mi = getMs   n in show mi ++ "ms"+  | n < minute = let s  = getSeconds n in show s  ++ "s"+  | n < hour   = let m  = getMinutes n in show m  ++ " min"+  | n < day    = let h  = getHours   n in show h  ++ " hours"+  | n < year   = let d  = getDays    n in show d  ++ " days"+  | otherwise  = let y  = getYears   n in show y  ++ " years"+ -- | Wrapper around any `Real` input, which works for `DiffTime` and -- `NominalDiffTime` from the time library, or a `Double` of seconds. --