hunk.code_window:         },
           "load-json-file": {
             "version": "2.0.0",
             "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
             "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=",
             "dev": true,
             "requires": {
               "graceful-fs": "^4.1.2",
               "parse-json": "^2.2.0",
  
hunk.labels: keep keep keep replace keep keep keep keep keep
hunk.after_edit:           "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
  
hunk.file_path: console/package-lock.json
hunk.type: replace
file: {-# LANGUAGE ScopedTypeVariables #-}
  
  module Hasura.SQL.Time
      ( ZonedTimeOfDay(..)
      ) where
  
  import           Data.Attoparsec.Text as A
  import           Data.Attoparsec.Time (timeOfDay, timeZone)
  import           Data.Maybe           (fromMaybe)
  import           Hasura.Prelude
  
  import qualified Data.Aeson.Types     as Aeson
  import qualified Data.Text            as T
  import qualified Data.Time.LocalTime  as Local
  
  data ZonedTimeOfDay
    = ZonedTimeOfDay
    { ztodTime :: Local.TimeOfDay
    , ztodZone :: Local.TimeZone
    } deriving (Show, Eq)
  
  utc :: Local.TimeZone
  utc = Local.TimeZone 0 False ""
  
  zonedTimeOfDay :: T.Text -> Aeson.Parser ZonedTimeOfDay
  zonedTimeOfDay t =
    case A.parseOnly (p <* endOfInput) t of
      Left err -> fail $ "could not parse timetz: " ++ err
      Right r  -> return r
    where
      p = ZonedTimeOfDay <$> timeOfDay <*> (fromMaybe utc <$> timeZone)
  
  instance Aeson.FromJSON ZonedTimeOfDay where
    parseJSON (Aeson.String t) = zonedTimeOfDay t
    parseJSON _                = fail "Expecting a string for timetz"
  