From 41652e4d1e0e07cbe0c036784941625bbba7ca7a Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Sun, 11 Aug 2019 11:45:19 +0700 Subject: [PATCH] QHP: iso8601 dates --- src/ATrade/Quotes/QHP.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ATrade/Quotes/QHP.hs b/src/ATrade/Quotes/QHP.hs index bd6841b..469336e 100644 --- a/src/ATrade/Quotes/QHP.hs +++ b/src/ATrade/Quotes/QHP.hs @@ -13,7 +13,9 @@ import Data.Binary.IEEE754 import qualified Data.ByteString.Lazy as BL import qualified Data.Text as T import Data.Time.Calendar +import Data.Time.Clock import Data.Time.Clock.POSIX +import Data.Time.Format import System.Log.Logger import System.ZMQ4 @@ -48,10 +50,13 @@ data RequestParams = period :: Period } deriving (Show, Eq) +printDatetime :: UTCTime -> String +printDatetime = formatTime defaultTimeLocale (iso8601DateFormat (Just "%H:%M:%S")) + instance ToJSON RequestParams where toJSON p = object [ "ticker" .= ticker p, - "from" .= showGregorian (startDate p), - "to" .= showGregorian (endDate p), + "from" .= printDatetime (UTCTime (startDate p) 0), + "to" .= printDatetime (UTCTime (endDate p) 0), "timeframe" .= show (period p) ] getQuotes :: Context -> RequestParams -> IO [Bar]