histogram: Make histograms crash less
[ninja.git] / application / helpers / cal.php
blob1c8d43027e7201cb0d95e9125e8284ca26022ad7
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3 * Date help class
4 */
5 class cal_Core
7 /**
8 * decide what date format to use for calendar
10 * NOTE!!! nagstat::date_format has the same thing, with time
12 public static function get_calendar_format($get_php=false)
14 $date_format = false;
15 $nagios_config = System_Model::parse_config_file('nagios.cfg');
16 $nagios_format_name = $nagios_config['date_format'];
17 switch (strtolower($nagios_format_name)) {
18 case 'us': # MM-DD-YYYY
19 $date_format = 'mm/dd/yyyy';
20 break;
21 case 'euro': # DD-MM-YYYY
22 $date_format = 'dd/mm/yyyy';
23 break;
24 case 'iso8601': # YYYY-MM-DD
25 $date_format = 'yyyy-mm-dd';
26 break;
27 case 'strict-iso8601': # YYYY-MM-DD
28 $date_format = 'yyyy-mm-dd';
29 break;
32 # convert to PHP equivalent
33 if ($get_php === true) {
34 $date_format = str_replace('yyyy', 'Y', $date_format);
35 $date_format = str_replace('mm', 'm', $date_format);
36 $date_format = str_replace('dd', 'd', $date_format);
38 return $date_format;