MCPcopy Index your code
hub / github.com/python-pendulum/pendulum / _to_string

Method _to_string

src/pendulum/datetime.py:454–465  ·  view source on GitHub ↗

Format the instance to a common string format.

(self, fmt: str, locale: str | None = None)

Source from the content-addressed store, hash-verified

452 return self._to_string("w3c")
453
454 def _to_string(self, fmt: str, locale: str | None = None) -> str:
455 """
456 Format the instance to a common string format.
457 """
458 if fmt not in self._FORMATS:
459 raise ValueError(f"Format [{fmt}] is not supported")
460
461 fmt_value = self._FORMATS[fmt]
462 if callable(fmt_value):
463 return fmt_value(self)
464
465 return self.format(fmt_value, locale=locale)
466
467 def __str__(self) -> str:
468 return self.isoformat(" ")

Callers 12

to_atom_stringMethod · 0.95
to_cookie_stringMethod · 0.95
to_iso8601_stringMethod · 0.95
to_rfc822_stringMethod · 0.95
to_rfc850_stringMethod · 0.95
to_rfc1036_stringMethod · 0.95
to_rfc1123_stringMethod · 0.95
to_rfc2822_stringMethod · 0.95
to_rfc3339_stringMethod · 0.95
to_rss_stringMethod · 0.95
to_w3c_stringMethod · 0.95
test_to_string_invalidFunction · 0.80

Calls 1

formatMethod · 0.45

Tested by 1

test_to_string_invalidFunction · 0.64