from datetime import timedelta, datetime


class TimeDelta(timedelta):
    @classmethod
    def from_timedelta(cls, delta: timedelta) -> "TimeDelta":
        return cls(days=delta.days, seconds=delta.seconds, microseconds=delta.microseconds)

    @classmethod
    def from_format_string(cls, format_string: str) -> "TimeDelta":
        formated_time = datetime.strptime(format_string, "%H:%M:%S.%f")
        return cls(hours=formated_time.hour, minutes=formated_time.minute, seconds=formated_time.second,
                   microseconds=formated_time.microsecond)

    def toFormatStr(self) -> str:
        return (datetime(year=2000, month=1, day=1) + self).strftime("%H:%M:%S.%f")[:-3]
