function holidayspotter_date_nav_title($params) { $granularity = $params['granularity']; $view = $params['view']; $date_info = $view->date_info; $link = !empty($params['link']) ? $params['link'] : FALSE; $format = !empty($params['format']) ? $params['format'] : NULL; switch ($granularity) { case 'year': $title = $date_info->year; $date_arg = $date_info->year; break; case 'month': $format = !empty($format) ? $format : (empty($date_info->mini) ? 'F Y' : 'F Y'); $title = date_format_date($date_info->min_date, 'custom', $format); $date_arg = $date_info->year . '-' . date_pad($date_info->month); break; case 'day': $format = !empty($format) ? $format : (empty($date_info->mini) ? 'l, F j Y' : 'l, F j'); $title = date_format_date($date_info->min_date, 'custom', $format); $date_arg = $date_info->year . '-' . date_pad($date_info->month) . '-' . date_pad($date_info->day); break; case 'week': $format = !empty($format) ? $format : (empty($date_info->mini) ? 'F j Y' : 'F j'); $title = t('Week of @date', array('@date' => date_format_date($date_info->min_date, 'custom', $format))); $date_arg = $date_info->year . '-W' . date_pad($date_info->week); break; } if (!empty($date_info->mini) || $link) { // Month navigation titles are used as links in the mini view. $attributes = array('title' => t('View full page month')); $url = date_pager_url($view, $granularity, $date_arg, TRUE); return l($title, $url, array('attributes' => $attributes)); } else { return $title; } }
/** * Theme the calendar title * * Copied and modified from date_views module theme.inc */ function az_gov_date_nav_title($params) { $granularity = $params['granularity']; $view = $params['view']; $date_info = $view->date_info; $link = !empty($params['link']) ? $params['link'] : FALSE; $format = !empty($params['format']) ? $params['format'] : NULL; $format_with_year = variable_get('date_views_' . $granularity . 'format_with_year', 'l, F j, Y'); $format_without_year = variable_get('date_views_' . $granularity . 'format_without_year', 'l, F j'); switch ($granularity) { case 'year': $title = $date_info->year; $date_arg = $date_info->year; break; case 'month': //customized format for month display //$format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year); $format = 'F Y'; $title = date_format_date($date_info->min_date, 'custom', $format); $date_arg = $date_info->year . '-' . date_pad($date_info->month); break; case 'day': $format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year); $title = date_format_date($date_info->min_date, 'custom', $format); $date_arg = $date_info->year . '-' . date_pad($date_info->month) . '-' . date_pad($date_info->day); break; case 'week': $format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year); $title = t('Week of @date', array('@date' => date_format_date($date_info->min_date, 'custom', $format))); $date_arg = $date_info->year . '-W' . date_pad($date_info->week); break; } if (!empty($date_info->mini) || $link) { // Month navigation titles are used as links in the mini view. $attributes = array('title' => t('View full page month')); $url = date_pager_url($view, $granularity, $date_arg, TRUE); return l($title, $url, array('attributes' => $attributes)); } else { return $title; } }
* @file views-view-summary.tpl.php * Default simple view template to display a list of summary lines * * @ingroup views_templates */ ?> <div class="item-list"> <ul class="views-summary"> <?php foreach ($rows as $row) { ?> <li><a href="<?php print $row->url; ?> "><?php print date_format_date(new DateTime($row->link), 'custom', 'F Y'); ?> </a> <?php if (!empty($options['count'])) { ?> (<?php print $row->count; ?> ) <?php } ?> </li> <?php }
/** * Build a description of an iCal rule. * * Constructs a human-readable description of the rule. */ function date_repeat_rrule_description($rrule, $format = 'D M d Y') { // Empty or invalid value. if (empty($rrule) || !strstr($rrule, 'RRULE')) { return; } // Make sure there will be an empty description for any unused parts. $description = array('!interval' => '', '!byday' => '', '!bymonth' => '', '!count' => '', '!until' => '', '!except' => '', '!additional' => '', '!week_starts_on' => ''); $parts = self::date_repeat_split_rrule($rrule); $additions = $parts[2]; $exceptions = $parts[1]; $rrule = $parts[0]; $interval = self::INTERVAL_options(); switch ($rrule['FREQ']) { case 'WEEKLY': $description['!interval'] = format_plural($rrule['INTERVAL'], 'every week', 'every @count weeks') . ' '; break; case 'MONTHLY': $description['!interval'] = format_plural($rrule['INTERVAL'], 'every month', 'every @count months') . ' '; break; case 'YEARLY': $description['!interval'] = format_plural($rrule['INTERVAL'], 'every year', 'every @count years') . ' '; break; default: $description['!interval'] = format_plural($rrule['INTERVAL'], 'every day', 'every @count days') . ' '; break; } if (!empty($rrule['BYDAY'])) { $days = date_repeat_dow_day_options(); $counts = date_repeat_dow_count_options(); $results = array(); foreach ($rrule['BYDAY'] as $byday) { $day = substr($byday, -2); $count = intval(str_replace(' ' . $day, '', $byday)); if ($count = intval(str_replace(' ' . $day, '', $byday))) { $results[] = trim(t('!repeats_every_interval on the !date_order !day_of_week', array('!repeats_every_interval ' => '', '!date_order' => strtolower($counts[substr($byday, 0, 2)]), '!day_of_week' => $days[$day]))); } else { $results[] = trim(t('!repeats_every_interval every !day_of_week', array('!repeats_every_interval ' => '', '!day_of_week' => $days[$day]))); } } $description['!byday'] = implode(' ' . t('and') . ' ', $results); } if (!empty($rrule['BYMONTH'])) { if (sizeof($rrule['BYMONTH']) < 12) { $results = array(); $months = Yii::app()->getLocale()->getMonthNames(); foreach ($rrule['BYMONTH'] as $month) { $results[] = $months[$month]; } if (!empty($rrule['BYMONTHDAY'])) { $description['!bymonth'] = trim(t('!repeats_every_interval on the !month_days of !month_names', array('!repeats_every_interval ' => '', '!month_days' => implode(', ', $rrule['BYMONTHDAY']), '!month_names' => implode(', ', $results)))); } else { $description['!bymonth'] = trim(t('!repeats_every_interval on !month_names', array('!repeats_every_interval ' => '', '!month_names' => implode(', ', $results)))); } } } if ($rrule['INTERVAL'] < 1) { $rrule['INTERVAL'] = 1; } if (!empty($rrule['COUNT'])) { $description['!count'] = trim(t('!repeats_every_interval !count times', array('!repeats_every_interval ' => '', '!count' => $rrule['COUNT']))); } if (!empty($rrule['UNTIL'])) { $until = date_ical_date($rrule['UNTIL'], 'UTC'); date_timezone_set($until, date_default_timezone_object()); $description['!until'] = trim(t('!repeats_every_interval until !until_date', array('!repeats_every_interval ' => '', '!until_date' => date_format_date($until, 'custom', $format)))); } if ($exceptions) { $values = array(); foreach ($exceptions as $exception) { $values[] = date_format_date(date_ical_date($exception), 'custom', $format); } $description['!except'] = trim(t('!repeats_every_interval except !except_dates', array('!repeats_every_interval ' => '', '!except_dates' => implode(', ', $values)))); } if (!empty($rrule['WKST'])) { $day_names = date_repeat_dow_day_options(); $description['!week_starts_on'] = trim(t('!repeats_every_interval where the week start on !day_of_week', array('!repeats_every_interval ' => '', '!day_of_week' => $day_names[trim($rrule['WKST'])]))); } if ($additions) { $values = array(); foreach ($additions as $addition) { $values[] = date_format_date(date_ical_date($addition), 'custom', $format); } $description['!additional'] = trim(t('Also includes !additional_dates.', array('!additional_dates' => implode(', ', $values)))); } return t('Repeats !interval !bymonth !byday !count !until !except. !additional', $description); }
/** * Alters link url for month in calendar events block in order to filter events at /events * * @see theme_date_nav_title */ function epf_date_nav_title($params) { $granularity = $params['granularity']; $view = $params['view']; $date_info = $view->date_info; $link = !empty($params['link']) ? $params['link'] : FALSE; $format = !empty($params['format']) ? $params['format'] : NULL; switch ($granularity) { case 'month': $format = !empty($format) ? $format : (empty($date_info->mini) ? 'F Y' : 'F'); $title = date_format_date($date_info->min_date, 'custom', $format); $date_arg = $date_info->year . '-' . date_pad($date_info->month); break; } if (!empty($date_info->mini) || $link) { // Month navigation titles are used as links in the mini view. $attributes = array('title' => t('View full page month')); $url = url('events/' . $date_arg); //date_pager_url($view, $granularity, $date_arg, TRUE); return l($title, $url, array('attributes' => $attributes)); } else { return $title; } }
/** * Overide variables and create additional template suggestions based on aliased path */ function skojtehallen_preprocess_page(&$vars) { // Change site-switcher menu based on context $parts = split(' ', $vars['body_classes']); if (in_array('isbanen', $parts)) { $vars['subsite_menu'] = '<a class="subsite-menu" href="/" >Til Skøjtehallen</a>'; } else { $vars['subsite_menu'] = '<a class="subsite-menu" href="/isbanen/">Til Isbanen</a>'; } if (strlen($vars['header'])) { $vars['header_link'] = '/'; } else { $vars['header_link'] = '/isbanen'; } /** * Generate additional template suggestions based on aliased path */ if (module_exists('path')) { $path_alias = drupal_get_path_alias($_GET['q']); $alias_parts = explode('/', $path_alias); // Check for edit page $last = array_reverse($alias_parts); $last_part = $last[0]; if ($last_part != "edit") { // Generate array of templates $templates = array(); $template_name = "page"; foreach ($alias_parts as $part) { $template_name = $template_name . '-' . $part; $templates[] = $template_name; } // Add suggestions to template array $vars['template_files'] = $templates; // Get node being proccessd $node = $vars['node']; // Add date to News if ($node->type == 'news') { $vars['news_date'] = date_format_date(new DateTime(date('Y-m-d H:i:s', $node->created)), 'custom', 'F Y'); } // Fix news title in month oveview if ($alias_parts[0] == 'nyheder' && count($alias_parts) == 2) { $vars['node_title'] = date_format_date(new DateTime(substr($alias_parts[1], 0, 4) . '-' . substr($alias_parts[1], -2) . '-01'), 'custom', 'F Y'); } // Add date to event if ($node->type == 'event') { $no_of_dates = count($node->field_arrangement_start); if ($no_of_dates == 1) { // Not a repeating event $vars['event_date'] = date_format_date(new DateTime($node->field_arrangement_start[0]['value']), 'custom', 'F Y'); } else { // Repeating event $vars['event_date'] = date_format_date(new DateTime($node->field_arrangement_start[0]['value']), 'custom', 'F Y') . ' - ' . date_format_date(new DateTime($node->field_arrangement_start[$no_of_dates - 1]['value']), 'custom', 'F Y'); } global $user; if (!$user->uid) { $vars['tabs'] = null; // Remove repaet events tab-menu, when not logged in } } } // End check for edit page } // End check for path module // Generate random style for changing images $vars['random_image_class'] = 'theme-style-' . rand(1, 4); // Append conditional styles $vars['styles'] .= $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], ''); }
/** * Reworked from Drupal's format_date function to handle pre-1970 and * post-2038 dates and accept a date object instead of a timestamp as input. * * Translates formatted date results, unlike PHP function date_format(). * Should only be used for display, not input, because it can't be parsed. * * @param $oject * A date object. * @param $type * The format to use. Can be "small", "medium" or "large" for the preconfigured * date formats. If "custom" is specified, then $format is required as well. * @param $format * A PHP date format string as required by date(). A backslash should be used * before a character to avoid interpreting the character as part of a date * format. * @return * A translated date string in the requested format. */ function date_format_date($date, $type = 'medium', $format = '', $langcode = NULL) { if (empty($date)) { return ''; } switch ($type) { case 'small': case 'short': $format = variable_get('date_format_short', 'm/d/Y - H:i'); break; case 'large': case 'long': $format = variable_get('date_format_long', 'l, F j, Y - H:i'); break; case 'custom': $format = $format; break; case 'medium': default: $format = variable_get('date_format_medium', 'D, m/d/Y - H:i'); } $format = date_limit_format($format, $date->granularity); $max = strlen($format); $datestring = ''; for ($i = 0; $i < $max; $i++) { $c = $format[$i]; switch ($c) { case 'l': $datestring .= t($date->format('l'), array(), array('context' => '', 'langcode' => $langcode)); break; case 'D': $datestring .= t($date->format('D'), array(), array('context' => '', 'langcode' => $langcode)); break; case 'F': $datestring .= t($date->format('F'), array(), array('context' => 'Long month name', 'langcode' => $langcode)); break; case 'M': $datestring .= t($date->format('M'), array(), array('context' => 'month_abbr', 'langcode' => $langcode)); break; case 'A': case 'a': $datestring .= t($date->format($c), array(), array('context' => 'ampm', 'langcode' => $langcode)); break; // The timezone name translations can use t(). // The timezone name translations can use t(). case 'e': case 'T': $datestring .= t($date->format($c)); break; // Remaining date parts need no translation. // Remaining date parts need no translation. case 'O': $datestring .= sprintf('%s%02d%02d', date_offset_get($date) < 0 ? '-' : '+', abs(date_offset_get($date) / 3600), abs(date_offset_get($date) % 3600) / 60); break; case 'P': $datestring .= sprintf('%s%02d:%02d', date_offset_get($date) < 0 ? '-' : '+', abs(date_offset_get($date) / 3600), abs(date_offset_get($date) % 3600) / 60); break; case 'Z': $datestring .= date_offset_get($date); break; case '\\': $datestring .= $format[++$i]; break; case 'r': $datestring .= date_format_date($date, 'custom', 'D, d M Y H:i:s O', $langcode); break; default: if (strpos('BdcgGhHiIjLmnNosStTuUwWYyz', $c) !== FALSE) { $datestring .= $date->format($c); } else { $datestring .= $c; } } } return $datestring; }
<div class="field-item"> <label><?php print t('Meeting Schedule'); ?> :</label> <?php $from_date = date_make_date($node->field_date[0]['value'], 'UTC'); date_timezone_set($from_date, timezone_open(date_get_timezone('site'))); // Fix timezone $to_date = date_make_date($node->field_date[0]['value2'], 'UTC'); date_timezone_set($to_date, timezone_open(date_get_timezone('site'))); // Fix timezone $from_date_string = date_format_date($from_date, 'custom', 'F j'); $from_time_string = date_format_date($from_date, 'custom', 'g:i A'); $to_date_string = date_format_date($to_date, 'custom', 'F j'); $to_time_string = date_format_date($to_date, 'custom', 'g:i A'); if ($from_date_string == $to_date_string) { print '<span class="date-display-start">' . "{$from_date_string}, {$from_time_string}" . '</span><span class="date-display-separator"> - </span><span class="date-display-end">' . $to_time_string . '</span>'; } else { print '<span class="date-display-start">' . "{$from_date_string}, {$from_time_string}" . '</span><span class="date-display-separator"> - </span><span class="date-display-end">' . "{$to_date_string}, {$to_time_string}" . '</span>'; } ?> <br /> <?php print l(t('Read more...'), 'node/' . $node->nid); ?> </div> </div> </div> </div> <!-- /committee-updates-right-infobox --> </div></div> <!-- /node-inner, /node -->
function nys_date_all_day($which, $date1, $date2, $format, $node, $view = NULL) { if (empty($date1) || !is_object($date1)) { return ''; } if (empty($date2)) { $date2 = $date1; } $granularity = array_pop(date_format_order($format)); switch ($granularity) { case 'second': $max_comp = date_format($date2, 'H:i:s') == '23:59:59'; break; case 'minute': $max_comp = date_format($date2, 'H:i') == '23:59'; break; case 'hour': $max_comp = date_format($date2, 'H') == '23'; break; default: $max_comp = FALSE; } // Time runs from midnight to the maximum time -- call it 'All day'. if (date_format($date1, 'H:i:s') == '00:00:00' && $max_comp) { $format = date_limit_format($format, array('year', 'month', 'day')); return trim(date_format_date(${$which}, 'custom', $format) . ' ' . theme('date_all_day_label')); } elseif (date_format($date1, 'H:i:s') == '00:00:00' && date_format($date2, 'H:i:s') == '00:00:00') { $format = date_limit_format($format, array('year', 'month', 'day')); return date_format_date(${$which}, 'custom', $format); } else { return date_format_date(${$which}, 'custom', 'M. d'); } }
<?php print $meeting['facility_name']; ?> <a href="<?php print $meeting['gmap_link']; ?> "> <img src="<?php print base_path() . drupal_get_path('module', 'osu_courses_feature'); ?> /map-icon.jpg" alt="Google Maps" style="margin:0px 2px 0px 3px;"/></a> </td> <td class="osu_course_days"><?php print $pattern[0]; ?> </td> <td class="osu_course_times"><?php print $pattern[1]; ?> </td> <td class="osu_course_pat_from osu_course_pat_to"><?php print date_format_date(date_make_date($meeting['start_date']), 'custom', 'n/j'); ?> -<?php print date_format_date(date_make_date($meeting['end_date']), 'custom', 'n/j'); ?> </td> <?php } ?> </tr>
/** * Custom repeat rule theme function for dates. * * @see date_repeat_rrule_description(). */ function ringstedtheme_repeat_rrule_description($rrule, $format = 'd.M') { // Empty or invalid value. if (empty($rrule) || !strstr($rrule, 'RRULE')) { return; } module_load_include('inc', 'date_api', 'date_api_ical'); module_load_include('inc', 'date_repeat', 'date_repeat_calc'); $parts = date_repeat_split_rrule($rrule); $rrule = $parts[0]; if ($rrule['FREQ'] == 'NONE') { return; } // Make sure there will be an empty description for any unused parts. $description = array('!interval' => '', '!byday' => '', '!bymonth' => '', '!count' => '', '!until' => '', '!except' => '', '!additional' => '', '!week_starts_on' => ''); $interval = date_repeat_interval_options(); switch ($rrule['FREQ']) { case 'WEEKLY': if (isset($rrule['BYDAY'])) { $description['!interval'] = format_plural($rrule['INTERVAL'], '', 'every @count weeks') . ' '; } else { $description['!interval'] = format_plural($rrule['INTERVAL'], 'every week', 'every @count weeks') . ' '; } break; case 'MONTHLY': $description['!interval'] = format_plural($rrule['INTERVAL'], 'every month', 'every @count months') . ' '; break; case 'YEARLY': $description['!interval'] = format_plural($rrule['INTERVAL'], 'every year', 'every @count years') . ' '; break; default: $description['!interval'] = format_plural($rrule['INTERVAL'], 'every day', 'every @count days') . ' '; break; } if (!empty($rrule['BYDAY'])) { $days = date_repeat_dow_day_options(); $counts = date_repeat_dow_count_options(); $results = array(); $first_day = $rrule['BYDAY'][0]; foreach ($rrule['BYDAY'] as $byday) { // Get the numeric part of the BYDAY option, i.e. +3 from +3MO. $day = substr($byday, -2); $count = str_replace($day, '', $byday); if (!empty($count)) { // See if there is a 'pretty' option for this count, i.e. +1 => First. $order = array_key_exists($count, $counts) ? strtolower($counts[$count]) : $count; $results[] = trim(t('!repeats_every_interval on the !date_order !day_of_week', array('!repeats_every_interval ' => '', '!date_order' => $order, '!day_of_week' => strtolower($days[$day])))); } else { if ($first_day === $byday) { $results[] = trim(t('!repeats_every_interval every !day_of_week', array('!repeats_every_interval ' => '', '!day_of_week' => strtolower($days[$day])))); } else { $results[] = trim(t('!repeats_every_interval !day_of_week', array('!repeats_every_interval ' => '', '!day_of_week' => strtolower($days[$day])))); } } } $days_count = count($rrule['BYDAY']); if ($days_count > 2) { $last_day = array_pop($results); $description['!byday'] = implode(' , ', $results); $description['!byday'] .= ' ' . t('and') . ' ' . $last_day; } else { $description['!byday'] = implode(' ' . t('and') . ' ', $results); } } if (!empty($rrule['BYMONTH'])) { if (sizeof($rrule['BYMONTH']) < 12) { $results = array(); $months = date_month_names(); foreach ($rrule['BYMONTH'] as $month) { $results[] = $months[$month]; } if (!empty($rrule['BYMONTHDAY'])) { $description['!bymonth'] = trim(t('!repeats_every_interval on the !month_days of !month_names', array('!repeats_every_interval ' => '', '!month_days' => implode(', ', $rrule['BYMONTHDAY']), '!month_names' => implode(', ', $results)))); } else { $description['!bymonth'] = trim(t('!repeats_every_interval on !month_names', array('!repeats_every_interval ' => '', '!month_names' => implode(', ', $results)))); } } } if ($rrule['INTERVAL'] < 1) { $rrule['INTERVAL'] = 1; } if (!empty($rrule['COUNT'])) { $description['!count'] = trim(t('!repeats_every_interval !count times', array('!repeats_every_interval ' => '', '!count' => $rrule['COUNT']))); } if (!empty($rrule['UNTIL'])) { $until = date_ical_date($rrule['UNTIL'], 'UTC'); date_timezone_set($until, date_default_timezone_object()); $description['!until'] = trim(t('!repeats_every_interval until !until_date', array('!repeats_every_interval ' => '', '!until_date' => strtolower(date_format_date($until, 'custom', $format))))); } if (!empty($rrule['WKST'])) { $day_names = date_repeat_dow_day_options(); $description['!week_starts_on'] = trim(t('!repeats_every_interval where the week start on !day_of_week', array('!repeats_every_interval ' => '', '!day_of_week' => $day_names[trim($rrule['WKST'])]))); } return preg_replace('/\\s*\\./', '.', t('Repeats !interval !bymonth !byday !count !until !except. !additional', $description)); }
if (isset($date['value2'])) { $expiration_date = strtotime($date['value2']); if (time() > $expiration_date) { unset($current_node->field_hero_image[$language_prefix][$index]); unset($current_node->field_title[$language_prefix][$index]); unset($current_node->field_slider_date[$language_prefix][$index]); unset($current_node->field_slider_teaser[$language_prefix][$index]); unset($current_node->field_link[$language_prefix][$index]); $rewrite_node = true; continue; } } // Convert from the database time zone to the user's time zone. $date_object = new DateObject($date['value'], new DateTimeZone($date['timezone_db'])); $date_object->setTimezone(new DateTimeZone($date['timezone'])); $slider_date_formatted = date_format_date($date_object, 'custom', $date_format); //date($date_format, strtotime($slider_dates[$index]['value']) ); } $slider_title_formatted = $slider_titles[$index]['value']; $slide_pos += 1; if ($slide_pos === 1) { $navClass = 'active'; $slideClass = 'first active'; } else { $navClass = ''; $slideClass = ''; } $slide = "<div class='slide {$slideClass}' number='{$slide_pos}'>"; $image = theme_image_formatter(array('item' => $slider_image, 'image-style' => 'original')); $slide .= "<div class='slide-image image-cover'>{$image}</div>"; $slide .= "<div class='slide-info-container'>";