Skip to content

Commit

Permalink
Fix optimization of default time format
Browse files Browse the repository at this point in the history
  • Loading branch information
Delgan committed Jan 17, 2025
1 parent f3830e1 commit 3ace6db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions loguru/_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ def _loguru_datetime_formatter(is_utc, format_string, formatters, dt):


def _default_datetime_formatter(dt):
return "%04d-%02d-%02d %02d:%02d:%02d.%03d" % (
return "%04d-%02d-%02d %02d:%02d:%02d.%03d %s" % (
dt.year,
dt.month,
dt.day,
dt.hour,
dt.minute,
dt.second,
dt.microsecond // 1000,
_format_timezone(dt, sep=":"),
)


Expand All @@ -52,7 +53,7 @@ def _format_timezone(dt, *, sep):

@lru_cache(maxsize=32)
def _compile_format(spec):
if spec == "YYYY-MM-DD HH:mm:ss.SSS":
if spec == "YYYY-MM-DD HH:mm:ss.SSS Z":
return _default_datetime_formatter

is_utc = spec.endswith("!UTC")
Expand Down

0 comments on commit 3ace6db

Please sign in to comment.