(self, o)
| 88 | """ |
| 89 | |
| 90 | def default(self, o): |
| 91 | # See "Date Time String Format" in the ECMA-262 specification. |
| 92 | if isinstance(o, datetime.datetime): |
| 93 | r = o.isoformat() |
| 94 | if o.microsecond: |
| 95 | r = r[:23] + r[26:] |
| 96 | if r.endswith("+00:00"): |
| 97 | r = r.removesuffix("+00:00") + "Z" |
| 98 | return r |
| 99 | elif isinstance(o, datetime.date): |
| 100 | return o.isoformat() |
| 101 | elif isinstance(o, datetime.time): |
| 102 | if is_aware(o): |
| 103 | raise ValueError("JSON can't represent timezone-aware times.") |
| 104 | r = o.isoformat() |
| 105 | if o.microsecond: |
| 106 | r = r[:12] |
| 107 | return r |
| 108 | elif isinstance(o, datetime.timedelta): |
| 109 | return duration_iso_string(o) |
| 110 | elif isinstance(o, (decimal.Decimal, uuid.UUID, Promise)): |
| 111 | return str(o) |
| 112 | else: |
| 113 | return super().default(o) |
nothing calls this directly
no test coverage detected