![]() |
get_day_names and get_month_name in calendar class - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: get_day_names and get_month_name in calendar class (/showthread.php?tid=9895) |
get_day_names and get_month_name in calendar class - El Forum - 07-11-2008 [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 get_day_names and get_month_name in calendar class - El Forum - 07-11-2008 [eluser]Peter van de Pas[/eluser] Or let the calendar_template hold arrays to be passed and check on that ! get_day_names and get_month_name in calendar class - El Forum - 07-12-2008 [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. get_day_names and get_month_name in calendar class - El Forum - 07-12-2008 [eluser]Peter van de Pas[/eluser] Ah... maybe you are right... thank you ? I wasn't aware.... can you explain how they work ? get_day_names and get_month_name in calendar class - El Forum - 07-12-2008 [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 ?! |