Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
amazonka-core: Accept single-digit days when parsing RFC822 dates
These are uncommon but sent by some S3-style servers, such as the one
in `rclone serve s3` circa 2024:

rclone/rclone#8277
  • Loading branch information
endgame committed Mar 10, 2025
commit abdcad2a5ec036c32e38df16cad77abf02e70356
15 changes: 14 additions & 1 deletion lib/amazonka-core/src/Amazonka/Data/Time.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,20 @@ parseFormattedTime = do
++ show s
)

parse (format (Proxy @RFC822))
-- A more lenient format string for parsing RFC822, whose
-- grammar allows single-digit days.
--
-- We still use `%d` over `%-d` in the `TimeFormat RFC822`
-- instance to always produce two-digit days, since that is what
-- most people expect to see.
--
-- This allows us to parse responses from versions of
-- `rclone serve s3` circa 2024:
-- https://github.com/rclone/rclone/issues/8277
rfc822 :: String
rfc822 = "%a, %-d %b %Y %H:%M:%S %Z"

parse rfc822
<|> parse (format (Proxy @ISO8601))
<|> parse (format (Proxy @BasicTime))
<|> parse (format (Proxy @AWSTime))
Expand Down
4 changes: 4 additions & 0 deletions lib/amazonka-core/test/Test/Amazonka/Data/Time.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ tests =
"rfc822 - GMT"
"Fri, 07 Nov 2014 04:42:13 GMT"
(time :: RFC822),
testFromText
"rfc822 - GMT - single-digit day"
"Fri, 7 Nov 2014 04:42:13 GMT"
(time :: RFC822),
testFromText
"rfc822 - PST"
"Fri, 06 Nov 2014 20:42:13 PST"
Expand Down
2 changes: 2 additions & 0 deletions lib/amazonka/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

### Fixed

- `amazonka-core`: Accept single-digit days when parsing RFC822 dates
[\#1032](https://github.com/brendanhay/amazonka/pull/1032)
- `amazonka`: Attempt to load credentials in the correct order. In particular, this means that the IMDS is queried last and is once again consistent with other SDKs.
[\#1029](https://github.com/brendanhay/amazonka/pull/1029)
- `.cabal` files name the source repository with a `https://` URL, not a `git://` one (thanks @marinelli)
Expand Down