{-# LANGUAGE OverloadedStrings  #-}
module TimeParseSpec where

import            Control.Monad.Except
import            Data.Time
import            Test.Hspec

import            LuminescentDreams.Text.TimeParsers


-- 2016-11-05 13:18:00 CDT
-- 2016-11-05 13:18:00 UTC
-- 2016-11-05 13:18:00
-- 2016-11-05 13:18 CDT
-- 2016-11-05 13:18 UTC
-- 2016-11-05 13:18
-- 2016-11-05

zonedTimeSpec :: Spec
zonedTimeSpec = describe "Parses partial zoned time entries" $ do
  it "parses a full string complete with timezone" $
    runExcept (parseZonedTime "2016-11-04 15:00:00 CDT") `shouldBe`
      Right (UTCTime (fromGregorian 2016 11 04) 72000)

  it "parses a date and time with an explicit UTC timezone" $
    runExcept (parseZonedTime "2016-11-04 15:00:00 UTC") `shouldBe`
      Right (UTCTime (fromGregorian 2016 11 04) 54000)

  it "parses a date and time with a time zone but without seconds" $
    runExcept (parseZonedTime "2016-11-05 13:18 CDT") `shouldBe`
      Right (UTCTime (fromGregorian 2016 11 05) 65880)

  it "parses a date and time without a timezone specified" pending

  it "parses just a date" pending

  it "fails if the day of the month is out of range" pending

  it "fails on a malformed date string" $ pendingWith "TODO: test for this bug"
    -- (runExcept $ parseZonedTime "2016-a-b-c") `shouldBe` Left UnparsableDate

spec :: Spec
spec = zonedTimeSpec
