Duration
class in package klyn.time

    public class Duration extends Object implements ValueType:

Object
└ 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

Properties

Modifier and Type | Member | Description
--- | --- | ---
public readonly property | totalSeconds `totalSeconds as Double:` | Returns the total number of seconds in the duration.

Inherited Properties
property Inherited Properties 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() as String:` | Returns a string representation of this Duration.
public | toString `toString(format as String) as String:` | Returns a string representation using a custom duration format.

Inherited Methods
method Inherited Methods 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.