<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_struct(self, value):
 """Cast `time` object to string."""

        if self.str_format:
            return value.strftime(self.str_format)
        return value.isoformat()