Skip to content

Commit

Permalink
th_TH strftime: normalize output for unsupported directive (joke2k#1336)
Browse files Browse the repository at this point in the history
This will fix joke2k#1333
  • Loading branch information
bact authored and fcurella committed Jun 2, 2021
1 parent 9f9f2d3 commit 931a4c3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions faker/providers/date_time/th_TH/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ def _std_strftime(dt_obj: datetime, fmt_char: str) -> str:
str_ = ""
try:
str_ = dt_obj.strftime("%{}".format(fmt_char))
if str_ == "%{}".format(fmt_char):
if not str_ or str_ == "%{}".format(fmt_char):
# normalize outputs for unsupported directives
# in different platforms
# unsupported "%Q" in platform A may return "Q"
# unsupported "%Q" in platform A may return "%Q"
# "%Q" may result "%Q", "Q", or "", make it "Q"
str_ = fmt_char
except ValueError as err: # pragma: no cover
# Unsupported directives may raise ValueError on Windows,
Expand Down

0 comments on commit 931a4c3

Please sign in to comment.