Duration
classin packageklyn.time
public class Duration extends Object implements ValueType:
└ Duration
All Implemented Interfaces: ValueType

Represents a duration of time.

This class provides methods to create and manipulate durations. It supports initialization from individual time components and provides arithmetic operations.

import klyn.time

duration = Duration(0, 0, 0, 3600)
print(duration.toString())  # Output: 1 h 0 m 0 s
Since

1.0

Properties
Modifier and Type Member Description
public readonly property totalSeconds
totalSeconds as Double:
Returns the total number of seconds in the duration.
Properties inherited from Object: type
Constructors
Modifier and Type Member Description
public Duration
Duration(days as Int = 0, hours as Int = 0, minutes as Int = 0, seconds as Double = 0.0, useconds as Int = 0):
Constructs a Duration object from individual time components.
Methods
Modifier and Type Member Description
public override toString
toString(format as String = "%h h %m m %s s") as String:
Returns a string representation of this Duration.
Methods inherited from Object: deepCopy, fromJson, toDict, toJson, toString, toXml
Operators
Modifier and Type Member Description
public static operator*(first as Duration, factor as Double) as Duration: Multiplies a Duration by a numeric factor.
public static operator+(first as Duration, second as Duration) as Duration: Adds two Duration values.
public static operator-(first as Duration, second as Duration) as Duration: Subtracts two Duration values.
public static operator<(first as Duration, second as Duration) as Boolean: Returns true when the first duration is shorter than the second one.
public static operator<=(first as Duration, second as Duration) as Boolean: Returns true when the first duration is shorter than or equal to the second one.
public static operator>(first as Duration, second as Duration) as Boolean: Returns true when the first duration is longer than the second one.
public static operator>=(first as Duration, second as Duration) as Boolean: Returns true when the first duration is longer than or equal to the second one.