MCPcopy
hub / github.com/django/django / format

Method format

django/utils/dateformat.py:40–52  ·  view source on GitHub ↗
(self, formatstr)

Source from the content-addressed store, hash-verified

38
39class Formatter:
40 def format(self, formatstr):
41 pieces = []
42 for i, piece in enumerate(re_formatchars.split(str(formatstr))):
43 if i % 2:
44 if type(self.data) is date and hasattr(TimeFormat, piece):
45 raise TypeError(
46 "The format for date objects may not contain "
47 "time-related format specifiers (found '%s')." % piece
48 )
49 pieces.append(str(getattr(self, piece)()))
50 elif piece:
51 pieces.append(re_escaped.sub(r"\1", piece))
52 return "".join(pieces)
53
54
55class TimeFormat(Formatter):

Callers 2

formatFunction · 0.45
time_formatFunction · 0.45

Calls 3

splitMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected