File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
src/frequenz/client/electricity_trading Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -365,6 +365,32 @@ def __eq__(
365365
366366 return self .start == other .start and self .duration == other .duration
367367
368+ def __str__ (self ) -> str :
369+ """
370+ Return string representation of the DeliveryPeriod object.
371+
372+ Returns:
373+ String representation of the DeliveryPeriod object.
374+ """
375+ duration_map = {
376+ DeliveryDuration .MINUTES_5 : "5min" ,
377+ DeliveryDuration .MINUTES_15 : "15min" ,
378+ DeliveryDuration .MINUTES_30 : "30min" ,
379+ DeliveryDuration .MINUTES_60 : "60min" ,
380+ }
381+ duration_str = duration_map .get (self .duration , "Unknown duration" )
382+ start_str = self .start .strftime ("%Y-%m-%d %H:%M:%S %Z" )
383+ return f"DeliveryPeriod(start={ start_str } , duration={ duration_str } )"
384+
385+ def __repr__ (self ) -> str :
386+ """
387+ Developer-friendly representation of the DeliveryPeriod object.
388+
389+ Returns:
390+ Developer-friendly representation of the DeliveryPeriod object.
391+ """
392+ return self .__str__ ()
393+
368394 @classmethod
369395 def from_pb (cls , delivery_period : delivery_duration_pb2 .DeliveryPeriod ) -> Self :
370396 """Convert a protobuf DeliveryPeriod to DeliveryPeriod object.
You can’t perform that action at this time.
0 commit comments