Menu

## TimeKeeper
in package

TimeKeeper.php : 11

Configurable way to convert back and forth between real time and game time.

### Table of Contents

$adjustedEpoch : mixed
$now : mixed
$secondsPerDay : mixed
$secondsPerGameDay : mixed
$secondsPerGameHour : mixed
$secondsPerGameMinute : mixed
$secondsPerGameSecond : mixed
$secondsPerGameYear : mixed
$secondsPerHour : mixed
$secondsPerMinute : mixed
$theBeginning : mixed
__construct() : mixed
  Construct a TimeKeeper with required configuration.
convertFromGameTime() : DateTime
  Given a game time, convert it to a real time.
convertToGameTime() : DateTime
  Given a real time, convert it to a game time.
getGameTime() : DateTime
  Return the current game time.
isNewDay() : bool
  Returns whether a user who is interating with the game now and last interacted at $lastInteractionTime should experience a New Day event.
interval() : DateInterval
  Convenience method to generate a DateInterval from an exploded date.

### Properties

#### $adjustedEpoch

TimeKeeper.php : 13
`private mixed $adjustedEpoch`

#### $now

TimeKeeper.php : 25
`private mixed $now`

#### $secondsPerDay

TimeKeeper.php : 18
`private mixed $secondsPerDay = 60 * 60 * 24`

#### $secondsPerGameDay

TimeKeeper.php : 20
`private mixed $secondsPerGameDay`

#### $secondsPerGameHour

TimeKeeper.php : 21
`private mixed $secondsPerGameHour`

#### $secondsPerGameMinute

TimeKeeper.php : 22
`private mixed $secondsPerGameMinute`

#### $secondsPerGameSecond

TimeKeeper.php : 23
`private mixed $secondsPerGameSecond`

#### $secondsPerGameYear

TimeKeeper.php : 19
`private mixed $secondsPerGameYear`

#### $secondsPerHour

TimeKeeper.php : 17
`private mixed $secondsPerHour = 60 * 60`

#### $secondsPerMinute

TimeKeeper.php : 16
`private mixed $secondsPerMinute = 60`

#### $theBeginning

TimeKeeper.php : 14
`private mixed $theBeginning`

### Methods

#### __construct()

TimeKeeper.php : 34

Construct a TimeKeeper with required configuration.

`public __construct(DateTime $gameEpoch, DateTime $now, int $gameOffsetSeconds, int $gameDaysPerDay) : mixed`

##### Parameters

$gameEpoch : DateTime

  When in real time is game day 0.

$now : DateTime

  The current time.

$gameOffsetSeconds : int

  How many seconds from midnight on the epoch should the first game day start.

$gameDaysPerDay : int

  How many game days are in one real day.

##### Return values

mixed —

#### convertFromGameTime()

TimeKeeper.php : 97

Given a game time, convert it to a real time.

`public convertFromGameTime(DateTime $time) : DateTime`

##### Parameters

$time : DateTime

  Game time to convert.

##### Return values

DateTime —

Real time corresponding to game time $time.

#### convertToGameTime()

TimeKeeper.php : 117

Given a real time, convert it to a game time.

`public convertToGameTime(DateTime $time) : DateTime`

##### Parameters

$time : DateTime

  Real time to convert.

##### Return values

DateTime —

Game time corresponding to real time $time.

#### getGameTime()

TimeKeeper.php : 87

Return the current game time.

`public getGameTime() : DateTime`

##### Return values

DateTime —

#### isNewDay()

TimeKeeper.php : 69

Returns whether a user who is interating with the game now and last interacted at $lastInteractionTime should experience a New Day event.

`public isNewDay(DateTime $lastInteractionTime) : bool`

##### Parameters

$lastInteractionTime : DateTime

##### Return values

bool —

#### interval()

TimeKeeper.php : 155

Convenience method to generate a DateInterval from an exploded date.

`private interval(int $years, int $days, int $hours, int $minutes, int $seconds) : DateInterval`

##### Parameters

$years : int
$days : int
$hours : int
$minutes : int
$seconds : int

##### Tags

throws
  Exception

##### Return values

DateInterval —

## Search results