You should explain in more detail what you're trying to accomplish.
I want to make use of 'global logic' in my controllers (and maybe even have access to it in JavaScript). The logic would be for a 'made up date system', that's used for a game. So all the month and day names are made up and they don't follow the 24 hour, 7 day, 12 months thing.
I have not made the logic yet, but I think I will have an epoch that's based on the Unix timestamp. I can than substract the current time from the epoch and use the remaining seconds to do my calculations.
For those calculations, I want a 'global' class.
I.e.
<?php
/* Mock up!!! */
class GameTime
{
public $months = array('Aburtei', 'Danai', 'Guura', 'Juunnu', 'Kuro', 'Serai', 'Vendrei');
public $days = array('etc');
private $epoch = 1398173634;
public static function getMonth()
{
/* Calculations etc */
return 'Guura';
}
public static function getDay() {}
public static function getYear() {}
public static function getFormattedDate($timestamp = time())
{
/* Calculations etc */
return 'Tuesday, 22 Guura, of the Year 1';
}
public static function getDateInFuture($timestamp)
{
/* Calculations etc */
return self::getFormattedDate($timestamp);
}
}
?>
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community