Fork me on Github

Interface CalendR\Period\ PeriodInterface

Interface that all Periods must implement.

Methods

bool contains( DateTime $date)

Checks if the given period is contained in the current period

DateTime getBegin()

Gets the DateTime of period begin

DateTime getEnd()

Gets the DateTime of the period end

PeriodInterface getNext()

Gets the next period of the same type

PeriodInterface getPrevious()

Gets the previous period of the same type

DatePeriod getDatePeriod()

Returns the period as a DatePeriod

bool equals( PeriodInterface $period)

Checks if a period is equals to an other

includes( PeriodInterface $period, bool $strict = true)

Returns true if the period include the other period given as argument

boolean containsEvent( EventInterface $event)

Returns if $event is during this period.

string format( string $format)

Format the period to a string

boolean isCurrent()

Returns if the current period is the current one

setFirstWeekday( int $firstWeekday)

Sets the first day of week

static isValid( DateTime $start)

Checks if $start is good for building the period

static DateInterval getDateInterval()

Returns a \DateInterval equivalent to the period

Details

public bool contains( DateTime $date)

Checks if the given period is contained in the current period

Parameters
DateTime $date
Return Value
bool true if the period contains this date

public DateTime getBegin()

Gets the DateTime of period begin

Return Value
DateTime

public DateTime getEnd()

Gets the DateTime of the period end

Return Value
DateTime

public PeriodInterface getNext()

Gets the next period of the same type

Return Value
PeriodInterface

public PeriodInterface getPrevious()

Gets the previous period of the same type

Return Value
PeriodInterface

public DatePeriod getDatePeriod()

Returns the period as a DatePeriod

Return Value
DatePeriod

public bool equals( PeriodInterface $period)

Checks if a period is equals to an other

Parameters
PeriodInterface $period
Return Value
bool

public includes( PeriodInterface $period, bool $strict = true)

Returns true if the period include the other period given as argument

Parameters
PeriodInterface $period
bool $strict

public boolean containsEvent( EventInterface $event)

Returns if $event is during this period.

Non strict. Must return true if : * Event is during period * Period is during event * Event begin is during Period * Event end is during Period

Parameters
EventInterface $event
Return Value
boolean

public string format( string $format)

Format the period to a string

Parameters
string $format
Return Value
string

public boolean isCurrent()

Returns if the current period is the current one

Return Value
boolean

public setFirstWeekday( int $firstWeekday)

Sets the first day of week

Parameters
int $firstWeekday

static public isValid( DateTime $start)

Checks if $start is good for building the period

Parameters
DateTime $start

static public DateInterval getDateInterval()

Returns a \DateInterval equivalent to the period

Return Value
DateInterval