(obj, mapping=None)
| 97 | |
| 98 | |
| 99 | def escape_timedelta(obj, mapping=None): |
| 100 | # timedelta normalizes a negative value so that seconds/microseconds are |
| 101 | # non-negative and the sign lives entirely in days, so the signed magnitude |
| 102 | # must be reconstructed before it is split into hours/minutes/seconds -- |
| 103 | # otherwise a negative TIME comes out with complemented sub-hour fields. |
| 104 | sign = "" |
| 105 | if obj.days < 0: |
| 106 | sign = "-" |
| 107 | obj = abs(obj) |
| 108 | |
| 109 | micros = obj.microseconds |
| 110 | minutes, seconds = divmod(obj.seconds, 60) |
| 111 | hours, minutes = divmod(minutes, 60) |
| 112 | hours += obj.days * 24 |
| 113 | |
| 114 | if micros: |
| 115 | return f"'{sign}{hours:02d}:{minutes:02d}:{seconds:02d}.{micros:06d}'" |
| 116 | return f"'{sign}{hours:02d}:{minutes:02d}:{seconds:02d}'" |
| 117 | |
| 118 | |
| 119 | def escape_time(obj, mapping=None): |
nothing calls this directly
no outgoing calls
no test coverage detected