Skip to content

timedelta_factory

Time delta factory, contains positive timedelta values and a helper factory method to create a timedelta object.

Classes

TimeDeltaFactory

Bases: BaseDataModel

Time delta model, contains positive timedelta values and a helper factory method to create a timedelta object.

Attributes:

  • days (int) –

    Days field, default is 0.

  • seconds (int) –

    Seconds field, default is 0.

  • microseconds (int) –

    Microseconds field, default is 0.

  • milliseconds (int) –

    Milliseconds field, default is 0.

  • minutes (int) –

    Minutes field, default is 0.

  • hours (int) –

    Hours field, default is 0.

  • weeks (int) –

    Weeks field, default is 0.

Attributes

days class-attribute instance-attribute
days: int = Field(
    default=0, ge=0, title="Days", description="Days field"
)
hours class-attribute instance-attribute
hours: int = Field(
    default=0,
    ge=0,
    title="Hours",
    description="Hours field",
)
microseconds class-attribute instance-attribute
microseconds: int = Field(
    default=0,
    ge=0,
    title="Microseconds",
    description="Microseconds field",
)
milliseconds class-attribute instance-attribute
milliseconds: int = Field(
    default=0,
    ge=0,
    title="Milliseconds",
    description="Milliseconds field",
)
minutes class-attribute instance-attribute
minutes: int = Field(
    default=0,
    ge=0,
    title="Minutes",
    description="Minutes field",
)
seconds class-attribute instance-attribute
seconds: int = Field(
    default=0,
    ge=0,
    title="Seconds",
    description="Seconds field",
)
weeks class-attribute instance-attribute
weeks: int = Field(
    default=0,
    ge=0,
    title="Weeks",
    description="Weeks field",
)

Functions

timedelta
timedelta() -> timedelta

Create a timedelta object from the model.

Returns:

  • timedelta ( timedelta ) –

    A timedelta object created from the model’s attributes.

Example
factory = TimeDeltaFactory(days=1, hours=2)
delta = factory.timedelta()
print(delta)  # Output: 1 day, 2:00:00