text-builder-dev 0.3.5 → 0.3.6
raw patch · 2 files changed
+34/−1 lines, 2 files
Files
- library/TextBuilderDev.hs +32/−0
- text-builder-dev.cabal +2/−1
library/TextBuilderDev.hs view
@@ -73,6 +73,8 @@ utcTimeInIso8601, utcTimestampInIso8601, intervalInSeconds,+ diffTimeCompact,+ picosecondsCompact, -- * Classes IsomorphicToTextBuilder (..),@@ -595,6 +597,11 @@ -- | -- Time interval in seconds.+--+-- The format is the following:+--+-- > DD:HH:MM:SS+-- -- Directly applicable to 'DiffTime' and 'NominalDiffTime'. {-# INLINEABLE intervalInSeconds #-} intervalInSeconds :: (RealFrac seconds) => seconds -> TextBuilder@@ -611,6 +618,31 @@ <> padFromLeft 2 '0' (decimal minutes) <> ":" <> padFromLeft 2 '0' (decimal seconds)++-- | DiffTime in a compact decimal format based on 'picosecondsCompact'.+diffTimeCompact :: DiffTime -> TextBuilder+diffTimeCompact = picosecondsCompact . diffTimeToPicoseconds++-- | Amount of picoseconds represented in a compact decimal format using suffixes.+--+-- E.g., the following is @1_230_000_000@ picoseconds or 1.23 milliseconds or 1230 microseconds:+--+-- > 1230us+picosecondsCompact :: Integer -> TextBuilder+picosecondsCompact x =+ attemptOr 1_000_000_000_000 "s"+ $ attemptOr 1_000_000_000 "ms"+ $ attemptOr 1_000_000 "us"+ $ attemptOr 1_000 "ns"+ $ decimal x+ <> "ps"+ where+ attemptOr factor suffix alternative =+ if x == divided * factor+ then decimal divided <> suffix+ else alternative+ where+ divided = div x factor -- | Double with a fixed number of decimal places. {-# INLINE fixedDouble #-}
text-builder-dev.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: text-builder-dev-version: 0.3.5+version: 0.3.6 category: Text, Builders synopsis: Edge of developments for "text-builder" description:@@ -47,6 +47,7 @@ MagicHash MultiParamTypeClasses MultiWayIf+ NumericUnderscores OverloadedStrings ParallelListComp PatternGuards