From 3df0b84c0636469677f6ceb326004c8ff136c37d Mon Sep 17 00:00:00 2001 From: Gabriella Gonzalez Date: Sun, 16 Oct 2022 08:09:01 -0700 Subject: [PATCH 1/2] Fix pretty-printing of `Time` literals The pretty-printer was stripping leading zeros from the fractional component of the time --- dhall/src/Dhall/Pretty/Internal.hs | 2 +- dhall/tests/format/timePrecisionA.dhall | 3 +++ dhall/tests/format/timePrecisionB.dhall | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 dhall/tests/format/timePrecisionA.dhall create mode 100644 dhall/tests/format/timePrecisionB.dhall diff --git a/dhall/src/Dhall/Pretty/Internal.hs b/dhall/src/Dhall/Pretty/Internal.hs index 3ab067332..37b0228be 100644 --- a/dhall/src/Dhall/Pretty/Internal.hs +++ b/dhall/src/Dhall/Pretty/Internal.hs @@ -1354,7 +1354,7 @@ prettyPrinters characterSet = suffix | precision == 0 = "" - | otherwise = "." <> Pretty.pretty fraction + | otherwise = "." <> Pretty.pretty (Printf.printf "%0*d" precision fraction :: String) prettyPrimitiveExpression TimeZone = builtin "TimeZone" prettyPrimitiveExpression (TimeZoneLiteral (Time.TimeZone minutes _ _)) = diff --git a/dhall/tests/format/timePrecisionA.dhall b/dhall/tests/format/timePrecisionA.dhall new file mode 100644 index 000000000..55874f7b2 --- /dev/null +++ b/dhall/tests/format/timePrecisionA.dhall @@ -0,0 +1,3 @@ +-- This test ensures that we don't strip leading zeros from the fractional +-- component of seconds when pretty-printing them +00:00:00.01 diff --git a/dhall/tests/format/timePrecisionB.dhall b/dhall/tests/format/timePrecisionB.dhall new file mode 100644 index 000000000..1038808b2 --- /dev/null +++ b/dhall/tests/format/timePrecisionB.dhall @@ -0,0 +1 @@ +00:00:00.01 From 9fdb00495785b37b8cdf29fd31c38080e05107da Mon Sep 17 00:00:00 2001 From: Gabriella Gonzalez Date: Sun, 23 Oct 2022 09:03:03 -0700 Subject: [PATCH 2/2] Fix test failure --- dhall/tests/format/timePrecisionB.dhall | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dhall/tests/format/timePrecisionB.dhall b/dhall/tests/format/timePrecisionB.dhall index 1038808b2..55874f7b2 100644 --- a/dhall/tests/format/timePrecisionB.dhall +++ b/dhall/tests/format/timePrecisionB.dhall @@ -1 +1,3 @@ +-- This test ensures that we don't strip leading zeros from the fractional +-- component of seconds when pretty-printing them 00:00:00.01