Skip to content

_dump_date year conversion doesn't zfill(4) #1739

@snicolary-NYCDOHMH

Description

@snicolary-NYCDOHMH

I have some dates that have a year before year 1000 and the _dump_date function doesn't represent them as zero filled to 4 so parsing the output with '%a, %d %b %Y %H:%M:%S %Z' throws an exception.

index b428ceeb..d233d0f2 100644
--- a/src/werkzeug/http.py
+++ b/src/werkzeug/http.py
@@ -882,7 +882,7 @@ def _dump_date(d, delim):
             "Dec",
         )[d.tm_mon - 1],
         delim,
-        str(d.tm_year),
+        str(d.tm_year).zfill(4),
         d.tm_hour,
         d.tm_min,
         d.tm_sec,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions