@@ -193,12 +193,13 @@ day dd = encodeYear yr <>
193193 !(T dh dl) = twoDigits d
194194 encodeYear y
195195 | y >= 1000 = B.integerDec y
196− | y > 0 =
197− let (ab,c) = fromIntegral y `quotRem` 10
198− (a,b) = ab `quotRem` 10
199− in BP.primBounded (ascii4 ('0',(digit a,(digit b,digit c)))) ()
200− | otherwise =
201− error "Data.Aeson.Encode.Builder.day: years BCE not supported"
196+ | y >= 0 = BP.primBounded (ascii4 (padYear y)) ()
197+ | y >= -999 = BP.primBounded (ascii5 ('-',padYear y)) ()
198+ | otherwise = B.integerDec y
199+ padYear y =
200+ let (ab,c) = fromIntegral y `quotRem` 10
201+ (a,b) = ab `quotRem` 10
202+ in ('0',(digit a,(digit b,digit c)))
202203{-# INLINE day #-}
203204
204205timeOfDay :: TimeOfDay -> Builder