format() public static method

* Format a date as per users timezone and format
public static format ( $date, $format = null )
Beispiel #1
0
 /**
  * Set estimated_end_date
  *
  * @param date $estimated_end_date
  */
 public function setEstimatedEndDate($estimated_end_date)
 {
     if ($this->getId() && $this->estimated_end_date != $estimated_end_date) {
         $current = isset($this->estimated_end_date) ? $this->estimated_end_date->format('Y-m-d') : '';
         $this->getLastNote()->addChange("Estimated end date changed from '{$current}' to '{$estimated_end_date->format('Y-m-d')}'");
     }
     if ($this->getOriginalEstimatedEndDate() == null) {
         $this->setOriginalEstimatedEndDate($estimated_end_date);
     }
     $this->estimated_end_date = $estimated_end_date;
 }
Beispiel #2
0
 /**
  * Magic setter
  *
  * @param  string  $key
  * @param  mixed   $value
  */
 public function __set($key, $value)
 {
     switch ($key) {
         // Date of birth
         case 'dob':
             $value = date::format(date::DATE_SQL, $value);
             break;
             // Always lowercase e-mail
         // Always lowercase e-mail
         case 'email':
             $value = utf8::strtolower($value);
             break;
     }
     parent::__set($key, $value);
 }
Beispiel #3
0
 /**
  * Magic setter
  *
  * @param  string  $key
  * @param  mixed   $value
  */
 public function __set($key, $value)
 {
     switch ($key) {
         // Date of birth
         case 'dob':
             $value = date::format(date::DATE_SQL, $value);
             break;
             // Always lowercase e-mail
         // Always lowercase e-mail
         case 'email':
             $value = utf8::strtolower($value);
             break;
             // Use Auth to hash the password
         // Use Auth to hash the password
         case 'password':
             $value = Visitor::instance()->hash_password($value);
             break;
     }
     parent::__set($key, $value);
 }
 function _get_mail_body($template_path)
 {
     $template = new template($template_path);
     $locale =& locale::instance();
     $date = new date();
     $template->set('date', $date->format($locale->get_short_date_format()));
     $cart =& cart::instance();
     $list =& $template->find_child('cart_items');
     $list->register_dataset($cart->get_items_array_dataset());
     $template->set('name', $this->dataspace->get('name'));
     $template->set('notes', $this->dataspace->get('notes'));
     $template->set('phone', $this->dataspace->get('phone'));
     $template->set('address', $this->dataspace->get('address'));
     $template->set('email', $this->dataspace->get('email'));
     ob_start();
     $template->display();
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
Beispiel #5
0
 /**
  * Get bind forum topics
  *
  * @param   string  $bind
  * @return  array
  */
 public function find_bind_topics($bind)
 {
     $topics = array();
     switch ($bind) {
         // Upcoming events
         case 'events_upcoming':
             $events = $this->find_upcoming(100);
             break;
             // Past events
         // Past events
         case 'events_past':
             $events = $this->find_past(100);
             break;
     }
     // Build human readable list
     if (!empty($events)) {
         foreach ($events as $event) {
             $topics[$event->id] = $event->name . ' ' . date::format('DDMMYYYY', $event->start_time);
         }
     }
     return $topics;
 }
Beispiel #6
0
<?php 
foreach ($galleries as $gallery) {
    ?>
	<li class="unit size1of2">
		<div class="thumb unit size2of5">
			<?php 
    echo html::anchor(url::model($gallery), html::image('http://' . Kohana::config('site.image_server') . '/kuvat/' . $gallery->dir . '/thumb_' . $gallery->default_image->legacy_filename));
    ?>
		</div>
		<header>
			<h4><?php 
    echo html::anchor(url::model($gallery), text::title($gallery->name));
    ?>
</h4>
			<span class="details">
				<?php 
    echo html::time(date::format('DMYYYY', $gallery->event_date), $gallery->event_date, true);
    ?>
,
				<?php 
    echo __2(':images image', ':images images', $gallery->image_count, array(':images' => '<var>' . $gallery->image_count . '</var>'));
    ?>
			</span>
		</header>
	</li>
<?php 
}
?>

</ul>
Beispiel #7
0
?>

<?php 
if (!empty($events)) {
    ?>
<ul class="events">

	<?php 
    foreach ($events as $event) {
        ?>
	<li class="event event-<?php 
        echo $event->id;
        ?>
">
		<?php 
        echo date::format('DDMM', $event->start_time);
        ?>
		<!--<?php 
        echo html::anchor(url::model($event), text::limit_chars(text::title($event->name), 20, '&hellip;', true), array('title' => $event->name));
        ?>
-->
		<?php 
        echo html::anchor(url::model($event), $event->name);
        ?>
	</li>
	<?php 
    }
    ?>

</ul>
Beispiel #8
0
 public function getYear()
 {
     return $this->date->format("Y");
 }
Beispiel #9
0
				<dt><?php 
    echo __('Homepage');
    ?>
</dt><dd><?php 
    echo html::anchor($event->homepage);
    ?>
</dd>
				<?php 
}
?>

				<dt><?php 
echo __('Opening hours');
?>
</dt><dd><?php 
echo $event->end_time ? __('From :from to :to', array(':from' => html::time(date::format('HHMM', $event->start_time), $event->start_time), ':to' => html::time(date::format('HHMM', $event->end_time), $event->end_time))) : __('From :from onwards', array(':from' => html::time(date::format('HHMM', $event->start_time), $event->start_time)));
?>
</dd>

				<?php 
if ($event->venue_id) {
    ?>
				<dt><?php 
    echo __('Venue');
    ?>
</dt><dd><?php 
    echo html::anchor(url::model($event->venue), $event->venue->name);
    ?>
, <?php 
    echo html::specialchars($event->venue->city_name);
    ?>
Beispiel #10
0
 * Shouts
 *
 * @package    Anqh
 * @author     Antti Qvickström
 * @copyright  (c) 2010 Antti Qvickström
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 */
?>

<ul>
<?php 
foreach ($shouts as $shout) {
    ?>

	<li><?php 
    echo html::time(date::format('HHMM', $shout->created), $shout->created);
    ?>
 <?php 
    echo html::user($shout->author);
    ?>
: <?php 
    echo html::chars($shout->shout);
    ?>
</li>

<?php 
}
?>
</ul>

<?php 
Beispiel #11
0
 /**
  * User profile
  */
 public function _view()
 {
     $this->tab_id = 'profile';
     $owner = $this->user && $this->member->id == $this->user->id;
     if ($owner && $this->user->newcomments) {
         $this->user->newcomments = 0;
         $this->user->save();
     }
     // Actions
     if ($this->member->has_access(User_Model::ACCESS_EDIT)) {
         $this->page_actions[] = array('link' => url::user($this->member) . '/edit', 'text' => __('Settings'), 'class' => 'settings');
     }
     // Picture
     widget::add('side', View_Mod::factory('member/member', array('mod_class' => 'member member-' . $this->member->id, 'user' => $this->member)));
     // Comments
     if ($this->member->has_access(User_Model::ACCESS_COMMENT)) {
         $comment = new User_Comment_Model();
         $form_values = $comment->as_array();
         $form_errors = array();
         // check post
         if (csrf::valid() && ($post = $this->input->post())) {
             $comment->user_id = $this->member->id;
             $comment->author_id = $this->user->id;
             $comment->comment = $post['comment'];
             if (isset($post['private'])) {
                 $comment->private = 1;
             }
             try {
                 $comment->save();
                 if (!$owner) {
                     $this->member->newcomments += 1;
                     $this->member->save();
                 }
                 $this->user->commentsleft += 1;
                 $this->user->save();
                 if (!request::is_ajax()) {
                     url::redirect(url::current());
                 }
             } catch (ORM_Validation_Exception $e) {
                 $form_errors = $e->validation->errors();
                 $form_values = arr::overwrite($form_values, $post);
             }
         }
         // Handle pagination
         $per_page = 25;
         $page_num = $this->uri->segment('page') ? $this->uri->segment('page') : 1;
         $page_offset = ($page_num - 1) * $per_page;
         $total_comments = $this->member->get_comment_count();
         $comments = $this->member->find_comments($page_num, $per_page, $this->user);
         $pagination = new Pagination(array('items_per_page' => $per_page, 'total_items' => $total_comments));
         $view = View::factory('generic/comments', array('delete' => '/member/comment/%d/delete/?token=' . csrf::token(), 'private' => '/member/comment/%d/private/?token=' . csrf::token(), 'comments' => $comments, 'errors' => $form_errors, 'values' => $form_values, 'pagination' => $pagination, 'user' => $this->user));
         if (request::is_ajax()) {
             echo $view;
             return;
         }
         widget::add('main', $view);
     }
     // Basic info
     $basic_info = array();
     if (!empty($this->member->name)) {
         $basic_info[__('Name')] = html::specialchars($this->member->name);
     }
     if (!empty($this->member->city_name)) {
         $basic_info[__('City')] = html::specialchars($this->member->city_name);
     }
     if (!empty($this->member->dob) && $this->member->dob != '0000-00-00') {
         $basic_info[__('Date of Birth')] = __(':dob (:years years)', array(':dob' => date::format('DMYYYY', $this->member->dob), ':years' => date::timespan(strtotime($this->member->dob), null, 'years')));
     }
     if (!empty($this->member->gender)) {
         $basic_info[__('Gender')] = $this->member->gender == 'm' ? __('Male') : __('Female');
     }
     if (!empty($this->member->latitude) && !empty($this->member->longitude)) {
         $basic_info[__('Location')] = $this->member->latitude . ', ' . $this->member->longitude;
         $basic_info[__('Location')] = html::anchor('#map', __('Toggle map'), array('class' => 'expander', 'title' => __('Show/hide'))) . '<div id="map" style="display: none">' . __('Map loading') . '</div>';
         $map = new Gmap('map', array('ScrollWheelZoom' => true));
         $map->center($this->member->latitude, $this->member->longitude, 15)->controls('small')->types();
         $map->add_marker($this->member->latitude, $this->member->longitude, html::avatar($this->member->avatar, $this->member->username) . html::user($this->member));
         widget::add('foot', html::script_source($map->render('gmaps/jquery_event')));
         widget::add('foot', html::script_source("\$('a[href*=\"#map\"]:first').click(function() { \$('#map').toggle('normal', gmap_open); return false; });"));
     }
     // Site info
     $site_info = array(__('Registered') => date::format('DMYYYY_HM', $this->member->created) . ' [#' . $this->member->id . ']', __('Logins') => __(':logins (:ago ago)', array(':logins' => number_format($this->member->logins, 0), ':ago' => '<abbr title="' . date::format('DMYYYY_HM', $this->member->last_login) . '">' . date::timespan_short($this->member->last_login) . '</abbr>')), __('Posts') => number_format($this->member->posts, 0), __('Comments') => number_format($this->member->commentsleft, 0));
     // Initialize tabs
     $tabs = array('basic-info' => array('href' => '#basic-info', 'title' => __('Basic info'), 'tab' => new View('generic/list_info', array('id' => 'basic-info', 'title' => __('Basic info'), 'list' => $basic_info))), 'site-info' => array('href' => '#site-info', 'title' => __('Site info'), 'tab' => new View('generic/list_info', array('id' => 'site-info', 'title' => __('Site info'), 'list' => $site_info))));
     widget::add('side', View::factory('generic/tabs', array('id' => 'info-tab', 'tabs' => $tabs)));
     $this->_side_views();
 }
Beispiel #12
0
				<?php 
    }
    ?>
				<?php 
    if ($image->exif->iso) {
        ?>
				<dd><?php 
        echo __('ISO speed: :iso', array(':iso' => '<var>' . text::title($image->exif->iso, true)));
        ?>
</dd>
				<?php 
    }
    ?>
				<?php 
    if ($image->exif->taken) {
        ?>
				<dd><?php 
        echo __('Taken: :taken', array(':taken' => '<var>' . date::format('DMYYYY_HM', $image->exif->taken)));
        ?>
</dd>
				<?php 
    }
    ?>
			<?php 
}
?>

		</dl>
	</div>
</section>
Beispiel #13
0
 /**
  * Get date
  *
  * @return date 
  */
 public function getDate()
 {
     return $this->date->format('d/m/Y');
 }
Beispiel #14
0
 /**
  * Get timeend
  *
  * @return datetime
  */
 public function getTimeend($format = null)
 {
     if (null === $this->timeend || null === $format) {
         return $this->timeend;
     }
     return $this->timeend->format($format);
 }
Beispiel #15
0
 /**
  * Return formatted <time> tag
  *
  * @param  string        $str
  * @param  array|string  $attributes  handled as time if not an array
  * @param  boolean       $short       use only date
  */
 public static function time($str, $attributes = null, $short = false)
 {
     // Extract datetime
     $datetime = is_array($attributes) ? arr::remove('datetime', $attributes) : $attributes;
     if ($datetime) {
         $time = is_int($datetime) ? $datetime : strtotime($datetime);
         $datetime = date::format($short ? date::DATE_8601 : date::TIME_8601, $time);
         if (is_array($attributes)) {
             $attributes['datetime'] = $datetime;
         } else {
             $attributes = array('datetime' => $datetime);
         }
         // Set title if not the same as content
         if (!isset($attributes['title'])) {
             $title = date::format($short ? 'DMYYYY' : 'DMYYYY_HM', $time);
             if ($title != $str) {
                 $attributes['title'] = date::format($short ? 'DMYYYY' : 'DMYYYY_HM', $time);
             }
         }
     }
     return '<time' . html::attributes($attributes) . '>' . $str . '</time>';
 }
Beispiel #16
0
<ul class="contentlist friends">
	<?php 
foreach ($friends as $friend) {
    ?>
	<li class="member clearfix">
		<?php 
    echo html::avatar($friend->friend->avatar, $friend->friend->username);
    ?>
		<?php 
    echo html::nick($friend->friend->id, $friend->friend->username);
    ?>
<br />
		<?php 
    echo __('Last online :ago ago', array(':ago' => '<abbr title="' . date::format('DMYYYY_HM', $friend->friend->last_login) . '">' . date::timespan_short($friend->friend->last_login) . '</abbr>'));
    ?>
	</li>
	<?php 
}
?>
</ul>
Beispiel #17
0
 /**
  * Checks whether end date is after start date.
  *
  * @access public
  *
  * @param date $oStartDate  Pear::Date object with Start Date
  * @param date $oEndDate    Pear::Date object with End Date
  *
  * @return boolean  Returns false when start date
  *                      is after end date and true in other case.
  */
 function checkDateOrder($oStartDate, $oEndDate)
 {
     if (isset($oStartDate) && isset($oEndDate) && ($oStartDate->format("%Y-%m-%d") != OA_Dal::noDateValue() && $oEndDate->format("%Y-%m-%d") != OA_Dal::noDateValue()) && $oStartDate->after($oEndDate)) {
         $this->raiseError('The start date is after the end date');
         return false;
     } else {
         return true;
     }
 }
Beispiel #18
0
 /**
  * Event view
  *
  * @param  mixed   $event_id or add
  * @param  string  $action
  */
 public function event($event_id, $action = false)
 {
     $this->tabs = null;
     // Add new event
     if ($event_id == 'add') {
         $this->_event_edit();
         return;
     } else {
         if ($action) {
             switch ($action) {
                 // Delete event
                 case 'delete':
                     $this->_event_delete($event_id);
                     return;
                     // Edit event
                 // Edit event
                 case 'edit':
                     $this->_event_edit($event_id);
                     return;
                     // Add to favorites
                 // Add to favorites
                 case 'favorite':
                     $this->_favorite_add($event_id);
                     return;
                     // Remove from favorites
                 // Remove from favorites
                 case 'unfavorite':
                     $this->_favorite_delete($event_id);
                     return;
             }
         }
     }
     $event = new Event_Model((int) $event_id);
     $errors = !$event->id ? array(__('Event not found')) : array();
     if (empty($errors)) {
         $this->breadcrumb[] = html::anchor(url::model($event), $event->name);
         // Actions
         if ($this->visitor->logged_in()) {
             if ($event->is_favorite($this->user)) {
                 $this->page_actions[] = array('link' => url::model($event) . '/unfavorite/?token=' . csrf::token(), 'text' => __('Remove favorite'), 'class' => 'favorite-delete');
             } else {
                 $this->page_actions[] = array('link' => url::model($event) . '/favorite/?token=' . csrf::token(), 'text' => __('Add favorite'), 'class' => 'favorite-add');
             }
             if ($event->is_author() || $this->visitor->logged_in(array('admin', 'event moderator'))) {
                 $this->page_actions[] = array('link' => url::model($event) . '/edit', 'text' => __('Edit event'), 'class' => 'event-edit');
             }
         }
         list($year, $month, $day) = explode('-', date('Y-m-d', strtotime($event->start_time)));
         $this->date->setDate($year, $month, $day);
         $this->page_title = text::title($event->name);
         $this->page_subtitle = html::time(date('l ', strtotime($event->start_time)) . date::format('DDMMYYYY', $event->start_time), $event->start_time, true);
         $venue = array();
         if ($event->venue_id) {
             $venue[] = html::anchor(url::model($event->venue), $event->venue->name);
             $venue[] = html::specialchars($event->venue->city_name);
         } else {
             if ($event->venue_name) {
                 $venue[] = $event->venue_url ? html::anchor($event->venue_url, $event->venue_name) : html::specialchars($event->venue_name);
                 if ($event->city_name) {
                     $venue[] = html::specialchars($event->city_name);
                 }
             } else {
                 if ($event->city_name) {
                     $venue[] = html::specialchars($event->city_name);
                 }
             }
         }
         if (count($venue)) {
             $this->page_subtitle .= ' @ ' . implode(', ', $venue);
         }
         widget::add('main', View::factory('events/event', array('event' => $event)));
         widget::add('side', View::factory('events/event_info', array('user' => $this->user, 'event' => $event)));
     } else {
         $this->_error(__('Error'), $errors);
     }
     //$this->_side_views();
 }
Beispiel #19
0
<ul class="contentlist favorites events">
	<?php 
foreach ($favorites as $favorite) {
    ?>
	<li class="event-<?php 
    echo $favorite->id;
    ?>
">
		<?php 
    echo date::format('DDMMYYYY', $favorite->start_time);
    ?>
		<?php 
    echo html::anchor(url::model($favorite), text::title($favorite->name), array('title' => html::specialchars($favorite->name)));
    ?>
	</li>
	<?php 
}
?>
</ul>
Beispiel #20
0
 /**
  * Changes the task status
  *
  * @param int $userId
  * 
  * @param string $status
  * 
  * @param date $selectedDate
  * 
  * @return \Doctrine\ORM\QueryBuilder
  */
 public function ChangeTaskStatus($userId, $status, $selectedDate)
 {
     $query = $this->getEntityManager()->createQuery("UPDATE Vlreleases\\UserBundle\\Entity\\UserTask ut SET ut.status='" . $status . "'\n                 WHERE ut.date = '" . $selectedDate->format('Y-m-d') . "' AND ut.user = {$userId}");
     try {
         return $query->getResult();
     } catch (\Doctrine\ORM\NoResultException $e) {
         return null;
     }
 }
Beispiel #21
0
 /**
  * Get datAniversario
  *
  * @return \DateTime
  */
 public function getDatAniversario()
 {
     return $this->datAniversario->format('d/m/Y');
 }
Beispiel #22
0
	<dl>
		<dt><?php 
echo __('Registered');
?>
:</dt><dd><?php 
echo date::format('DMYYYY_HM', $user->created);
?>
</dd>
		<dt><?php 
echo __('Logins');
?>
:</dt><dd><?php 
echo number_format($user->logins, 0);
?>
 (<?php 
echo __(':ago ago', array(':ago' => '<abbr title="' . date::format('DMYYYY_HM', $user->last_login) . '">' . date::timespan_short($user->last_login) . '</abbr>'));
?>
)</dd>
		<dt><?php 
echo __('Forum posts');
?>
:</dt><dd><?php 
echo number_format($user->posts, 0);
?>
</dd>
		<dt><?php 
echo __('Profile comments');
?>
:</dt><dd><?php 
echo number_format($user->commentsleft, 0);
?>