Previous topic

stalker.core.mixins.ReferenceMixin

Next topic

stalker.core.mixins.StatusMixin

This Page

stalker.core.mixins.ScheduleMixin

Inheritance diagram of stalker.core.mixins.ScheduleMixin

class stalker.core.mixins.ScheduleMixin(start_date=None, due_date=None, duration=None, **kwargs)[source]

Bases: object

Adds schedule info to the mixed in class.

Adds schedule information like start_date, due_date and duration. There are theree parameters to initialize a class with ScheduleMixin, which are, start_date, due_date and duration. Only two of them are enough to initialize the class. The preceeding order for the parameters is as follows:

start_date > due_date > duration

So if all of the parameters are given only the start_date and the due_date will be used and the duration will be calculated accordingly. In any other conditions the missing parameter will be calculated from the following table:

start_date due_date duration DEFAULTS
     

start_date = datetime.date.today()

duration = datetime.timedelta(days=10)

due_date = start_date + duration

X    

duration = datetime.timedelta(days=10)

due_date = start_date + duration

X X   duration = due_date - start_date
X   X due_date = start_date + duration
X X X duration = due_date - start_date
  X X start_date = due_date - duration
  X  

duration = datetime.timedelta(days=10)

start_date = due_date - duration

    X

start_date = datetime.date.today()

due_date = start_date + duration

The date attributes can be managed with timezones. Follow the Python idioms shown in the documentation of datetime

Parameters:
  • start_date (datetime.datetime) – the start date of the entity, should be a datetime.date instance, the start_date is the pin point for the date calculation. In any condition if the start_date is available then the value will be preserved. If start_date passes the due_date the due_date is also changed to a date to keep the timedelta between dates. The default value is datetime.date.today()
  • due_date (datetime.datetime or datetime.timedelta) – the due_date of the entity, should be a datetime.date instance, when the start_date is changed to a date passing the due_date, then the due_date is also changed to a later date so the timedelta between the dates is kept.
  • duration (datetime.timedelta) – The duration of the entity. It is a datetime.timedelta instance. The default value is read from the defaults module. See the table above for the initialization rules.
__init__(start_date=None, due_date=None, duration=None, **kwargs)[source]

Methods

__init__(**kwargs[, start_date, due_date, ...])

Attributes

due_date The date that the entity should be delivered.
duration Duration of the entity.
start_date The date that this entity should start.
due_date[source]

The date that the entity should be delivered.

The due_date can be set to a datetime.timedelta and in this case it will be calculated as an offset from the start_date and converted to datetime.date again. Setting the start_date to a date passing the due_date will also set the due_date so the timedelta between them is preserved, default value is 10 days

start_date[source]

The date that this entity should start.

Also effects the due_date attribute value in certain conditions, if the start_date is set to a time passing the due_date it will also offset the due_date to keep the duration value fixed. start_date should be an instance of class:datetime.date and the default value is datetime.date.today()

duration[source]

Duration of the entity.

It is a datetime.timedelta instance. Showing the difference of the start_date and the due_date. If edited it changes the due_date attribute value.