本文整理汇总了PHP中Horde_Date::setTimezone方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Date::setTimezone方法的具体用法?PHP Horde_Date::setTimezone怎么用?PHP Horde_Date::setTimezone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Date
的用法示例。
在下文中一共展示了Horde_Date::setTimezone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOffset
/**
* Return the CURRENT offset from UTC for this station as provided by the
* API.
*
* @return integer The current offset from UTC.
* @since 1.2.0
*/
public function getOffset()
{
if (!empty($this->_properties['tz']) && is_numeric($this->_properties['tz'])) {
return ($this->tz < 0 ? '-' : '') . gmdate('H:i', floor(abs($this->tz) * 60 * 60));
} elseif (!empty($this->_properties['tz'])) {
try {
$d = new Horde_Date(time(), 'UTC');
$d->setTimezone($this->tz);
return $d->tzOffset();
} catch (Horde_Date_Exception $e) {
}
}
return false;
}
示例2: _isNthOcurrenceOfWeekdayInMonth
/**
* Test if the weekday of the given timestamp is the nth occurence of this
* weekday within its month, where '5' indicates the last occurrence even if
* there is less than five occurrences.
*
* @param integer $timestamp The timestamp to check.
* @param integer $occurence 1 to 5, where 5 indicates the final occurrence
* during the month if that day of the week does
* not occur 5 times
* @return boolean
*/
protected static function _isNthOcurrenceOfWeekdayInMonth($timestamp, $occurence)
{
$original = new Horde_Date($timestamp);
$original->setTimezone('UTC');
if ($occurence == 5) {
$modified = $original->add(array('mday' => 7));
return $modified->month > $original->month;
} else {
$modified = $original->sub(array('mday' => 7 * $occurence));
$modified2 = $original->sub(array('mday' => 7 * ($occurence - 1)));
return $modified->month < $original->month && $modified2->month == $original->month;
}
}
示例3: buildFbString
/**
* Build a EAS style FB string. Essentially, each digit represents 1/2 hour.
* The values are as follows:
* 0 - Free
* 1 - Tentative
* 2 - Busy
* 3 - OOF
* 4 - No data available.
*
* Though currently we only provide a Free/Busy/Unknown differentiation.
*
* @param stdClass $fb The fb information. An object containing:
* - s: The start of the period covered.
* - e: The end of the period covered.
* - b: An array of busy periods.
*
* @param Horde_Date $start The start of the period requested by the client.
* @param Horde_Date $end The end of the period requested by the client.
*
* @return string The EAS freebusy string.
* @since 2.4.0
*/
public static function buildFbString($fb, Horde_Date $start, Horde_Date $end)
{
if (empty($fb)) {
return false;
}
// Convert all to UTC
$start->setTimezone('UTC');
$end->setTimezone('UTC');
// Calculate total time span (end timestamp in non-inclusive).
$end_ts = $end->timestamp() - 1;
$start_ts = $start->timestamp();
$sec = $end_ts - $start_ts;
$fb_start = new Horde_Date($fb->s);
$fb_end = new Horde_Date($fb->e);
$fb_start->setTimezone('UTC');
$fb_end->setTimezone('UTC');
// Number of 30 minute periods.
$period_cnt = ceil($sec / 1800);
// Requested range is completely out of the available range.
if ($start_ts >= $fb_end->timestamp() || $end_ts < $fb_start->timestamp()) {
return str_repeat('4', $period_cnt);
}
// We already know we don't have any busy periods.
if (empty($fb->b) && $fb_end->timestamp() <= $end_ts) {
return str_repeat('0', $period_cnt);
}
$eas_fb = '';
// Move $start to the start of the available data.
while ($start_ts < $fb_start->timestamp() && $start_ts <= $end_ts) {
$eas_fb .= '4';
$start_ts += 1800;
// 30 minutes
}
// The rest is assumed free up to $fb->e
while ($start_ts <= $fb_end->timestamp() && $start_ts <= $end_ts) {
$eas_fb .= '0';
$start_ts += 1800;
}
// The remainder is also unavailable
while ($start_ts <= $end_ts) {
$eas_fb .= '4';
$start_ts += 1800;
}
// Now put in the busy blocks. Need to convert to UTC here too since
// all fb data is returned as local tz.
while (list($b_start, $b_end) = each($fb->b)) {
$b_start = new Horde_Date($b_start);
$b_start->setTimezone('UTC');
$b_end = new Horde_Date($b_end);
$b_end->setTimezone('UTC');
if ($b_start->timestamp() > $end->timestamp()) {
continue;
}
$offset = $b_start->timestamp() - $start->timestamp();
$duration = ceil(($b_end->timestamp() - $b_start->timestamp()) / 1800);
if ($offset > 0) {
$eas_fb = substr_replace($eas_fb, str_repeat('2', $duration), floor($offset / 1800), $duration);
}
}
return $eas_fb;
}
示例4: fromDriver
/**
* Imports a backend specific event object.
*
* @param array $event Backend specific event object that this object
* will represent.
*/
public function fromDriver($SQLEvent)
{
$driver = $this->getDriver();
if (isset($SQLEvent['event_timezone'])) {
$this->timezone = $SQLEvent['event_timezone'];
}
$tz_local = date_default_timezone_get();
$this->allday = (bool) $SQLEvent['event_allday'];
if (!$this->allday && $driver->getParam('utc')) {
$this->start = new Horde_Date($SQLEvent['event_start'], 'UTC');
$this->start->setTimezone($tz_local);
$this->end = new Horde_Date($SQLEvent['event_end'], 'UTC');
$this->end->setTimezone($tz_local);
} else {
$this->start = new Horde_Date($SQLEvent['event_start']);
$this->end = new Horde_Date($SQLEvent['event_end']);
if ($this->end->hour == 23 && $this->end->min == 59) {
$this->end->hour = $this->end->min = $this->end->sec = 0;
$this->end->mday++;
}
}
$this->durMin = ($this->end->timestamp() - $this->start->timestamp()) / 60;
$this->title = $driver->convertFromDriver($SQLEvent['event_title']);
$this->id = $SQLEvent['event_id'];
$this->uid = $SQLEvent['event_uid'];
$this->creator = $SQLEvent['event_creator_id'];
$this->organizer = $SQLEvent['event_organizer'];
if (!empty($SQLEvent['event_recurtype'])) {
$this->recurrence = new Horde_Date_Recurrence($this->start);
$this->recurrence->setRecurType((int) $SQLEvent['event_recurtype']);
$this->recurrence->setRecurInterval((int) $SQLEvent['event_recurinterval']);
if (isset($SQLEvent['event_recurenddate']) && $SQLEvent['event_recurenddate'] != '9999-12-31 23:59:59') {
if ($driver->getParam('utc')) {
$recur_end = new Horde_Date($SQLEvent['event_recurenddate'], 'UTC');
if ($recur_end->min == 0) {
/* Old recurrence end date format. */
$recur_end = new Horde_Date($SQLEvent['event_recurenddate']);
$recur_end->hour = 23;
$recur_end->min = 59;
$recur_end->sec = 59;
} else {
$recur_end->setTimezone(date_default_timezone_get());
}
} else {
$recur_end = new Horde_Date($SQLEvent['event_recurenddate']);
$recur_end->hour = 23;
$recur_end->min = 59;
$recur_end->sec = 59;
}
$this->recurrence->setRecurEnd($recur_end);
}
if (isset($SQLEvent['event_recurcount'])) {
$this->recurrence->setRecurCount((int) $SQLEvent['event_recurcount']);
}
if (isset($SQLEvent['event_recurdays'])) {
$this->recurrence->recurData = (int) $SQLEvent['event_recurdays'];
}
if (!empty($SQLEvent['event_exceptions'])) {
$this->recurrence->exceptions = explode(',', $SQLEvent['event_exceptions']);
}
}
if (isset($SQLEvent['event_location'])) {
$this->location = $driver->convertFromDriver($SQLEvent['event_location']);
}
if (isset($SQLEvent['event_url'])) {
$this->url = $SQLEvent['event_url'];
}
if (isset($SQLEvent['event_private'])) {
$this->private = (bool) $SQLEvent['event_private'];
}
if (isset($SQLEvent['event_status'])) {
$this->status = (int) $SQLEvent['event_status'];
}
if (isset($SQLEvent['event_attendees'])) {
$attendees = unserialize($SQLEvent['event_attendees']);
if ($attendees) {
if (!is_object($attendees)) {
$this->attendees = new Kronolith_Attendee_List();
foreach ($attendees as $email => $attendee) {
$this->attendees->add(Kronolith_Attendee::migrate($email, $driver->convertFromDriver($attendee)));
}
} else {
$this->attendees = new Kronolith_Attendee_List(iterator_to_array($attendees));
}
}
}
if (isset($SQLEvent['event_resources'])) {
$resources = unserialize($SQLEvent['event_resources']);
if ($resources) {
$this->_resources = array_change_key_case($driver->convertFromDriver($resources));
}
}
if (isset($SQLEvent['event_description'])) {
$this->description = $driver->convertFromDriver($SQLEvent['event_description']);
//.........这里部分代码省略.........
示例5: _convertUTC2LocalTime
/**
* Converts an UTC timestamp like "20061222T110000Z" into a local
* timestamp like "20061222T130000" using the server timezone.
*
* @param array $utc Array with a datetime string in UTC.
*
* @return string The datetime string converted to the local timezone.
*/
protected function _convertUTC2LocalTime($utc)
{
$date = new Horde_Date($utc[0]);
$date->setTimezone(date_default_timezone_get());
return $date->format("Ymd\\THis");
}
示例6: _formatDate
/**
* Oh yeah. This is beautiful. Exchange outputs date fields differently in
* calendar items and emails. We could just always send one or the other,
* but unfortunately nokia's 'Mail for exchange' depends on this quirk.
* So we have to send a different date type depending on where it's used.
* Used when encoding a date value to send to the client.
*
* @param Horde_Date $dt The Horde_Date object to format
* (should normally be in local tz).
* @param integer $type The type to format as: One of
* TYPE_DATE or TYPE_DATE_DASHES, TYPE_DATE_LOCAL
*
* @return string The formatted date
* @throws InvalidArgumentException
*/
protected function _formatDate(Horde_Date $dt, $type)
{
switch ($type) {
case self::TYPE_DATE:
return $dt->setTimezone('UTC')->format('Ymd\\THis\\Z');
case self::TYPE_DATE_DASHES:
return $dt->setTimezone('UTC')->format('Y-m-d\\TH:i:s\\.000\\Z');
case self::TYPE_DATE_LOCAL:
return $dt->format('Y-m-d\\TH:i:s\\.000\\Z');
default:
throw new InvalidArgumentException('Unidentified DATE_TYPE');
}
}
示例7: _gc
/**
* Garbage collects old alarms in the backend.
*/
protected function _gc()
{
$query = sprintf('DELETE FROM %s WHERE alarm_end IS NOT NULL AND alarm_end < ?', $this->_params['table']);
$end = new Horde_Date(time());
$this->_db->delete($query, array($end->setTimezone('UTC')->format(Horde_Date::DATE_DEFAULT)));
}
示例8: setTimezone
/**
* Converts this event between the event's and the local timezone.
*
* @param boolean $to_orginal If true converts to the event's timezone.
*/
public function setTimezone($to_original)
{
if (!$this->timezone || !$this->getDriver()->supportsTimezones()) {
return;
}
$timezone = $to_original ? $this->timezone : date_default_timezone_get();
$this->start->setTimezone($timezone);
$this->end->setTimezone($timezone);
if ($this->recurs() && $this->recurrence->hasRecurEnd()) {
/* @todo Check if have to go through all recurrence
exceptions too. */
$this->recurrence->start->setTimezone($timezone);
$this->recurrence->recurEnd->setTimezone($timezone);
}
}
示例9: fromRRule20
/**
* Parses an iCalendar 2.0 recurrence rule.
*
* @link http://rfc.net/rfc2445.html#s4.3.10
* @link http://rfc.net/rfc2445.html#s4.8.5
* @link http://www.shuchow.com/vCalAddendum.html
*
* @param string $rrule An iCalendar 2.0 conform RRULE value.
*/
public function fromRRule20($rrule)
{
$this->reset();
// Parse the recurrence rule into keys and values.
$rdata = array();
$parts = explode(';', $rrule);
foreach ($parts as $part) {
list($key, $value) = explode('=', $part, 2);
$rdata[Horde_String::upper($key)] = $value;
}
if (isset($rdata['FREQ'])) {
// Always default the recurInterval to 1.
$this->setRecurInterval(isset($rdata['INTERVAL']) ? $rdata['INTERVAL'] : 1);
switch (Horde_String::upper($rdata['FREQ'])) {
case 'DAILY':
$this->setRecurType(self::RECUR_DAILY);
break;
case 'WEEKLY':
$this->setRecurType(self::RECUR_WEEKLY);
if (isset($rdata['BYDAY'])) {
$maskdays = array('SU' => Horde_Date::MASK_SUNDAY, 'MO' => Horde_Date::MASK_MONDAY, 'TU' => Horde_Date::MASK_TUESDAY, 'WE' => Horde_Date::MASK_WEDNESDAY, 'TH' => Horde_Date::MASK_THURSDAY, 'FR' => Horde_Date::MASK_FRIDAY, 'SA' => Horde_Date::MASK_SATURDAY);
$days = explode(',', $rdata['BYDAY']);
$mask = 0;
foreach ($days as $day) {
$mask |= $maskdays[$day];
}
$this->setRecurOnDay($mask);
} else {
// Recur on the day of the week of the original
// recurrence.
$maskdays = array(Horde_Date::DATE_SUNDAY => Horde_Date::MASK_SUNDAY, Horde_Date::DATE_MONDAY => Horde_Date::MASK_MONDAY, Horde_Date::DATE_TUESDAY => Horde_Date::MASK_TUESDAY, Horde_Date::DATE_WEDNESDAY => Horde_Date::MASK_WEDNESDAY, Horde_Date::DATE_THURSDAY => Horde_Date::MASK_THURSDAY, Horde_Date::DATE_FRIDAY => Horde_Date::MASK_FRIDAY, Horde_Date::DATE_SATURDAY => Horde_Date::MASK_SATURDAY);
$this->setRecurOnDay($maskdays[$this->start->dayOfWeek()]);
}
break;
case 'MONTHLY':
if (isset($rdata['BYDAY'])) {
$this->setRecurType(self::RECUR_MONTHLY_WEEKDAY);
} else {
$this->setRecurType(self::RECUR_MONTHLY_DATE);
}
break;
case 'YEARLY':
if (isset($rdata['BYYEARDAY'])) {
$this->setRecurType(self::RECUR_YEARLY_DAY);
} elseif (isset($rdata['BYDAY'])) {
$this->setRecurType(self::RECUR_YEARLY_WEEKDAY);
} else {
$this->setRecurType(self::RECUR_YEARLY_DATE);
}
break;
}
// MUST take into account the time portion if it is present.
// See Bug: 12869 and Bug: 2813
if (isset($rdata['UNTIL'])) {
if (preg_match('/^(\\d{4})-?(\\d{2})-?(\\d{2})T? ?(\\d{2}):?(\\d{2}):?(\\d{2})(?:\\.\\d+)?(Z?)$/', $rdata['UNTIL'], $parts)) {
$until = new Horde_Date($rdata['UNTIL'], 'UTC');
$until->setTimezone($this->start->timezone);
} else {
list($year, $month, $mday) = sscanf($rdata['UNTIL'], '%04d%02d%02d');
$until = new Horde_Date(array('year' => $year, 'month' => $month, 'mday' => $mday + 1), $this->start->timezone);
}
$this->setRecurEnd($until);
}
if (isset($rdata['COUNT'])) {
$this->setRecurCount($rdata['COUNT']);
}
} else {
// No recurrence data - event does not recur.
$this->setRecurType(self::RECUR_NONE);
}
}
示例10: stopTimer
/**
* Stop a timer. Expects the following in $this->vars:
* - t: The timer id.
* - restart:
*
* @return array An array describing the current timer state. Contains:
* - h: The total number of hours elapsed so far.
* - n: A note to apply to the description field of a time slice.
* - t: The new timer title, if restarting.
*/
public function stopTimer()
{
global $prefs, $notification;
try {
$timer = Hermes::getTimer($this->vars->t);
} catch (Horde_Exception_NotFound $e) {
$notification->push(_("Invalid timer requested"), 'horde.error');
return false;
}
$results = $timer;
$tname = $timer['name'];
$elapsed = (!$timer['paused'] ? time() - $timer['time'] : 0) + $timer['elapsed'];
$results['h'] = round((double) $elapsed / 3600, 2);
$started = new Horde_Date($this->vars->t, 'UTC');
$started->setTimezone(date_default_timezone_get());
$now = new Horde_Date(time(), 'UTC');
$now->setTimezone(date_default_timezone_get());
if ($prefs->getValue('add_description')) {
$results['n'] = sprintf(_("Using the \"%s\" stop watch from %s %s to %s %s"), $tname, $started->strftime($prefs->getValue('date_format_mini')), $started->strftime($prefs->getValue('time_format')), $now->strftime($prefs->getValue('date_format_mini')), $now->strftime($prefs->getValue('time_format')));
} else {
$results['n'] = '';
}
$notification->push(sprintf(_("The stop watch \"%s\" has been stopped."), $tname), 'horde.success');
Hermes::clearTimer($this->vars->t);
if ($this->vars->restart == 'true') {
$now = time();
$timer['elapsed'] = 0;
$timer['paused'] = $results['paused'] = true;
$timer['time'] = $now;
Hermes::updateTimer($this->vars->t, $timer);
}
return $results;
}
示例11: _formatDate
/**
* Oh yeah. This is beautiful. Exchange outputs date fields differently in
* calendar items and emails. We could just always send one or the other,
* but unfortunately nokia's 'Mail for exchange' depends on this quirk.
* So we have to send a different date type depending on where it's used.
*
* @param Horde_Date $dt The datetime to format (assumed to be in local tz)
* @param integer $type The type to format as (TYPE_DATE or TYPE_DATE_DASHES)
*
* @return string The formatted date
*/
protected function _formatDate(Horde_Date $dt, $type)
{
if ($type == Horde_ActiveSync_Message_Base::TYPE_DATE) {
return $dt->setTimezone('UTC')->format('Ymd\\THis\\Z');
} elseif ($type == Horde_ActiveSync_Message_Base::TYPE_DATE_DASHES) {
return $dt->setTimezone('UTC')->format('Y-m-d\\TH:i:s\\.000\\Z');
}
}
示例12: _buildTask
/**
* Return an array describing this task from the provided backend data.
*
* @param array $row The backend data
* @param boolean $include_history Include history data.
*
* @return array The task data.
*/
protected function _buildTask($row, $include_history = true)
{
// Make sure tasks always have a UID.
if (empty($row['task_uid'])) {
$row['task_uid'] = strval(new Horde_Support_Guid());
$query = 'UPDATE ' . $this->_params['table'] . ' SET task_uid = ?' . ' WHERE task_owner = ? AND task_id = ?';
$values = array($row['task_uid'], $row['task_owner'], $row['task_id']);
try {
$this->_db->update($query, $values);
} catch (Horde_Db_Exception $e) {
}
}
if (!$row['task_due'] || !$row['task_recurtype']) {
$recurrence = null;
} else {
$recurrence = new Horde_Date_Recurrence($row['task_due']);
$recurrence->setRecurType((int) $row['task_recurtype']);
$recurrence->setRecurInterval((int) $row['task_recurinterval']);
if (isset($row['task_recurenddate']) && $row['task_recurenddate'] != '9999-12-31 23:59:59') {
$recur_end = new Horde_Date($row['task_recurenddate'], 'UTC');
$recur_end->setTimezone(date_default_timezone_get());
$recurrence->setRecurEnd($recur_end);
}
if (isset($row['task_recurcount'])) {
$recurrence->setRecurCount((int) $row['task_recurcount']);
}
if (isset($row['task_recurdays'])) {
$recurrence->recurData = (int) $row['task_recurdays'];
}
if (!empty($row['task_exceptions'])) {
$recurrence->exceptions = explode(',', $row['task_exceptions']);
}
if (!empty($row['task_completions'])) {
$recurrence->completions = explode(',', $row['task_completions']);
}
}
/* Create a new task based on $row's values. */
$task = array('tasklist_id' => $row['task_owner'], 'task_id' => $row['task_id'], 'uid' => Horde_String::convertCharset($row['task_uid'], $this->_params['charset'], 'UTF-8'), 'parent' => $row['task_parent'], 'owner' => $row['task_creator'], 'assignee' => $row['task_assignee'], 'name' => Horde_String::convertCharset($row['task_name'], $this->_params['charset'], 'UTF-8'), 'desc' => Horde_String::convertCharset($row['task_desc'], $this->_params['charset'], 'UTF-8'), 'start' => $row['task_start'], 'due' => $row['task_due'], 'priority' => $row['task_priority'], 'estimate' => (double) $row['task_estimate'], 'completed' => $row['task_completed'], 'completed_date' => isset($row['task_completed_date']) ? $row['task_completed_date'] : null, 'alarm' => $row['task_alarm'], 'methods' => Horde_String::convertCharset(@unserialize($row['task_alarm_methods']), $this->_params['charset'], 'UTF-8'), 'private' => $row['task_private'], 'recurrence' => $recurrence);
if ($include_history) {
try {
$userId = $GLOBALS['registry']->getAuth();
$log = $GLOBALS['injector']->getInstance('Horde_History')->getHistory('nag:' . $row['task_owner'] . ':' . $row['task_uid']);
foreach ($log as $entry) {
switch ($entry['action']) {
case 'add':
$task['created'] = new Horde_Date($entry['ts']);
if ($userId != $entry['who']) {
$task['createdby'] = sprintf(_("by %s"), Nag::getUserName($entry['who']));
} else {
$task['createdby'] = _("by me");
}
break;
case 'modify':
$task['modified'] = new Horde_Date($entry['ts']);
if ($userId != $entry['who']) {
$task['modifiedby'] = sprintf(_("by %s"), Nag::getUserName($entry['who']));
} else {
$task['modifiedby'] = _("by me");
}
break;
}
}
} catch (Horde_Exception $e) {
}
}
return $task;
}
示例13: UTC2LocalDate
public function UTC2LocalDate($s)
{
$date = new Horde_Date($s);
$date->setTimezone(date_default_timezone_get());
return $date->format('Ymd') . 'T000000';
}
示例14: normalizePoomContactsDates
/**
* Return the number of hours to offset a POOMCONTACTS:BIRTHDAY
* or ANNIVERSARY field in an attempt to work around a bug in the
* protocol - which doesn't define a standard time for birthdays to occur.
*
* WP:
* Devices seem to send the birthdays at the entered date, with
* a time of 00:00:00 UTC during standard time and with 01:00:00 UTC
* during DST if the client's configured timezone observes it. No idea
* what purpose this serves since no timezone data is transmitted for
* birthday values.
*
* iOS:
* Seems different based on version. iOS 5+, at least seems to send
* the birthday as midnight at the entered date in the device's timezone
* then converted to UTC. Some minor issues with offsets being off an
* hour or two for some timezones though.
*
* iOS < 5 sends the birthday time part as the time the birthday
* was entered/edited on the device, converted to UTC, so it can't be
* trusted at all. The best we can do here is transform the date to
* midnight on date_default_timezone() converted to UTC.
*
* Android:
* For contacts originating on the SERVER, the following is true:
*
* Stock 4.3 Takes the down-synched bday value which is assumed to be
* UTC, does some magic to it (converts to milliseconds, creates a
* gregorian calendar object, then converts to YYYY-MM-DD). When
* sending the bday value up, it sends it up as-is. No conversion
* to/from UTC or local is done.
*
* Stock 4.4.x does the above, but before sending the bday value,
* validates that it's in a correct format for sending to the server.
* This really only affects date data originally entered on the device
* for non-stock android clients.
*
* There is some strange bit of code in Android that adds 1 to the
* DAY_OF_MONTH when HOUR_OF_DAY >= 12 in an attempt to "fix"
* birthday handling for GMT+n users. See:
* https://android.googlesource.com/platform/packages/apps/Exchange/+/32daacdd71b9de8fd5e3f59c37934e3e4a9fa972%5E!/exchange2/src/com/android/exchange/adapter/ContactsSyncAdapter.java
* Not sure what to make of it, or why it's not just converted to
* local tz when displaying but this probably breaks birthday handling
* for people in a few timezones.
*
* For contacts originating on the CLIENT, the datetime is sent as
* 08:00:00 UTC, and this seems to be regardless of the timezone set
* in the Android system.
*
* Given all of this, it makes sense to me to ALWAYS send birthday
* data as occuring at 08:00:00 UTC for *native* Android clients.
*
* BB 10+ expects it at 12:00:00 UTC
*
* @param Horde_Date $date The date. This should normally be in the local
* timezone if encoding the date for the client.
* If decoding the date from the client, it will
* normally be in UTC.
* @param boolean $toEas Convert from local to device if true.
* DEFAULT: false
*
* @return Horde_Date The date of the birthday/anniversary, with
* any fixes applied for the current device. The
* timezone set in the object will depend on the
* client detected, and whether the date is being
* encoding or decoding.
*/
public function normalizePoomContactsDates($date, $toEas = false)
{
switch (Horde_String::lower($this->clientType)) {
case self::TYPE_WP:
case 'wp8':
// Legacy. Remove in H6.
// Legacy. Remove in H6.
case 'wp':
// Legacy. Remove in H6.
if ($toEas) {
return new Horde_Date($date->format('Y-m-d'), 'UTC');
} else {
$date = new Horde_Date($date->format('Y-m-d'));
return $date->setTimezone('UTC');
}
case self::TYPE_ANDROID:
// Need to protect against clients that don't send the actual Android
// version in the OS field.
if (stripos($this->deviceType, 'samsung') === 0) {
// Samsung's native Contacts app works differently than stock
// Android, always sending as 00:00:00
if ($toEas) {
return new Horde_Date($date->format('Y-m-d'), 'UTC');
}
$date = new Horde_Date($date->format('Y-m-d'));
return $date->setTimezone('UTC');
}
if ($this->getMajorVersion() >= 4 && $this->getMajorVersion() <= 10) {
if ($toEas) {
return new Horde_Date($date->format('Y-m-d 08:00:00'), 'UTC');
} else {
$date = new Horde_Date($date->format('Y-m-d'));
return $date->setTimezone('UTC');
//.........这里部分代码省略.........
示例15: __get
/**
* Accessor so we can lazy-parse the results.
*
* @param string $property The property name.
*
* @return mixed The value of requested property
* @throws Horde_Service_Weather_Exception_InvalidProperty
*/
public function __get($property)
{
switch ($property) {
case 'is_pm':
// Wunderground only supports standard
return false;
case 'hour':
// Wunderground supports this, but we don't.
return false;
case 'date':
$date = new Horde_Date(array('year' => $this->_properties['date']->year, 'month' => $this->_properties['date']->month, 'mday' => $this->_properties['date']->day));
$date->hour = $this->_properties['date']->hour;
$date->min = $this->_properties['date']->min;
$date->setTimezone($this->_properties['date']->tz_long);
return $date;
case 'high':
if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
return $this->_properties['high']->fahrenheit !== '' ? $this->_properties['high']->fahrenheit : Horde_Service_Weather_Translation::t("N/A");
}
return $this->_properties['high']->celsius;
case 'low':
if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
return $this->_properties['low']->fahrenheit !== '' ? $this->_properties['low']->fahrenheit : Horde_Service_Weather_Translation::t("N/A");
}
return $this->_properties['low']->celsius;
case 'icon':
return $this->_forecast->weather->iconMap[$this->_properties['icon']];
case 'wind_direction':
return strlen($this->_properties['avewind']->dir) ? Horde_Service_Weather_Translation::t($this->_properties['avewind']->dir) : Horde_Service_Weather_Translation::t("N/A");
case 'wind_degrees':
return strlen($this->_properties['avewind']->dir) ? $this->_properties['avewind']->degrees : Horde_Service_Weather_Translation::t("N/A");
case 'wind_speed':
if (strlen($this->_properties['avewind']->dir)) {
if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
return $this->_properties['avewind']->mph;
}
return $this->_properties['avewind']->kph;
} else {
return Horde_Service_Weather_Translation::t("N/A");
}
case 'wind_gust':
if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
return $this->_properties['maxwind']->mph;
}
return $this->_properties['maxwind']->kph;
case 'rain_total':
if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
return $this->_properties['qpf_allday']->in;
}
return $this->_properties['qpf_allday']->mm;
case 'snow_total':
if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
return $this->_properties['snow_allday']->in;
}
return $this->_properties['snow_allday']->cm;
default:
if (!empty($this->_map[$property])) {
return Horde_Service_Weather_Translation::t($this->_properties[$this->_map[$property]]);
}
throw new Horde_Service_Weather_Exception_InvalidProperty('This provider does not support the "' . $property . '" property');
}
}