Skip to content

Commit 466f4ca

Browse files
committed
debug wip
1 parent 500b9f6 commit 466f4ca

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/wtforms/fields/datetime.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def __init__(
3434
def _value(self):
3535
if self.raw_data:
3636
return " ".join(self.raw_data)
37-
return self.data and self.data.strftime(self.format[0]) or ""
37+
format = self.format[0]
38+
return self.data and self.data.strftime(format) or ""
3839

3940
def process_formdata(self, valuelist):
4041
if not valuelist:

src/wtforms/utils.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import os
12
import re
23

4+
_LEADING_SYMBOL = "#" if os.name == "nt" else "-"
5+
36
# https://docs.python.org/3/library/datetime.html#technical-detail (see NOTE #9)
47
_DATETIME_STRIP_ZERO_PADDING_FORMATS_RE = re.compile(
5-
"%-["
8+
f"%{_LEADING_SYMBOL}["
69
"d" # day of month
710
"m" # month
811
"H" # hour (24-hour)
@@ -25,7 +28,7 @@ def clean_datetime_format_for_strptime(formats):
2528
return [
2629
re.sub(
2730
_DATETIME_STRIP_ZERO_PADDING_FORMATS_RE,
28-
lambda m: m[0].replace("-", ""),
31+
lambda m: m[0].replace(_LEADING_SYMBOL, ""),
2932
format,
3033
)
3134
for format in formats

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ deps =
1111
babel
1212
email_validator
1313
commands =
14-
pytest --tb=short --basetemp={envtmpdir} {posargs}
14+
pytest --tb=short -l --basetemp={envtmpdir} {posargs}
1515

1616
[testenv:coverage]
1717
deps =

0 commit comments

Comments
 (0)