ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilCalendarUtil Class Reference

Class ilCalendarUtil. More...

+ Collaboration diagram for ilCalendarUtil:

Static Public Member Functions

static convertDateToUtcDBTimestamp (\ilDateTime $date=null)
 
static _isToday ($date)
 check if a date is today More...
 
static _numericMonthToString ($a_month, $a_long=true)
 numeric month to string More...
 
static _numericDayToString ($a_day, $a_long=true)
 get More...
 
static _buildWeekDayList ($a_day, $a_weekstart)
 build week day list More...
 
static _buildMonthDayList ($a_month, $a_year, $weekstart)
 Build a month day list. More...
 
static initJSCalendar ()
 Init Javascript Calendar. More...
 
static getZoneInfoFile ($a_tz)
 
static _getShortTimeZoneList ()
 get short timezone list More...
 
static _isLeapYear ($a_year)
 check if a given year is a leap year More...
 
static _getMaxDayOfMonth ($a_year, $a_month)
 get max day of month 2008,2 => 29 More...
 
static calculateFontColor ($a_html_color_code)
 Calculate best font color from html hex color code. More...
 
static getHourSelection ($a_format)
 Get hour selectio depending on user specific hour format. More...
 
static initDefaultCalendarByType ($a_type_id, $a_usr_id, $a_title, $a_create=false)
 Init the default calendar for given type and user. More...
 
static getUserDateFormat ($a_add_time=false, $a_for_parsing=false)
 Parse current user setting into date/time format. More...
 
static initDateTimePicker ()
 
static addDateTimePicker ($a_id, $a_add_time=null, array $a_custom_config=null, $a_id2=null, $a_custom_config2=null, $a_toggle_id=null, $a_subform_id=null)
 Add date time picker to element. More...
 
static parseDateString ($a_date, $a_add_time=null, $a_use_generic_format=false)
 Parse (incoming) string to date/time object. More...
 
static parseIncomingDate ($a_value, $a_add_time=null)
 Try to parse incoming value to date object. More...
 

Static Public Attributes

static $init_done
 

Static Protected Attributes

static $init_datetimepicker
 

Static Private Attributes

static $today = null
 
static $default_calendar = array()
 

Detailed Description

Class ilCalendarUtil.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 33 of file class.ilCalendarUtil.php.

Member Function Documentation

◆ _buildMonthDayList()

static ilCalendarUtil::_buildMonthDayList (   $a_month,
  $a_year,
  $weekstart 
)
static

Build a month day list.

@access public

Parameters
intmonth
intyear
intweekstart (0 => Sunday,1 => Monday)
Returns
ilDateList

Definition at line 154 of file class.ilCalendarUtil.php.

155 {
156 include_once('Services/Calendar/classes/class.ilDateList.php');
157 $day_list = new ilDateList(ilDateList::TYPE_DATE);
158
159 $prev_month = ($a_month == 1) ? 12 : $a_month - 1;
160 $prev_year = ($prev_month == 12) ? $a_year - 1 : $a_year;
161 $next_month = $a_month == 12 ? 1 : $a_month + 1;
162 $next_year = $a_month == 12 ? $a_year + 1 : $a_year;
163
164 $days_in_month = self::_getMaxDayOfMonth($a_year, $a_month);
165 $days_in_prev_month = self::_getMaxDayOfMonth($a_year, $prev_month);
166
167 $week_day['year'] = $a_year;
168 $week_day['mon'] = $a_month;
169 $week_day['mday'] = 1;
170 $week_day['hours'] = 0;
171 $week_day['minutes'] = 0;
172 $week_day = new ilDate($week_day, IL_CAL_FKT_GETDATE);
173
174 $weekday = $week_day->get(IL_CAL_FKT_DATE, 'w');
175 $first_day_offset = (($weekday - $weekstart) < 0) ? 6 : $weekday - $weekstart;
176
177
178 for ($i = 0;$i < 42;$i++) {
179 if ($i < $first_day_offset) {
180 $day = $days_in_prev_month - $first_day_offset + $i + 1;
181
182 $day_list->add(new ilDate(
183 gmmktime(
184 0,
185 0,
186 0,
187 $prev_month,
188 $days_in_prev_month - $first_day_offset + $i + 1,
189 $prev_year
190 ),
192 ));
193 } elseif ($i < $days_in_month + $first_day_offset) {
194 $day = $i - $first_day_offset + 1;
195
196
197 $day_list->add(new ilDate(
198 gmmktime(
199 0,
200 0,
201 0,
202 $a_month,
203 $i - $first_day_offset + 1,
204 $a_year
205 ),
207 ));
208 } else {
209 $day = $i - $days_in_month - $first_day_offset + 1;
210 $day_list->add(new ilDate(
211 gmmktime(
212 0,
213 0,
214 0,
215 $next_month,
216 $i - $days_in_month - $first_day_offset + 1,
217 $next_year
218 ),
220 ));
221 }
222 if ($i == 34 and ($day < 15 or $day == $days_in_month)) {
223 break;
224 }
225 }
226 return $day_list;
227 }
const IL_CAL_FKT_GETDATE
const IL_CAL_UNIX
const IL_CAL_FKT_DATE
static _getMaxDayOfMonth($a_year, $a_month)
get max day of month 2008,2 => 29
List of dates.
Class for single dates.
$i
Definition: metadata.php:24

References $i, _getMaxDayOfMonth(), IL_CAL_FKT_DATE, IL_CAL_FKT_GETDATE, IL_CAL_UNIX, and ilDateList\TYPE_DATE.

Referenced by ilMiniCalendarGUI\addMiniMonth(), and ilCalendarBlockGUI\addMiniMonth().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _buildWeekDayList()

static ilCalendarUtil::_buildWeekDayList (   $a_day,
  $a_weekstart 
)
static

build week day list

@access public

Parameters
ilDatea day in a week
intweekstart
Returns
ilDateList

Definition at line 124 of file class.ilCalendarUtil.php.

125 {
126 include_once('Services/Calendar/classes/class.ilDateList.php');
127 $day_list = new ilDateList(ilDateList::TYPE_DATE);
128
129 $start = clone $a_day;
130 $start_info = $start->get(IL_CAL_FKT_GETDATE, '', 'UTC');
131 $day_diff = $a_weekstart - $start_info['isoday'];
132 if ($day_diff == 7) {
133 $day_diff = 0;
134 }
135 $start->increment(IL_CAL_DAY, $day_diff);
136 $day_list->add($start);
137 for ($i = 1; $i < 7;$i++) {
138 $start->increment(IL_CAL_DAY, 1);
139 $day_list->add($start);
140 }
141 return $day_list;
142 }
const IL_CAL_DAY

References $i, IL_CAL_DAY, IL_CAL_FKT_GETDATE, and ilDateList\TYPE_DATE.

Referenced by ilCalendarViewGUI\getBucketTitle(), ilCalendarHeaderNavigationGUI\getHTML(), and ilCalendarWeekGUI\show().

+ Here is the caller graph for this function:

◆ _getMaxDayOfMonth()

static ilCalendarUtil::_getMaxDayOfMonth (   $a_year,
  $a_month 
)
static

get max day of month 2008,2 => 29

@access public

Parameters
intyear
intmonth
Returns

Definition at line 443 of file class.ilCalendarUtil.php.

444 {
445 if (@function_exists('cal_days_in_month')) {
446 return cal_days_in_month(CAL_GREGORIAN, $a_month, $a_year);
447 }
448 $months = array(0,31,
449 self::_isLeapYear($a_year) ? 29 : 28,
450 31,30,31,30,31,31,30,31,30,31);
451 return $months[(int) $a_month];
452 }

Referenced by _buildMonthDayList(), ilCalendarRecurrenceCalculator\applyBYMONTHDAYRules(), ilCalendarRecurrenceCalculator\getMonthWeekDays(), and ilCalendarSchedule\initPeriod().

+ Here is the caller graph for this function:

◆ _getShortTimeZoneList()

static ilCalendarUtil::_getShortTimeZoneList ( )
static

get short timezone list

@access public

Parameters

Definition at line 336 of file class.ilCalendarUtil.php.

337 {
338 return array(
339 'Pacific/Samoa' => 'GMT-11: Midway Islands, Samoa',
340 'US/Hawaii' => 'GMT-10:00: Hawaii, Polynesia',
341 'US/Alaska' => 'GMT-9:00: Alaska',
342 'America/Los_Angeles' => 'GMT-8:00: Tijuana, Los Angeles, Seattle, Vancouver',
343 'US/Arizona' => 'GMT-7:00: Arizona',
344 'America/Chihuahua' => 'GMT-7:00: Chihuahua, La Paz, Mazatlan',
345 'America/Denver' => 'GMT-7:00: Arizona, Denver, Salt Lake City, Calgary',
346 'America/Chicago' => 'GMT-6:00: Chicago, Dallas, Kansas City, Winnipeg',
347 'America/Monterrey' => 'GMT-6:00: Guadalajara, Mexico City, Monterrey',
348 'Canada/Saskatchewan' => 'GMT-6:00: Saskatchewan',
349 'US/Central' => 'GMT-6:00: Central America',
350 'America/Bogota' => 'GMT-5:00: Bogota, Lima, Quito',
351 'US/East-Indiana' => 'GMT-5:00: East-Indiana',
352 'America/New_York' => 'GMT-5:00: New York, Miami, Atlanta, Detroit, Toronto',
353 'Canada/Atlantic' => 'GMT-4:00: Atlantic (Canada)',
354 'America/La_Paz' => 'GMT-4:00: Carcas, La Paz',
355 'America/Santiago' => 'GMT-4:00: Santiago',
356 'Canada/Newfoundland' => 'GMT-3:00: Newfoundland',
357 'Brazil/East' => 'GMT-3:00: Sao Paulo',
358 'America/Argentina/Buenos_Aires' => 'GMT-3:00: Buenes Aires, Georgtown',
359 'Etc/GMT+3' => 'GMT-3:00: Greenland, Uruguay, Surinam',
360 'Atlantic/Cape_Verde' => 'GMT-2:00: Cape Verde, Greenland, South Georgia',
361 'Atlantic/Azores' => 'GMT-1:00: Azores',
362 'Africa/Casablanca' => 'GMT+0:00: Casablanca, Monrovia',
363 'Europe/London' => 'GMT+0:00: Dublin, Edinburgh, Lisbon, London',
364 'Europe/Berlin' => 'GMT+1:00: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna',
365 'Europe/Belgrade' => 'GMT+1:00: Belgrade, Bratislava, Budapest, Ljubljana, Prague',
366 'Europe/Paris' => 'GMT+1:00: Brussels, Copenhagen, Paris, Madrid',
367 'Europe/Sarajevo' => 'GMT+1:00: Sarajevo, Skopje, Warsaw, Zagreb',
368 'Africa/Lagos' => 'GMT+1:00: West-Central Africa',
369 'Europe/Athens' => 'GMT+2:00: Athens, Beirut, Istanbul, Minsk',
370 'Europe/Bucharest' => 'GMT+2:00: Bucharest',
371 'Africa/Harare' => 'GMT+2:00: Harare, Pratoria',
372 'Europe/Helsinki' => 'GMT+2:00: Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius',
373 'Asia/Jerusalem' => 'GMT+2:00: Jerusalem',
374 'Africa/Cairo' => 'GMT+2:00: Cairo',
375 'Asia/Baghdad' => 'GMT+3:00: Baghdad',
376 'Asia/Kuwait' => 'GMT+3:00: Kuwait, Riyadh',
377 'Europe/Moscow' => 'GMT+3:00: Moscow, Saint Petersburg',
378 'Africa/Nairobi' => 'GMT+3:00: Nairobi',
379 'Asia/Tehran' => 'GMT+3:30: Tehran',
380 'Asia/Muscat' => 'GMT+4:00: Abu Dhabi, Muscat',
381 'Asia/Baku' => 'GMT+4:00: Baku, Tbilisi, Erivan',
382 'Asia/Kabul' => 'GMT+4:00: Kabul',
383 'Asia/Karachi' => 'GMT+5:00: Islamabad, Karachi, Taschkent',
384 'Asia/Yekaterinburg' => 'GMT+5:00: Yekaterinburg',
385 'Asia/Calcutta' => 'GMT+5:30: New Dehli',
386 'Asia/Katmandu' => 'GMT+5:45: Katmandu',
387 'Asia/Novosibirsk' => 'GMT+6:00: Almaty, Novosibirsk',
388 'Asia/Dhaka' => 'GMT+6:00: Astana, Dhaka',
389 'Asia/Rangoon' => 'GMT+6:00: Sri Jayawardenepura, Rangoon',
390 'Asia/Jakarta' => 'GMT+7:00: Bangkok, Hanoi, Jakarta',
391 'Asia/Krasnoyarsk' => 'GMT+7:00: Krasnoyarsk',
392 'Asia/Irkutsk' => 'GMT+8:00: Irkutsk, Ulan Bator',
393 'Asia/Singapore' => 'GMT+8:00: Kuala Lumpour, Singapore',
394 'Asia/Hong_Kong' => 'GMT+8:00: Beijing, Chongqing, Hong kong, Urumchi',
395 'Australia/Perth' => 'GMT+8:00: Perth',
396 'Asia/Taipei' => 'GMT+8:00: Taipei',
397 'Asia/Yakutsk' => 'GMT+9:00: Yakutsk',
398 'Asia/Tokyo' => 'GMT+9:00: Osaka, Sapporo, Tokyo',
399 'Asia/Seoul' => 'GMT+9:00: Seoul, Darwin, Adelaide',
400 'Australia/Brisbane' => 'GMT+10:00: Brisbane',
401 'Australia/Sydney' => 'GMT+10:00: Canberra, Melbourne, Sydney',
402 'Pacific/Guam' => 'GMT+10:00: Guam, Port Moresby',
403 'Australia/Hobart' => 'GMT+10:00: Hobart',
404 'Asia/Vladivostok' => 'GMT+10:00: Vladivostok',
405 'Asia/Magadan' => 'GMT+11:00: Salomon Islands, New Caledonia, Magadan',
406 'Pacific/Auckland' => 'GMT+12:00: Auckland, Wellington',
407 'Pacific/Fiji' => 'GMT+12:00: Fiji, Kamchatka, Marshall-Islands');
408 }

Referenced by ilSetupGUI\initBasicSettingsForm(), ilObjCalendarSettingsGUI\initFormSettings(), ilPersonalSettingsGUI\initGeneralSettingsForm(), and ilCalendarUserSettingsGUI\initSettingsForm().

+ Here is the caller graph for this function:

◆ _isLeapYear()

static ilCalendarUtil::_isLeapYear (   $a_year)
static

check if a given year is a leap year

@access public

Parameters
intyear
Returns
bool

Definition at line 418 of file class.ilCalendarUtil.php.

419 {
420 $is_leap = false;
421
422 if ($a_year % 4 == 0) {
423 $is_leap = true;
424 if ($a_year % 100 == 0) {
425 $is_leap = false;
426 if ($a_year % 400) {
427 return true;
428 }
429 }
430 }
431 return $is_leap;
432 }

Referenced by ilCalendarRecurrenceCalculator\getYearWeekDays().

+ Here is the caller graph for this function:

◆ _isToday()

static ilCalendarUtil::_isToday (   $date)
static

check if a date is today

Parameters
ilDateTime$datedate to check
Returns
bool

Definition at line 61 of file class.ilCalendarUtil.php.

62 {
63 global $DIC;
64
65 $ilUser = $DIC['ilUser'];
66
67
68 if (!is_object(self::$today)) {
69 self::$today = new ilDateTime(time(), IL_CAL_UNIX, $ilUser->getTimeZone());
70 }
71 return ilDateTime::_equals(self::$today, $date, IL_CAL_DAY, $ilUser->getTimeZone());
72 }
@classDescription Date and time handling
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46

References $DIC, $ilUser, ilDateTime\_equals(), IL_CAL_DAY, and IL_CAL_UNIX.

Referenced by ilMiniCalendarGUI\addMiniMonth(), and ilCalendarBlockGUI\addMiniMonth().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _numericDayToString()

static ilCalendarUtil::_numericDayToString (   $a_day,
  $a_long = true 
)
static

get

@access public

Parameters
intday of week (0 for sunday, 1 for monday)
boolshort or long day translation

Definition at line 103 of file class.ilCalendarUtil.php.

104 {
105 global $DIC;
106
107 $lng = $DIC['lng'];
108
109 $lng->loadLanguageModule('dateplaner');
110 static $days = array('Su','Mo','Tu','We','Th','Fr','Sa','Su');
111
112 return $a_long ? $lng->txt($days[$a_day] . '_long') : $lng->txt($days[$a_day] . '_short');
113 }
$lng

References $DIC, and $lng.

Referenced by ilCalendarWeekGUI\addHeaderDate(), ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), ilRecurrenceInputGUI\buildMonthlyByDaySelection(), ilRecurrenceInputGUI\buildWeekDaySelection(), ilRecurrenceInputGUI\buildYearlyByDaySelection(), ilSessionStatisticsGUI\exportCSV(), ilBookingReservationsTableGUI\fillRow(), ilBookingReservationsTableGUI\fillRowCSV(), ilBookingReservationsTableGUI\fillRowExcel(), ilSessionStatisticsGUI\getChart(), ilCalendarHeaderNavigationGUI\getHTML(), and ilBookingReservationsTableGUI\initFilter().

+ Here is the caller graph for this function:

◆ _numericMonthToString()

static ilCalendarUtil::_numericMonthToString (   $a_month,
  $a_long = true 
)
static

numeric month to string

@access public

Parameters
intmonth (1-12)
boolshort or long month translation

Definition at line 83 of file class.ilCalendarUtil.php.

84 {
85 global $DIC;
86
87 $lng = $DIC['lng'];
88
89 $month = $a_month < 10 ? '0' . $a_month : $a_month;
90
91 return $a_long ? $lng->txt('month_' . $month . '_long') : $lng->txt('month_' . $month . '_short');
92 }

References $DIC, and $lng.

Referenced by ilRecurrenceInputGUI\buildYearlyByDaySelection(), ilRecurrenceInputGUI\buildYearlyByMonthDaySelection(), ilDatePresentation\formatDate(), ilObjBlogGUI\renderList(), ilObjBlogGUI\renderNavigationByDate(), and ilWikiStatGUI\viewToolbar().

+ Here is the caller graph for this function:

◆ addDateTimePicker()

static ilCalendarUtil::addDateTimePicker (   $a_id,
  $a_add_time = null,
array  $a_custom_config = null,
  $a_id2 = null,
  $a_custom_config2 = null,
  $a_toggle_id = null,
  $a_subform_id = null 
)
static

Add date time picker to element.

Parameters
string$a_id
int$a_add_time1=hh:mm, 2=hh:mm:ss
array$a_custom_config
string$a_id2
array$a_custom_config2
string$a_toggle_id
string$a_subform_id
Returns
string

Definition at line 632 of file class.ilCalendarUtil.php.

633 {
634 global $DIC;
635
636 $tpl = $DIC['tpl'];
637 $ilUser = $DIC['ilUser'];
638
640
641 // weekStart is currently governed by locale and cannot be changed
642
643 // fix for mantis 22994 => default to english language
644 $language = 'en';
645 if ($ilUser->getLanguage() != 'ar') {
646 $language = $ilUser->getLanguage();
647 }
648 $default = array(
649 'locale' => $language
650 ,'stepping' => 5
651 ,'useCurrent' => false
652 ,'calendarWeeks' => true
653 ,'toolbarPlacement' => 'top'
654 // ,'showTodayButton' => true
655 ,'showClear' => true
656 // ,'showClose' => true
657 ,'keepInvalid' => true
658 ,'sideBySide' => true
659 // ,'collapse' => false
660 ,'format' => self::getUserDateFormat($a_add_time)
661 );
662
663 $config = (!$a_custom_config)
664 ? $default
665 : array_merge($default, $a_custom_config);
666
667 $tpl->addOnLoadCode('$("#' . $a_id . '").datetimepicker(' . json_encode($config) . ')');
668
669
670 // optional 2nd picker aka duration
671 if ($a_id2) {
672 $config2 = (!$a_custom_config2)
673 ? $default
674 : array_merge($default, $a_custom_config2);
675
676 $config2["useCurrent"] = false; //Important! See issue #1075
677
678 $tpl->addOnLoadCode('$("#' . $a_id2 . '").datetimepicker(' . json_encode($config2) . ')');
679
680 // duration limits, diff and subform handling
681 $tpl->addOnLoadCode('il.Form.initDateDurationPicker("' . $a_id . '","' . $a_id2 . '","' . $a_toggle_id . '","' . $a_subform_id . '");');
682 } elseif ($a_subform_id) {
683 // subform handling
684 $tpl->addOnLoadCode('il.Form.initDatePicker("' . $a_id . '","' . $a_subform_id . '");');
685 }
686 }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl

References $config, $DIC, $ilUser, $tpl, and initDateTimePicker().

Referenced by ilDateDurationInputGUI\render(), and ilDateTimeInputGUI\render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateFontColor()

static ilCalendarUtil::calculateFontColor (   $a_html_color_code)
static

Calculate best font color from html hex color code.

@access public

Parameters
stringhex value of color
Returns
string #ffffff or #000000

Definition at line 462 of file class.ilCalendarUtil.php.

463 {
464 if (strpos($a_html_color_code, '#') !== 0 or strlen($a_html_color_code) != 7) {
465 return '#000000';
466 }
467
468 // http://en.wikipedia.org/wiki/Luminance_(relative)
469 $lum = round(hexdec(substr($a_html_color_code, 1, 2)) * 0.2126 +
470 hexdec(substr($a_html_color_code, 3, 2)) * 0.7152 +
471 hexdec(substr($a_html_color_code, 5, 2)) * 0.0722);
472
473 return ($lum <= 128) ? "#FFFFFF" : "#000000";
474
475 /*
476 $hex = str_replace('#','0x',$a_html_color_code);
477 return hexdec($hex) > 8000000 ? '#000000' : '#FFFFFF';
478 */
479 }

Referenced by ilCalendarDayGUI\showAppointment(), ilCalendarWeekGUI\showAppointment(), ilCalendarMonthGUI\showEvents(), ilCalendarDayGUI\showFulldayAppointment(), and ilCalendarWeekGUI\showFulldayAppointment().

+ Here is the caller graph for this function:

◆ convertDateToUtcDBTimestamp()

static ilCalendarUtil::convertDateToUtcDBTimestamp ( \ilDateTime  $date = null)
static
Parameters
\ilDateTime | null$date

Definition at line 44 of file class.ilCalendarUtil.php.

45 {
46 if (is_null($date)) {
47 return $date;
48 }
49 if ($date instanceof \ilDate) {
50 return $date->get(IL_CAL_DATE);
51 }
52 return $date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC);
53 }
const IL_CAL_DATE
const IL_CAL_DATETIME

References IL_CAL_DATE, IL_CAL_DATETIME, and ilTimeZone\UTC.

Referenced by ilObjGroup\update(), and ilObjCourse\updateSettings().

+ Here is the caller graph for this function:

◆ getHourSelection()

static ilCalendarUtil::getHourSelection (   $a_format)
static

Get hour selectio depending on user specific hour format.

Returns
Parameters
int$a_format

Definition at line 486 of file class.ilCalendarUtil.php.

487 {
488 switch ($a_format) {
490 for ($i = 0; $i < 24; $i++) {
491 $options[$i] = sprintf('%02d:00', $i);
492 }
493 break;
494
496 for ($i = 0; $i < 24; $i++) {
497 $options[$i] = date('h a', mktime($i, 0, 0, 1, 1, 2000));
498 }
499 break;
500 }
501 return $options ? $options : array();
502 }

References $i, ilCalendarSettings\TIME_FORMAT_12, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by ilObjCalendarSettingsGUI\initFormSettings(), and ilCalendarUserSettingsGUI\initSettingsForm().

+ Here is the caller graph for this function:

◆ getUserDateFormat()

static ilCalendarUtil::getUserDateFormat (   $a_add_time = false,
  $a_for_parsing = false 
)
static

Parse current user setting into date/time format.

Parameters
int$a_add_time1=hh:mm, 2=hh:mm:ss
bool$a_for_parsing
Returns
string

Definition at line 559 of file class.ilCalendarUtil.php.

560 {
561 global $DIC;
562
563 $ilUser = $DIC['ilUser'];
564
565 // getDateFormat() should return calendar defaults for ANONYMOUS user
566 switch ($ilUser->getDateFormat()) {
568 $format = "DD.MM.YYYY";
569 break;
570
572 $format = "YYYY-MM-DD";
573 break;
574
576 $format = "MM/DD/YYYY";
577 break;
578 }
579 if ($a_add_time) {
580 $format .= " " . (($ilUser->getTimeFormat() == ilCalendarSettings::TIME_FORMAT_24)
581 ? "HH:mm"
582 : "hh:mma");
583 if ($a_add_time == 2) {
584 $format .= ":ss";
585 }
586 }
587
588 // translate datepicker format to PHP format
589 if ((bool) $a_for_parsing) {
590 $format = str_replace("DD", "d", $format);
591 $format = str_replace("MM", "m", $format);
592 $format = str_replace("mm", "i", $format);
593 $format = str_replace("YYYY", "Y", $format);
594 $format = str_replace("HH", "H", $format);
595 $format = str_replace("hh", "h", $format);
596 }
597
598 return $format;
599 }
$format
Definition: metadata.php:218

References $DIC, $format, $ilUser, ilCalendarSettings\DATE_FORMAT_DMY, ilCalendarSettings\DATE_FORMAT_MDY, ilCalendarSettings\DATE_FORMAT_YMD, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by parseDateString(), ilDateDurationInputGUI\render(), and ilDateTimeInputGUI\render().

+ Here is the caller graph for this function:

◆ getZoneInfoFile()

static ilCalendarUtil::getZoneInfoFile (   $a_tz)
static

Definition at line 317 of file class.ilCalendarUtil.php.

318 {
319 if (!array_key_exists($a_tz, self::_getShortTimeZoneList())) {
320 return '';
321 }
322 $timezone_filename = str_replace('/', '_', $a_tz);
323 $timezone_filename .= '.ics';
324 return './Services/Calendar/zoneinfo/' . $timezone_filename;
325 }

Referenced by ilCalendarExport\addTimezone().

+ Here is the caller graph for this function:

◆ initDateTimePicker()

static ilCalendarUtil::initDateTimePicker ( )
static

Definition at line 601 of file class.ilCalendarUtil.php.

602 {
603 global $DIC;
604
605 $tpl = $DIC['tpl'];
606
607 if (!self::$init_datetimepicker) {
608 $tpl->addJavaScript("./libs/bower/bower_components/moment/min/moment-with-locales.min.js");
609
610 // unminified version does not work with jQuery 3.0
611 // https://github.com/Eonasdan/bootstrap-datetimepicker/issues/1684
612 $tpl->addJavaScript("./libs/bower/bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js");
613
614 $tpl->addJavaScript("Services/Form/js/Form.js"); // see ilPropertyFormGUI
615
616 self::$init_datetimepicker = true;
617 }
618 }

References $DIC, and $tpl.

Referenced by addDateTimePicker(), ilExerciseManagementGUI\initIndividualDeadlineModal(), and ILIAS\UI\Implementation\Component\Input\Field\Renderer\renderDateTimeInput().

+ Here is the caller graph for this function:

◆ initDefaultCalendarByType()

static ilCalendarUtil::initDefaultCalendarByType (   $a_type_id,
  $a_usr_id,
  $a_title,
  $a_create = false 
)
static

Init the default calendar for given type and user.

Parameters
int$a_type_id
int$a_usr_id
string$a_title
bool$create
Returns

Definition at line 512 of file class.ilCalendarUtil.php.

513 {
514 global $DIC;
515
516 $ilDB = $DIC['ilDB'];
517
518 if (isset(self::$default_calendar[$a_usr_id]) and isset(self::$default_calendar[$a_usr_id][$a_type_id])) {
519 return self::$default_calendar[$a_usr_id][$a_type_id];
520 }
521
522 include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
523
524 $query = "SELECT cat_id FROM cal_categories " .
525 "WHERE obj_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
526 "AND type = " . $ilDB->quote($a_type_id, 'integer');
527 $res = $ilDB->query($query);
528 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
529 return self::$default_calendar[$a_usr_id][$a_type_id] = new ilCalendarCategory($row->cat_id);
530 }
531
532 if (!$a_create) {
533 return null;
534 }
535
536 // Create default calendar
537 self::$default_calendar[$a_usr_id][$a_type_id] = new ilCalendarCategory();
538 self::$default_calendar[$a_usr_id][$a_type_id]->setType($a_type_id);
539 self::$default_calendar[$a_usr_id][$a_type_id]->setColor(ilCalendarCategory::DEFAULT_COLOR);
540 self::$default_calendar[$a_usr_id][$a_type_id]->setTitle($a_title);
541 self::$default_calendar[$a_usr_id][$a_type_id]->setObjId($a_usr_id);
542 self::$default_calendar[$a_usr_id][$a_type_id]->add();
543
544 return self::$default_calendar[$a_usr_id][$a_type_id];
545 }
Stores calendar categories.
$query
foreach($_POST as $key=> $value) $res
global $ilDB

References $DIC, $ilDB, $query, $res, ilCalendarCategory\DEFAULT_COLOR, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilConsultationHourUtils\bookAppointment(), ilConsultationHoursGUI\createAppointments(), and ilBookingProcessGUI\processBooking().

+ Here is the caller graph for this function:

◆ initJSCalendar()

static ilCalendarUtil::initJSCalendar ( )
static

Init Javascript Calendar.

Definition at line 232 of file class.ilCalendarUtil.php.

233 {
234 global $DIC;
235
236 $tpl = $DIC['tpl'];
237 $lng = $DIC['lng'];
238
239 if (self::$init_done == "done") {
240 return;
241 }
242
243 $lng->loadLanguageModule("jscalendar");
244 $tpl->addBlockFile(
245 "CALENDAR_LANG_JAVASCRIPT",
246 "calendar_javascript",
247 "tpl.calendar.html",
248 "Services/Calendar"
249 );
250 $tpl->setCurrentBlock("calendar_javascript");
251 $tpl->setVariable("FULL_SUNDAY", $lng->txt("l_su"));
252 $tpl->setVariable("FULL_MONDAY", $lng->txt("l_mo"));
253 $tpl->setVariable("FULL_TUESDAY", $lng->txt("l_tu"));
254 $tpl->setVariable("FULL_WEDNESDAY", $lng->txt("l_we"));
255 $tpl->setVariable("FULL_THURSDAY", $lng->txt("l_th"));
256 $tpl->setVariable("FULL_FRIDAY", $lng->txt("l_fr"));
257 $tpl->setVariable("FULL_SATURDAY", $lng->txt("l_sa"));
258 $tpl->setVariable("SHORT_SUNDAY", $lng->txt("s_su"));
259 $tpl->setVariable("SHORT_MONDAY", $lng->txt("s_mo"));
260 $tpl->setVariable("SHORT_TUESDAY", $lng->txt("s_tu"));
261 $tpl->setVariable("SHORT_WEDNESDAY", $lng->txt("s_we"));
262 $tpl->setVariable("SHORT_THURSDAY", $lng->txt("s_th"));
263 $tpl->setVariable("SHORT_FRIDAY", $lng->txt("s_fr"));
264 $tpl->setVariable("SHORT_SATURDAY", $lng->txt("s_sa"));
265 $tpl->setVariable("FULL_JANUARY", $lng->txt("l_01"));
266 $tpl->setVariable("FULL_FEBRUARY", $lng->txt("l_02"));
267 $tpl->setVariable("FULL_MARCH", $lng->txt("l_03"));
268 $tpl->setVariable("FULL_APRIL", $lng->txt("l_04"));
269 $tpl->setVariable("FULL_MAY", $lng->txt("l_05"));
270 $tpl->setVariable("FULL_JUNE", $lng->txt("l_06"));
271 $tpl->setVariable("FULL_JULY", $lng->txt("l_07"));
272 $tpl->setVariable("FULL_AUGUST", $lng->txt("l_08"));
273 $tpl->setVariable("FULL_SEPTEMBER", $lng->txt("l_09"));
274 $tpl->setVariable("FULL_OCTOBER", $lng->txt("l_10"));
275 $tpl->setVariable("FULL_NOVEMBER", $lng->txt("l_11"));
276 $tpl->setVariable("FULL_DECEMBER", $lng->txt("l_12"));
277 $tpl->setVariable("SHORT_JANUARY", $lng->txt("s_01"));
278 $tpl->setVariable("SHORT_FEBRUARY", $lng->txt("s_02"));
279 $tpl->setVariable("SHORT_MARCH", $lng->txt("s_03"));
280 $tpl->setVariable("SHORT_APRIL", $lng->txt("s_04"));
281 $tpl->setVariable("SHORT_MAY", $lng->txt("s_05"));
282 $tpl->setVariable("SHORT_JUNE", $lng->txt("s_06"));
283 $tpl->setVariable("SHORT_JULY", $lng->txt("s_07"));
284 $tpl->setVariable("SHORT_AUGUST", $lng->txt("s_08"));
285 $tpl->setVariable("SHORT_SEPTEMBER", $lng->txt("s_09"));
286 $tpl->setVariable("SHORT_OCTOBER", $lng->txt("s_10"));
287 $tpl->setVariable("SHORT_NOVEMBER", $lng->txt("s_11"));
288 $tpl->setVariable("SHORT_DECEMBER", $lng->txt("s_12"));
289 $tpl->setVariable("ABOUT_CALENDAR", $lng->txt("about_calendar"));
290 $tpl->setVariable("ABOUT_CALENDAR_LONG", $lng->txt("about_calendar_long"));
291 $tpl->setVariable("ABOUT_TIME_LONG", $lng->txt("about_time"));
292 $tpl->setVariable("PREV_YEAR", $lng->txt("prev_year"));
293 $tpl->setVariable("PREV_MONTH", $lng->txt("prev_month"));
294 $tpl->setVariable("GO_TODAY", $lng->txt("go_today"));
295 $tpl->setVariable("NEXT_MONTH", $lng->txt("next_month"));
296 $tpl->setVariable("NEXT_YEAR", $lng->txt("next_year"));
297 $tpl->setVariable("SEL_DATE", $lng->txt("select_date"));
298 $tpl->setVariable("DRAG_TO_MOVE", $lng->txt("drag_to_move"));
299 $tpl->setVariable("PART_TODAY", $lng->txt("part_today"));
300 $tpl->setVariable("DAY_FIRST", $lng->txt("day_first"));
301 $tpl->setVariable("CLOSE", $lng->txt("close"));
302 $tpl->setVariable("TODAY", $lng->txt("today"));
303 $tpl->setVariable("TIME_PART", $lng->txt("time_part"));
304 $tpl->setVariable("DEF_DATE_FORMAT", $lng->txt("def_date_format"));
305 $tpl->setVariable("TT_DATE_FORMAT", $lng->txt("tt_date_format"));
306 $tpl->setVariable("WK", $lng->txt("wk"));
307 $tpl->setVariable("TIME", $lng->txt("time"));
308 $tpl->parseCurrentBlock();
309 $tpl->setCurrentBlock("CalendarJS");
310 $tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", "./Services/Calendar/js/calendar.js");
311 $tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", "./Services/Calendar/js/calendar-setup.js");
312 $tpl->parseCurrentBlock();
313
314 self::$init_done = "done";
315 }

References $DIC, $lng, and $tpl.

◆ parseDateString()

static ilCalendarUtil::parseDateString (   $a_date,
  $a_add_time = null,
  $a_use_generic_format = false 
)
static

Parse (incoming) string to date/time object.

Parameters
string$a_date
int$a_add_time1=hh:mm, 2=hh:mm:ss
Returns
array date, warnings, errors

Definition at line 694 of file class.ilCalendarUtil.php.

695 {
696 global $DIC;
697
698 $ilUser = $DIC['ilUser'];
699
700 if (!$a_use_generic_format) {
701 $out_format = self::getUserDateFormat($a_add_time, true);
702 } else {
703 $out_format = $a_add_time
704 ? "Y-m-d H:i:s"
705 : "Y-m-d";
706 }
707 $tmp = date_parse_from_format($out_format, $a_date);
708 $date = null;
709
710 if (!$tmp["error_count"] &&
711 !$tmp["warning_count"]) {
712 $format = $tmp["year"] . "-" .
713 str_pad($tmp["month"], 2, "0", STR_PAD_LEFT) . "-" .
714 str_pad($tmp["day"], 2, "0", STR_PAD_LEFT);
715
716 if ($a_add_time) {
717 $format .= " " .
718 str_pad($tmp["hour"], 2, "0", STR_PAD_LEFT) . ":" .
719 str_pad($tmp["minute"], 2, "0", STR_PAD_LEFT) . ":" .
720 str_pad($tmp["second"], 2, "0", STR_PAD_LEFT);
721
722 $date = new ilDateTime($format, IL_CAL_DATETIME, $ilUser->getTimeZone());
723 } else {
724 $date = new ilDate($format, IL_CAL_DATE);
725 }
726 }
727
728 return array(
729 "date" => $date
730 , "warnings" => sizeof($tmp["warnings"])
731 ? $tmp["warnings"]
732 : null
733 , "errors" => sizeof($tmp["errors"])
734 ? $tmp["errors"]
735 : null
736 );
737 }
static getUserDateFormat($a_add_time=false, $a_for_parsing=false)
Parse current user setting into date/time format.

References $DIC, $format, $ilUser, getUserDateFormat(), IL_CAL_DATE, and IL_CAL_DATETIME.

Referenced by parseIncomingDate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseIncomingDate()

static ilCalendarUtil::parseIncomingDate (   $a_value,
  $a_add_time = null 
)
static

Try to parse incoming value to date object.

Parameters
mixed$a_value
int$a_add_time
Returns
ilDateTime|ilDate

Definition at line 746 of file class.ilCalendarUtil.php.

747 {
748 // already datetime object?
749 if (is_object($a_value) &&
750 $a_value instanceof ilDateTime) {
751 return $a_value;
752 } elseif (trim($a_value)) {
753 // try user-specific format
754 $parsed = self::parseDateString($a_value, $a_add_time);
755 if (is_object($parsed["date"])) {
756 return $parsed["date"];
757 } else {
758 // try generic format
759 $parsed = self::parseDateString($a_value, $a_add_time, true);
760 if (is_object($parsed["date"])) {
761 return $parsed["date"];
762 }
763 }
764 }
765 }
static parseDateString($a_date, $a_add_time=null, $a_use_generic_format=false)
Parse (incoming) string to date/time object.

References parseDateString().

Referenced by ilDateDurationInputGUI\checkInput(), ilDateTimeInputGUI\checkInput(), ilBookingProcessGUI\confirmedBookingNumbers(), ilSessionStatisticsGUI\importDate(), ilADTDateSearchBridgeRange\importFromPost(), ilADTDateSearchBridgeSingle\importFromPost(), ilADTDateTimeSearchBridgeRange\importFromPost(), ilADTDateTimeSearchBridgeSingle\importFromPost(), ilDateDurationInputGUI\setValueByArray(), ilDateTimeInputGUI\setValueByArray(), ilCourseContentGUI\updateManagedTimings(), and ilCourseContentGUI\updatePersonalTimings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $default_calendar

ilCalendarUtil::$default_calendar = array()
staticprivate

Definition at line 36 of file class.ilCalendarUtil.php.

◆ $init_datetimepicker

ilCalendarUtil::$init_datetimepicker
staticprotected

Definition at line 38 of file class.ilCalendarUtil.php.

◆ $init_done

ilCalendarUtil::$init_done
static

Definition at line 37 of file class.ilCalendarUtil.php.

◆ $today

ilCalendarUtil::$today = null
staticprivate

Definition at line 35 of file class.ilCalendarUtil.php.


The documentation for this class was generated from the following file: