diff -Nru hdbc-2.4.0.3/CHANGELOG.md hdbc-2.4.0.4/CHANGELOG.md --- hdbc-2.4.0.3/CHANGELOG.md 2001-09-09 01:46:40.000000000 +0000 +++ hdbc-2.4.0.4/CHANGELOG.md 2001-09-09 01:46:40.000000000 +0000 @@ -1,5 +1,9 @@ # Changelog +#### 2.4.0.4 + +* Zero-prefix years when parsing dates. + #### 2.4.0.3 * Compatibility with GHC 8.8/time 1.9 diff -Nru hdbc-2.4.0.3/Database/HDBC/Locale.hs hdbc-2.4.0.4/Database/HDBC/Locale.hs --- hdbc-2.4.0.3/Database/HDBC/Locale.hs 2001-09-09 01:46:40.000000000 +0000 +++ hdbc-2.4.0.4/Database/HDBC/Locale.hs 2001-09-09 01:46:40.000000000 +0000 @@ -2,7 +2,8 @@ module Database.HDBC.Locale ( defaultTimeLocale, - iso8601DateFormat + iso8601DateFormat, + oldIso8601DateFormat ) where @@ -18,6 +19,16 @@ -- (compatible) version of it. iso8601DateFormat :: Maybe String -> String iso8601DateFormat mTimeFmt = + "%0Y-%m-%d" ++ case mTimeFmt of + Nothing -> "" + Just fmt -> ' ' : fmt + +-- | HDBC would in versions up to and including 2.4.0.3 use this time format +-- string to serialize timestamps. To keep being able to deserialize timestamps +-- serialized on database engines that keep the representation intact (e.g. +-- SQLite) we keep this format string around, such that we can fall back to it. +oldIso8601DateFormat :: Maybe String -> String +oldIso8601DateFormat mTimeFmt = "%Y-%m-%d" ++ case mTimeFmt of Nothing -> "" Just fmt -> ' ' : fmt diff -Nru hdbc-2.4.0.3/Database/HDBC/SqlValue.hs hdbc-2.4.0.4/Database/HDBC/SqlValue.hs --- hdbc-2.4.0.3/Database/HDBC/SqlValue.hs 2001-09-09 01:46:40.000000000 +0000 +++ hdbc-2.4.0.4/Database/HDBC/SqlValue.hs 2001-09-09 01:46:40.000000000 +0000 @@ -9,6 +9,7 @@ ) where +import Control.Applicative ((<|>)) import Data.Dynamic import qualified Data.ByteString.UTF8 as BUTF8 import qualified Data.ByteString as B @@ -28,7 +29,7 @@ #endif ) import Data.Time.Clock.POSIX -import Database.HDBC.Locale (defaultTimeLocale, iso8601DateFormat) +import Database.HDBC.Locale (defaultTimeLocale, iso8601DateFormat, oldIso8601DateFormat) import Data.Ratio import Data.Convertible import Data.Fixed @@ -609,7 +610,7 @@ instance Convertible Day SqlValue where safeConvert = return . SqlLocalDate instance Convertible SqlValue Day where - safeConvert (SqlString x) = parseTime' (iso8601DateFormat Nothing) x + safeConvert (SqlString x) = parseTimeISO8601 Nothing x safeConvert (SqlByteString x) = safeConvert (SqlString (BUTF8.toString x)) safeConvert (SqlInt32 x) = return $ ModifiedJulianDay {toModifiedJulianDay = fromIntegral x} @@ -704,7 +705,7 @@ instance Convertible LocalTime SqlValue where safeConvert = return . SqlLocalTime instance Convertible SqlValue LocalTime where - safeConvert (SqlString x) = parseTime' (iso8601DateFormat (Just "%T%Q")) x + safeConvert (SqlString x) = parseTimeISO8601 (Just "%T%Q") x safeConvert (SqlByteString x) = safeConvert (SqlString (BUTF8.toString x)) safeConvert y@(SqlInt32 _) = quickError y safeConvert y@(SqlInt64 _) = quickError y @@ -730,7 +731,7 @@ instance Convertible ZonedTime SqlValue where safeConvert = return . SqlZonedTime instance Convertible SqlValue ZonedTime where - safeConvert (SqlString x) = parseTime' (iso8601DateFormat (Just "%T%Q %z")) x + safeConvert (SqlString x) = parseTimeISO8601 (Just "%T%Q %z") x safeConvert (SqlByteString x) = safeConvert (SqlString (BUTF8.toString x)) safeConvert (SqlInt32 x) = safeConvert (SqlInteger (fromIntegral x)) safeConvert (SqlInt64 x) = safeConvert (SqlInteger (fromIntegral x)) @@ -756,7 +757,7 @@ instance Convertible UTCTime SqlValue where safeConvert = return . SqlUTCTime instance Convertible SqlValue UTCTime where - safeConvert (SqlString x) = parseTime' (iso8601DateFormat (Just "%T%Q")) x + safeConvert (SqlString x) = parseTimeISO8601 (Just "%T%Q") x safeConvert (SqlByteString x) = safeConvert (SqlString (BUTF8.toString x)) safeConvert y@(SqlInt32 _) = safeConvert y >>= return . posixSecondsToUTCTime safeConvert y@(SqlInt64 _) = safeConvert y >>= return . posixSecondsToUTCTime @@ -957,3 +958,16 @@ (SqlString inpstr) Just x -> Right x #endif + +parseTimeISO8601 :: (Typeable t, Convertible SqlValue t, ParseTime t) => Maybe String -> String -> ConvertResult t +parseTimeISO8601 fmtstr inpstr = + case tryParse iso8601DateFormat <|> tryParse oldIso8601DateFormat of + Nothing -> convError "Cannot parse ISO8601 timestamp" (SqlString inpstr) + Just x -> Right x + where + tryParse fmtFunction = +#if MIN_TIME_15 + parseTimeM True defaultTimeLocale (fmtFunction fmtstr) inpstr +#else + parseTime defaultTimeLocale (fmtFunction fmtstr) inpstr +#endif diff -Nru hdbc-2.4.0.3/debian/changelog hdbc-2.4.0.4/debian/changelog --- hdbc-2.4.0.3/debian/changelog 2020-10-29 20:57:54.000000000 +0000 +++ hdbc-2.4.0.4/debian/changelog 2022-07-03 12:52:56.000000000 +0000 @@ -1,14 +1,9 @@ -hdbc (2.4.0.3-1build2) hirsute; urgency=medium +hdbc (2.4.0.4-1) unstable; urgency=medium - * No-change rebuild for new GHC ABIs + * New upstream release (Closes: #1013559) + * Declare compliance with Debian policy 4.6.1 - -- Steve Langasek Thu, 29 Oct 2020 20:57:54 +0000 - -hdbc (2.4.0.3-1build1) groovy; urgency=medium - - * Rebuild against new GHC abi. - - -- Gianfranco Costamagna Wed, 22 Jul 2020 14:26:44 +0200 + -- Ilias Tsitsimpis Sun, 03 Jul 2022 15:52:56 +0300 hdbc (2.4.0.3-1) unstable; urgency=medium diff -Nru hdbc-2.4.0.3/debian/control hdbc-2.4.0.4/debian/control --- hdbc-2.4.0.3/debian/control 2020-10-29 20:57:54.000000000 +0000 +++ hdbc-2.4.0.4/debian/control 2022-07-03 12:52:56.000000000 +0000 @@ -1,6 +1,5 @@ Source: hdbc -Maintainer: Ubuntu Developers -XSBC-Original-Maintainer: Debian Haskell Group +Maintainer: Debian Haskell Group Uploaders: John Goerzen , Priority: optional @@ -20,7 +19,7 @@ ghc-doc, libghc-convertible-doc, libghc-utf8-string-doc, -Standards-Version: 4.1.4 +Standards-Version: 4.6.1 Homepage: https://github.com/hdbc/hdbc Vcs-Browser: https://salsa.debian.org/haskell-team/DHG_packages/tree/master/p/hdbc Vcs-Git: https://salsa.debian.org/haskell-team/DHG_packages.git [p/hdbc] diff -Nru hdbc-2.4.0.3/HDBC.cabal hdbc-2.4.0.4/HDBC.cabal --- hdbc-2.4.0.3/HDBC.cabal 2001-09-09 01:46:40.000000000 +0000 +++ hdbc-2.4.0.4/HDBC.cabal 2001-09-09 01:46:40.000000000 +0000 @@ -1,5 +1,5 @@ Name: HDBC -Version: 2.4.0.3 +Version: 2.4.0.4 License: BSD3 Maintainer: Nicolas Wu Author: John Goerzen, Nicolas Wu @@ -16,7 +16,7 @@ Stability: Stable Build-Type: Simple -Cabal-Version: >=1.8 +Cabal-Version: >=1.10 source-repository head type: git @@ -35,10 +35,10 @@ if flag(splitBase) Build-Depends: base>=3 && <5, old-time, bytestring, containers if flag(minTime15) - Build-Depends: time >= 1.5 && < 1.10 + Build-Depends: time >= 1.5 && < 1.14 CPP-Options: -DMIN_TIME_15 else - Build-Depends: time < 1.5, old-locale + Build-Depends: time >= 1.2 && < 1.5, old-locale else Build-Depends: base<3 Build-Depends: mtl, convertible >= 1.1.0.0, text, utf8-string @@ -54,21 +54,23 @@ Database.HDBC.ColTypes, Database.HDBC.Statement, Database.HDBC.SqlValue, Database.HDBC.Locale Other-Modules: Database.HDBC.Utils - Extensions: ExistentialQuantification, CPP, MultiParamTypeClasses, + Default-Extensions: ExistentialQuantification, CPP, MultiParamTypeClasses, FlexibleContexts, TypeSynonymInstances, TypeOperators, RankNTypes, FlexibleInstances, DeriveDataTypeable + Default-Language: Haskell2010 Executable runtests if flag(buildtests) Buildable: True - Build-Depends: HUnit, QuickCheck (>= 2.0), testpack (>= 2.0) + Build-Depends: HUnit, QuickCheck >= 2.0 if flag(splitBase) Build-Depends: base>=3 && <5, old-time, bytestring, containers if flag(minTime15) - Build-Depends: time >= 1.5 && < 1.9 + Build-Depends: time >= 1.5 && < 1.14 + CPP-Options: -DMIN_TIME_15 else - Build-Depends: time < 1.5, old-locale + Build-Depends: time >= 1.2 && < 1.5, old-locale else Build-Depends: base<3 Build-Depends: mtl, convertible >= 1.1.0.0, utf8-string, text @@ -81,9 +83,9 @@ Buildable: False Main-Is: runtests.hs Other-Modules: TestSqlValue - TestInfrastructure Hs-Source-Dirs: ., testsrc GHC-Options: -O2 - Extensions: ExistentialQuantification, CPP, MultiParamTypeClasses, + Default-Extensions: ExistentialQuantification, CPP, MultiParamTypeClasses, FlexibleContexts, TypeSynonymInstances, TypeOperators, RankNTypes, FlexibleInstances + Default-Language: Haskell2010 diff -Nru hdbc-2.4.0.3/testsrc/runtests.hs hdbc-2.4.0.4/testsrc/runtests.hs --- hdbc-2.4.0.3/testsrc/runtests.hs 2001-09-09 01:46:40.000000000 +0000 +++ hdbc-2.4.0.4/testsrc/runtests.hs 2001-09-09 01:46:40.000000000 +0000 @@ -1,14 +1,9 @@ module Main where import qualified Test.HUnit as HU -import Test.HUnit.Tools +import Test.QuickCheck (quickCheck) import qualified TestSqlValue -test1 = HU.TestCase ((HU.@=?) "x" "x") - -alltests = [HU.TestLabel "test1" test1, - tl "TestSqlValue" TestSqlValue.allt - ] - -main = do runVerboseTests (HU.TestList alltests) +main = do HU.runTestTT (HU.TestList $ TestSqlValue.allHUnitTests) + traverse quickCheck TestSqlValue.allQuickCheckTests return () diff -Nru hdbc-2.4.0.3/testsrc/TestInfrastructure.hs hdbc-2.4.0.4/testsrc/TestInfrastructure.hs --- hdbc-2.4.0.3/testsrc/TestInfrastructure.hs 2001-09-09 01:46:40.000000000 +0000 +++ hdbc-2.4.0.4/testsrc/TestInfrastructure.hs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -{- -Copyright (C) 2009 John Goerzen - -All rights reserved. - -For license and copyright information, see the file COPYRIGHT --} -module TestInfrastructure where -import qualified Test.QuickCheck as QC -import qualified Test.HUnit as HU -import Test.HUnit.Tools - -q :: QC.Testable a => String -> a -> HU.Test -q = qc2hu 250 - -qverbose :: QC.Testable a => String -> a -> HU.Test -qverbose = qc2hu 250 diff -Nru hdbc-2.4.0.3/testsrc/TestSqlValue.hs hdbc-2.4.0.4/testsrc/TestSqlValue.hs --- hdbc-2.4.0.3/testsrc/TestSqlValue.hs 2001-09-09 01:46:40.000000000 +0000 +++ hdbc-2.4.0.4/testsrc/TestSqlValue.hs 2001-09-09 01:46:40.000000000 +0000 @@ -7,27 +7,25 @@ -} module TestSqlValue where -import TestInfrastructure import Test.QuickCheck hiding (Result) import Test.QuickCheck.Property (Result) -import Test.QuickCheck.Tools import qualified Test.HUnit as HU import Database.HDBC -import Data.Time.Format +import Data.Time.Format (parseTime) import Data.Time.LocalTime -import Database.HDBC.Locale (defaultTimeLocale, iso8601DateFormat) +import Database.HDBC.Locale (defaultTimeLocale, iso8601DateFormat, oldIso8601DateFormat) import Data.Maybe instance Eq ZonedTime where a == b = zonedTimeToUTC a == zonedTimeToUTC b && zonedTimeZone a == zonedTimeZone b -toSql_Int :: Int -> Result -toSql_Int x = toSql x @?= SqlInt64 (fromIntegral x) +toSql_Int :: Int -> Property +toSql_Int x = toSql x === SqlInt64 (fromIntegral x) -fromSql_Int :: Int -> Result +fromSql_Int :: Int -> Property fromSql_Int x = - Right x @=? safeFromSql (SqlInt64 (fromIntegral x)) + Right x === safeFromSql (SqlInt64 (fromIntegral x)) testZonedTimeStr = "1989-08-01 15:33:01 -0500" testZonedTime :: ZonedTime @@ -39,14 +37,25 @@ testZonedTimeFrac = fromJust $ parseTime defaultTimeLocale (iso8601DateFormat (Just "%T%Q %z")) testZonedTimeFracStr +testZonedTimeTwoDigitYearStr = "89-08-01 15:33:01 -0500" +testZonedTimeTwoDigitYear :: ZonedTime +testZonedTimeTwoDigitYear = fromJust $ parseTime defaultTimeLocale (oldIso8601DateFormat (Just "%T %z")) + testZonedTimeTwoDigitYearStr + ztparsenf = (HU.@=?) testZonedTime (fromSql (SqlString testZonedTimeStr)) ztparsef = (HU.@=?) testZonedTimeFrac (fromSql (SqlString testZonedTimeFracStr)) +ztparseTwoDigitYear = + (HU.@=?) testZonedTimeTwoDigitYear (fromSql (SqlString testZonedTimeTwoDigitYearStr)) hut msg = HU.TestLabel msg . HU.TestCase -allt = [q "toSql Int" toSql_Int, - q "safeFromSql Int" fromSql_Int, - hut "non-frac parse" ztparsenf, - hut "frac parse" ztparsef] +allHUnitTests = [hut "non-frac parse" ztparsenf, + hut "frac parse" ztparsef, + hut "old serialization of two digit year without leading zeros" ztparseTwoDigitYear + ] + +allQuickCheckTests = [toSql_Int, + fromSql_Int + ]