timeplot 1.0.11 → 1.0.13
raw patch · 3 files changed
+17/−5 lines, 3 files
Files
- Tools/TimePlot.hs +3/−0
- Tools/TimePlot/Conf.hs +13/−4
- timeplot.cabal +1/−1
Tools/TimePlot.hs view
@@ -81,6 +81,8 @@ " -if IFILE [-tf TF] ", " [{+|-}k Pat1 '[+Suf1] Kind1' {+|-}k Pat2 '[+Suf2] Kind2' ...] [{+|-}dk '[+Suf] KindN']", " [-fromTime TIME] [-toTime TIME] [-baseTime TIME]",+ " --version - show version information",+ " --help - show this help", " -o OFILE - output file", " -of - output format (default: extension of -o)", " -or - output resolution (default 640x480)",@@ -96,6 +98,7 @@ " We also support %OS for fractional seconds (i.e. %OS will", " parse 12.4039 or 12,4039) and %^[+-][N]s for ten-powers ", " of seconds since epoch, for example %^-3s is ms since epoch.",+ " -tf elapsed means times are fractional seconds since an unknown moment.", " Default: 'date %Y-%m-%d %H:%M:%OS'", " {+|-}dk - set default diagram kind", " {+|-}k P K - set diagram kind for tracks matching regex P (in the format",
Tools/TimePlot/Conf.hs view
@@ -13,6 +13,7 @@ import Graphics.Rendering.Chart import qualified Data.ByteString.Char8 as S import qualified Data.ByteString.Lazy.Char8 as B +import Data.ByteString.Lex.Lazy.Double import Unsafe.Coerce @@ -41,11 +42,17 @@ readConf :: [String] -> Conf readConf args = readConf' parseTime where - pattern = case (words $ single "time format" "-tf" ("date %Y-%m-%d %H:%M:%OS")) of + pattern = case (words $ single "time format" "-tf" ("%Y-%m-%d %H:%M:%OS")) of "date":f -> B.pack (unwords f) - _ -> error "Unrecognized time format (-tf)" + f -> B.pack (unwords f) {-# NOINLINE ourStrptime #-} - ourStrptime = strptime pattern + Just (ourBaseTime,_) = strptime "%Y-%m-%d %H:%M:%OS" "1900-01-01 00:00:00" + ourStrptime :: B.ByteString -> Maybe (LocalTime, B.ByteString) + ourStrptime = if pattern == B.pack "elapsed" + then \s -> do + (d, s') <- readDouble s + return (fromSeconds d ourBaseTime `add` ourBaseTime, s') + else strptime pattern parseTime s = ourStrptime s int2double = fromIntegral :: Int -> Double @@ -85,7 +92,9 @@ fromTime = fst `fmap` (parseTime . B.pack $ single "minimum time (inclusive)" "-fromTime" "") toTime = fst `fmap` (parseTime . B.pack $ single "maximum time (exclusive)" "-toTime" "") - baseTime = fst `fmap` (parseTime . B.pack $ single "base time" "-baseTime" "") + baseTime = if pattern == B.pack "elapsed" + then Just ourBaseTime + else (fst `fmap` (parseTime . B.pack $ single "base time" "-baseTime" "")) transformLabel t s = case baseTime of Nothing -> s
timeplot.cabal view
@@ -1,5 +1,5 @@ name: timeplot-version: 1.0.11+version: 1.0.13 cabal-version: >=1.6 build-type: Simple license: BSD3