Welcome Guest, Not a member yet? Register   Sign In
get_day_names and get_month_name in calendar class
#1

[eluser]Peter van de Pas[/eluser]
I would propose a switch statement instead of the if/elseif !!

Like this:

switch ($this->day_type) {

case 'long':
$day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
break;

case 'short':
$day_names = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
break;

case 'first_character':
$day_names = array('S', 'M', 'T', 'W', 'T', 'F', 'S');
break;

case 'dutch_short':
$day_names = array('Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za');
break;

default:
$day_names = array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa');
break;
}

and simular in the getmonth_name method
#2

[eluser]Peter van de Pas[/eluser]
Or let the calendar_template hold arrays to be passed and check on that !
#3

[eluser]xwero[/eluser]
What i don't get is why don't the use the calendar language file??

As for your request i don't see the benefit in using switch over if/else. If the purpose of the switch is to make it possible to add your own abbreviations i think other solutions are better.
#4

[eluser]Peter van de Pas[/eluser]
Ah... maybe you are right... thank you ?
I wasn't aware.... can you explain how they work ?
#5

[eluser]Peter van de Pas[/eluser]
but what about switch versus if/else discussions and speed difference...
even though it will be minor, it makes the code more readable too ?!




Theme © iAndrew 2016 - Forum software by © MyBB