Пример #1
0
 /** Diff two date objects. Only full units are returned */
 public static function diff(TimeInterval $interval, Date $date1, Date $date2) : int
 {
     if ($date1->getOffsetInSeconds() != $date2->getOffsetInSeconds()) {
         // Convert date2 to same timezone as date1. To work around PHP bug #45038,
         // not just take the timezone of date1, but construct a new one which will
         // have a timezone ID - which is required for this kind of computation.
         $tz = new TimeZone(timezone_name_from_abbr('', $date1->getOffsetInSeconds(), $date1->toString('I')));
         // Now, convert both dates to the same time (actually we only need to convert the
         // second one, as the first will remain in the same timezone)
         $date2 = $tz->translate($date2);
     }
     // Then cut off timezone, by setting both to GMT
     $date1 = DateUtil::setTimeZone($date1, new TimeZone('GMT'));
     $date2 = DateUtil::setTimeZone($date2, new TimeZone('GMT'));
     switch ($interval) {
         case TimeInterval::$YEAR:
             return -($date1->getYear() - $date2->getYear());
         case TimeInterval::$MONTH:
             return -(($date1->getYear() - $date2->getYear()) * 12 + ($date1->getMonth() - $date2->getMonth()));
         case TimeInterval::$DAY:
             return -(intval($date1->getTime() / 86400) - intval($date2->getTime() / 86400));
         case TimeInterval::$HOURS:
             return -(intval($date1->getTime() / 3600) - intval($date2->getTime() / 3600));
         case TimeInterval::$MINUTES:
             return -(intval($date1->getTime() / 60) - intval($date2->getTime() / 60));
         case TimeInterval::$SECONDS:
             return -($date1->getTime() - $date2->getTime());
     }
 }
Пример #2
0
    protected function sendFixDateMail($user, $foodle)
    {
        if (!$this->user->notification('invite', TRUE)) {
            error_log('Foodle response was added, but mail notification was not sent because of users preferences');
            return;
        }
        error_log('Sending Foodle fixdate to ' . $user->email);
        $profileurl = FoodleUtils::getUrl() . 'profile/';
        $url = FoodleUtils::getUrl() . 'foodle/' . $foodle->identifier;
        $name = 'Date and time set for ' . $foodle->name;
        if (empty($user->email)) {
            error_log('Was not able to send e-mail notification to ' . $user->userid . ' because email address was missing');
            return;
        }
        $to = $user->email;
        //		$to = '*****@*****.**';
        $datetimetext = '';
        $extralinks = '';
        if (!empty($foodle->datetime)) {
            $tz = new TimeZone($this->db, NULL, $user);
            $icalurl = FoodleUtils::getUrl() . 'foodle/' . $foodle->identifier . '?output=ical';
            $datetimetext = "\n\n### Date and time\n\n" . $foodle->datetimeText($tz->getTimeZone());
            $extralinks = "\n* Import to your calendar using the attached calendar file";
        }
        $mail = $foodle->descr . '

### Confirm your participation

* [Please confirm your participation on this event](' . $url . ')
* [View confirmation of other participants](' . $url . '#responses)' . $extralinks . '

' . $datetimetext . '

### Did you know

You may also create new Foodles on your own, and invite others to respond.

* [Go to Foodl.org to create a new Foodle.](http://foodl.org)

		';
        $mailer = new Foodle_EMail($to, htmlspecialchars($name), 'Foodl.org <*****@*****.**>');
        $mailer->setBody($mail);
        if (!empty($foodle->datetime)) {
            $url = FoodleUtils::getUrl() . 'foodle/' . $foodle->identifier . '?output=ical';
            $ics = file_get_contents($url);
            $mailer->send(array(array('data' => $ics, 'file' => 'foodl-invitation.ics', 'type' => 'calendar/text')));
        } else {
            $mailer->send();
        }
    }
Пример #3
0
 /**
  *    Convert a date from Excel to PHP
  *
  *    @param        integer        $dateValue            Excel date/time value
  *    @param        boolean        $adjustToTimezone    Flag indicating whether $dateValue should be treated as
  *                                                    a UST timestamp, or adjusted to UST
  *    @param        string         $timezone            The timezone for finding the adjustment from UST
  *    @return       integer        PHP serialized date/time
  */
 public static function excelToPHP($dateValue = 0, $adjustToTimezone = false, $timezone = null)
 {
     if (self::$excelBaseDate == self::CALENDAR_WINDOWS_1900) {
         $myexcelBaseDate = 25569;
         //    Adjust for the spurious 29-Feb-1900 (Day 60)
         if ($dateValue < 60) {
             --$myexcelBaseDate;
         }
     } else {
         $myexcelBaseDate = 24107;
     }
     // Perform conversion
     if ($dateValue >= 1) {
         $utcDays = $dateValue - $myexcelBaseDate;
         $returnValue = round($utcDays * 86400);
         if ($returnValue <= PHP_INT_MAX && $returnValue >= -PHP_INT_MAX) {
             $returnValue = (int) $returnValue;
         }
     } else {
         $hours = round($dateValue * 24);
         $mins = round($dateValue * 1440) - round($hours * 60);
         $secs = round($dateValue * 86400) - round($hours * 3600) - round($mins * 60);
         $returnValue = (int) gmmktime($hours, $mins, $secs);
     }
     $timezoneAdjustment = $adjustToTimezone ? TimeZone::getTimezoneAdjustment($timezone, $returnValue) : 0;
     return $returnValue + $timezoneAdjustment;
 }
Пример #4
0
 /**
  * undocumented function
  *
  * @param unknown $groups
  * @param unknown $includeOffset
  * @return void
  * @access public
  */
 static function listByGroups($groups = array(), $includeOffset = true)
 {
     if (empty($groups)) {
         $groups = TimeZone::listGroups();
     }
     $allZones = DateTimeZone::listIdentifiers();
     $listZones = array();
     foreach ($allZones as $zone) {
         @(list($group, $city) = explode('/', $zone));
         if (!in_array($group, $groups)) {
         } elseif ($includeOffset) {
             $offset = TimeZone::offset($zone);
             $sign = $offset < 0 ? '-' : '+';
             $offset = date('H:i', mktime(0, 0, abs($offset)));
             $listZones[$group][] = $city . ' (GMT ' . $sign . $offset . ')';
         }
     }
     foreach ($listZones as $group => $data) {
         $listZones[$group] = array_unique($listZones[$group]);
     }
     return $listZones;
 }
Пример #5
0
 /**
  * @inheritdoc
  */
 public function __get($property)
 {
     if (strpos($property, 'as_') === 0) {
         return $this->{'format_' . $property}();
     }
     switch ($property) {
         case 'timestamp':
             return $this->getTimestamp();
         case 'year':
             return (int) $this->format('Y');
         case 'quarter':
             return floor(($this->month - 1) / 3) + 1;
         case 'month':
             return (int) $this->format('m');
         case 'week':
             return (int) $this->format('W');
         case 'year_day':
             return (int) $this->format('z') + 1;
         case 'weekday':
             return (int) $this->format('w') ?: 7;
         case 'day':
             return (int) $this->format('d');
         case 'hour':
             return (int) $this->format('H');
         case 'minute':
             return (int) $this->format('i');
         case 'second':
             return (int) $this->format('s');
         case 'is_monday':
             return $this->weekday == 1;
         case 'is_tuesday':
             return $this->weekday == 2;
         case 'is_wednesday':
             return $this->weekday == 3;
         case 'is_thursday':
             return $this->weekday == 4;
         case 'is_friday':
             return $this->weekday == 5;
         case 'is_saturday':
             return $this->weekday == 6;
         case 'is_sunday':
             return $this->weekday == 7;
         case 'is_today':
             $now = new static('now', $this->zone);
             return $this->as_date === $now->as_date;
         case 'is_past':
             return $this < new static('now', $this->zone);
         case 'is_future':
             return $this > new static('now', $this->zone);
         case 'is_empty':
             return $this->year == -1 && $this->month == 11 && $this->day == 30;
         case 'tomorrow':
             $time = clone $this;
             $time->modify('+1 day');
             $time->setTime(0, 0, 0);
             return $time;
         case 'yesterday':
             $time = clone $this;
             $time->modify('-1 day');
             $time->setTime(0, 0, 0);
             return $time;
             /*
              * days
              */
         /*
          * days
          */
         case 'monday':
         case 'tuesday':
         case 'wednesday':
         case 'thursday':
         case 'friday':
         case 'saturday':
         case 'sunday':
             return $this->{'get_' . $property}();
         case 'zone':
             return TimeZone::from($this->getTimezone());
         case 'utc':
         case 'local':
             $time = clone $this;
             $time->setTimezone($property);
             return $time;
         case 'is_utc':
             return $this->zone->name == 'UTC';
         case 'is_local':
             return $this->zone->name == date_default_timezone_get();
         case 'is_dst':
             $timestamp = $this->timestamp;
             $transitions = $this->zone->getTransitions($timestamp, $timestamp);
             return $transitions[0]['isdst'];
     }
     if (class_exists('ICanBoogie\\PropertyNotDefined')) {
         throw new PropertyNotDefined([$property, $this]);
     } else {
         throw new \RuntimeException("Property is not defined: {$property}.");
     }
 }
Пример #6
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return TimeZone the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = TimeZone::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #7
0
<?php

/* @var $this UserController */
/* @var $model User */
$this->breadcrumbs = array('Users' => array('index'), 'Manage');
$this->menu = array(array('label' => 'List User', 'url' => array('index')), array('label' => 'Create User', 'url' => array('create')));
?>

<h1>Manage Users</h1>

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'user-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('fullName', 'user.email', array('name' => 'countryID', 'value' => '$data->country->name', 'filter' => CHtml::ListData(Country::model()->active()->findAll(), 'id', 'name')), array('name' => 'timeZoneID', 'value' => '$data->timeZone->name', 'filter' => CHtml::ListData(TimeZone::model()->active()->findAll(), 'id', 'name')), array('name' => 'user.status', 'value' => '$data->user->statusText', 'filter' => User::$statuses), 'user.createdAt', array('class' => 'CButtonColumn'))));
Пример #8
0
     break;
 case 'widget':
     $page = new Pages_PageWidget($config, $parameters);
     $page->show();
     break;
 case 'rss':
     $page = new Pages_PageRSS($config, $parameters);
     $page->show();
     break;
 case 'embed':
     $embed = new Pages_EmbedFoodle($config, $parameters);
     $embed->getContent($_REQUEST['output']);
     break;
 case 'timezone':
     $db = new FoodleDBConnector($config);
     $timezone = new TimeZone($db);
     $newtimezone = $timezone->getTimezone();
     echo "Timezone is :";
     print var_export($newtimezone, true);
     break;
 case 'mail':
     require 'mail.php';
     break;
 case 'accountmapping':
     $page = new Pages_PageAccountMapping($config, $parameters);
     $page->show();
     break;
 case 'accountmappingprepare':
     $page = new Pages_PageAccountMappingPrepare($config, $parameters);
     $page->show();
     break;
Пример #9
0
 /**
  * Move a date to a given timezone. Does not modify the date's
  * actual value.
  *
  * @param   util.Date date
  * @param   util.TimeZone tz
  * @return  util.Date
  */
 public static function moveToTimezone(Date $date, TimeZone $tz)
 {
     return $tz->translate($date);
 }
Пример #10
0
 /**
  * @covers Marando\AstroDate\TimeZone::__toString
  */
 public function test__toString()
 {
     $mst = TimeZone::parse('mst');
     $this->assertEquals('MST', $mst->name);
 }
Пример #11
0
 /**
  * PointChannels::Load()
  *
  * @param mixed $userId
  * @param mixed $domainId
  * @return
  */
 function Load($userId, $domainId, $pointType = '', $participationType = '', $siftByResource = false, $rapMonth = false, $rapYear = false)
 {
     //echo "In PointChannels->Load(...)...<br>\n";
     $participationTypeClause = $participationType != '' ? " and pat.ParticipationTypeID = {$participationType} " : '';
     $pointTypeClause = $pointType != '' ? " and ptypes.PointTypeName = '{$pointType}' " : " and not ptypes.PointTypeName = 'Resource' ";
     $resourceSort = $siftByResource ? " rappc.ChannelDescription, " : '';
     $resourceClause = $siftByResource ? " and rap.AssetObjectID = pc.ObjectID\n and rap.AssetChannelID = pc.ChannelID\n and rap.ResourceObjectID = rappc.ObjectID \n " : '';
     $resourceTable = $siftByResource ? ", mdr.t_resourceassetprofiles rap, mdr.t_pointchannels rappc " : '';
     $resourceFields = $siftByResource ? ", rappc.ChannelDescription ResourceDescription, rap.AssetObjectID,  rap.AssetChannelID, rap.ResourceObjectID " : '';
     $rapDateClause = $rapMonth ? " and rap.EffectiveMonth = '{$rapMonth}' and rap.EffectiveYear = '{$rapYear}'" : '';
     //print $rapDateClause;
     $this->p_userId = $userId;
     $this->p_domainId = $domainId;
     $sql = "\n            SELECT DISTINCT\n                pc.*,\n                pn.ReadTimeOffset,\n                pn.ReadInterval,\n                t.TimeZoneID,\n                t.TimeZoneName,\n                t.TimeZoneDescription,\n                t.IsDstActive,\n                t.StdAbbreviation,\n                t.StdDescription,\n                t.StdOffset,\n                t.StdMonth,\n                t.StdWeek,\n                t.StdDay,\n                t.StdHour,\n                t.DstAbbreviation,\n                t.DstDescription,\n                t.DstOffset,\n                t.DstMonth,\n                t.DstWeek,\n                t.DstDay,\n                t.DstHour,\n                zo.ObjectDescription Zone,\n                pat.ParticipationTypeID,\n                pat.ParticipationTypeDescription,\n                pcppp.CommittedReduction,\n                rp.PriceID RealTimePriceID,\n                rp.PriceDescription RealTimePriceDescription,\n                hp.PriceID HourlyPriceID,\n                hp.PriceDescription HourlyPriceDescription {$resourceFields}\n            FROM\n                mdr.t_objectxrefs dgox,\n                mdr.t_objecttypes got,\n                mdr.t_objects go,\n                mdr.t_objectxrefs ugox,\n                mdr.t_actorprivilegexrefs gpx,\n                mdr.t_actorprivilegexrefs dpx,\n                mdr.t_privileges p,\n                mdr.t_privilegetypes pt,\n                mdr.t_points pn,\n                mdr.t_timezones t,\n                mdr.t_objects po,\n                mdr.t_pointchannels pc,\n                mdr.t_objectxrefs pzox,\n                mdr.t_objects zo,\n                mdr.t_zones z,\n                mdr.t_pointchannelprogramparticipationprofiles pcppp,\n                mdr.t_participationtypes pat,\n                mdr.t_pricelocations pl,\n                mdr.t_pricecomponents pco,\n                mdr.t_pricetypes rpt,\n                mdr.t_pricetypes hpt,\n                mdr.t_prices rp,\n                mdr.t_prices hp,\n                mdr.t_pointtypes ptypes {$resourceTable}\n            WHERE\n                got.ObjectTypeName = 'Group' and\n                go.ObjectTypeID = got.ObjectTypeID and\n                dgox.ChildObjectID = go.ObjectID and\n                dgox.ParentObjectID = {$this->p_domainId} and\n                ugox.ParentObjectID = dgox.ChildObjectID and\n                ugox.ChildObjectID = {$this->p_userId}  and\n                gpx.ObjectID = ugox.ParentObjectID and\n                dpx.ObjectID = dgox.ParentObjectID and\n                gpx.PrivilegeID = dpx.PrivilegeID and\n                p.PrivilegeID = gpx.PrivilegeID and\n                pt.PrivilegeTypeID = p.PrivilegeTypeID and\n                pt.PrivilegeTypeName = 'Read' and\n                po.ObjectID = p.ObjectID and\n                pn.ObjectID = po.ObjectID and\n                t.TimeZoneID = pn.TimeZoneID and\n                po.IsInactive = 0 and\n                pn.IsEnabled = 1 and\n                pc.ObjectID = pn.ObjectID and\n                pc.IsEnabled = 1 and\n                pc.IsPlotable = 1 and\n                pzox.ChildObjectID = pn.ObjectID and\n                zo.ObjectID = pzox.ParentObjectID and\n                z.ObjectID = zo.ObjectID and\n                pcppp.PointObjectID = p.ObjectID and\n                pat.ParticipationTypeID = pcppp.ParticipationTypeID and\n                pco.PriceComponentName = 'LBMP' and\n                pl.ZoneObjectID = z.ObjectID and\n                rpt.PriceTypeName = 'RealTimePrice' and\n                rp.PriceTypeID = rpt.PriceTypeID and\n                rp.PriceLocationID = pl.PriceLocationID and\n                rp.PriceComponentID = pco.PriceComponentID and\n                hpt.PriceTypeName = 'HourlyPrice' and\n                hp.PriceTypeID = hpt.PriceTypeID and\n                hp.PriceLocationID = pl.PriceLocationID and\n                hp.PriceComponentID = pco.PriceComponentID and\n                ptypes.PointTypeID = pn.PointTypeID {$participationTypeClause} {$resourceClause} {$pointTypeClause} {$rapDateClause} \n            ORDER BY\n                {$resourceSort}\n                pc.ChannelDescription\n            ";
     //$this->preDebugger($sql);
     $result = mysql_query($sql, $this->sqlConnection());
     //echo mysql_num_rows($result);
     if (mysql_num_rows($result) > 0) {
         while ($row = mysql_fetch_array($result)) {
             //$this->preDebugger($row);
             if ($siftByResource) {
                 $this->p_resources[$row['ResourceObjectID']]['description'] = $row['ResourceDescription'];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['id'] = $row["ObjectID"];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['channelId'] = $row["ChannelID"];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['description'] = $row["ChannelDescription"];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['programId'] = $row["ParticipationTypeID"];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['programDescription'] = $row["ParticipationTypeDescription"];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['assetIdentifier'] = $row["AssetIdentifier"];
             } else {
                 $inx = $this->p_length++;
                 //inx has no meaning in the new context -- just using it to hold things together right now.
                 $uom = new UnitOfMeasure();
                 $uom->Load($row["UnitOfMeasureID"]);
                 $dluom = new UnitOfMeasure();
                 $dluom->Load($row["DrawLimitUnitOfMeasureID"]);
                 $pointChannel = new PointChannel($row["ObjectID"], $row["ChannelID"], $row["ChannelName"], $row["ChannelDescription"], $uom, $row["PulseConversionFactor"], $row["DrawLimit"], $dluom, $row["IsGenerator"], $row["AssetIdentifier"]);
                 $this->p_pointChannel[$inx] = clone $pointChannel;
                 $this->p_pcMap[$pointChannel->objectId()][$pointChannel->channelId()] = $inx;
                 //$this->preDebugger($pointChannel);
                 /*
                             print '<pre style="color: red;">';
                             echo "pointChannel='" . $this->p_pointChannel[$inx]->objectId() . "', '" . $this->p_pointChannel[$inx]->channelId() . "'<br>\n";
                             echo "index='" . $this->p_pcMap[$pointChannel->objectId()][$pointChannel->channelId()] . "'<br>\n";
                             print '</pre>';
                 */
                 if (!isset($this->p_meterPoint[$pointChannel->objectId()])) {
                     $this->p_meterPoint[$pointChannel->objectId()] = new MeterPoint();
                     $this->p_meterPoint[$pointChannel->objectId()]->id($pointChannel->objectId());
                     $this->p_meterPoint[$pointChannel->objectId()]->readTimeOffset($row["ReadTimeOffset"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->readInterval($row["ReadInterval"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->zone($row["Zone"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->committedReduction($row["CommittedReduction"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->participationTypeID($row["ParticipationTypeID"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->participationTypeDescription($row["ParticipationTypeDescription"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->displayPriceId($row["RealTimePriceID"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->displayPriceDescription($row["RealTimePriceDescription"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->settlementPriceId($row["HourlyPriceID"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->settlementPriceDescription($row["HourlyPriceDescription"]);
                     $this->p_participationTypeList[$row["ParticipationTypeID"]] = $row["ParticipationTypeDescription"];
                     $timeZone = new TimeZone();
                     $timeZone->id($row["TimeZoneID"]);
                     $timeZone->name($row["TimeZoneName"]);
                     $timeZone->description($row["TimeZoneDescription"]);
                     $timeZone->isDstActive($row["IsDstActive"]);
                     $timeZone->stdAbbreviation($row["StdAbbreviation"]);
                     $timeZone->stdDescription($row["StdDescription"]);
                     $timeZone->stdOffset($row["StdOffset"]);
                     $timeZone->stdMonth($row["StdMonth"]);
                     $timeZone->stdWeek($row["StdWeek"]);
                     $timeZone->stdDay($row["StdDay"]);
                     $timeZone->stdHour($row["StdHour"]);
                     $timeZone->dstAbbreviation($row["DstAbbreviation"]);
                     $timeZone->dstDescription($row["DstDescription"]);
                     $timeZone->dstOffset($row["DstOffset"]);
                     $timeZone->dstMonth($row["DstMonth"]);
                     $timeZone->dstWeek($row["DstWeek"]);
                     $timeZone->dstDay($row["DstDay"]);
                     $timeZone->dstHour($row["DstHour"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->timeZone($timeZone);
                 }
                 $this->p_pointChannel[$inx]->meterPoint($this->p_meterPoint[$pointChannel->objectId()]);
             }
             //print_r($this->p_resource);
         }
         // end while
     } else {
         $this->p_resources = false;
     }
     //end if
 }
Пример #12
0
 /**
  * Sets the system default time zone to the time zone in $id
  *
  * Sets the system default time zone to the time zone in $id
  *
  * @access public
  * @param string $id
  *        	the time zone id to use
  */
 static function setDefault($id)
 {
     if (TimeZone::isValidID($id)) {
         $GLOBALS['_DATE_TIMEZONE_DEFAULT'] = $id;
     }
 }
Пример #13
0
 /**
  * Answer the Time Zone that corresponds to our offset.
  * 
  * @return object TimeZone
  * @access public
  * @since 5/10/05
  */
 function timeZone()
 {
     // Search through the array of timezones for one that matches. Otherwise,
     // build our own. The name and abbreviation are just a guess, as multiple
     // Time Zones have the same offset.
     $zoneArray = TimeZone::timeZones();
     foreach (array_keys($zoneArray) as $key) {
         if ($this->offset->isEqualTo($zoneArray[$key]->offset())) {
             return $zoneArray[$key];
         }
     }
     $obj = TimeZone::offsetNameAbbreviation($this->offset, $tzAbbreviation, $tzAbbreviation);
     return $obj;
 }
 public function issueWithGetterAndDate()
 {
     $this->assertEquals('{ "issueId" : 1 , "title" : "New issue" , "createdAt" : "2012-03-19T08:37:00+00:00" }', $this->fixture->serialize(new net·xp_framework·unittest·webservices·rest·IssueWithGetter(1, 'New issue', new Date('2012-03-19 08:37:00', TimeZone::getByName('GMT')))));
 }
Пример #15
0
 /**
  * Return an Array of TimeZones
  * 
  * @return array
  * @access public
  * @since 5/3/05
  * @static
  */
 static function timeZones()
 {
     $array = array(TimeZone::offsetNameAbbreviation(Duration::withHours(0), 'Universal Time', 'UTC'), TimeZone::offsetNameAbbreviation(Duration::withHours(0), 'Greenwich Mean Time', 'GMT'), TimeZone::offsetNameAbbreviation(Duration::withHours(0), 'British Summer Time', 'BST'), TimeZone::offsetNameAbbreviation(Duration::withHours(-5), 'Eastern Standard Time', 'EST'), TimeZone::offsetNameAbbreviation(Duration::withHours(-4), 'Eastern Daylight Time', 'EDT'), TimeZone::offsetNameAbbreviation(Duration::withHours(-6), 'Central Standard Time', 'CST'), TimeZone::offsetNameAbbreviation(Duration::withHours(-5), 'Central Daylight Time', 'CDT'), TimeZone::offsetNameAbbreviation(Duration::withHours(-7), 'Mountain Standard Time', 'MST'), TimeZone::offsetNameAbbreviation(Duration::withHours(-6), 'Mountain Daylight Time', 'MDT'), TimeZone::offsetNameAbbreviation(Duration::withHours(-8), 'Pacific Standard Time', 'PST'), TimeZone::offsetNameAbbreviation(Duration::withHours(-7), 'Pacific Daylight Time', 'PDT'));
     return $array;
 }
 public function issueWithGetterAndDate()
 {
     $this->assertXmlEquals('<root><issueId>1</issueId><title>New issue</title><createdAt>2012-03-19T08:37:00+00:00</createdAt></root>', $this->fixture->serialize(new net·xp_framework·unittest·webservices·rest·IssueWithGetter(1, 'New issue', new Date('2012-03-19 08:37:00', TimeZone::getByName('GMT')))));
 }
Пример #17
0
 /**
  * Write response headers
  *
  * @param  scriptlet.Response response
  * @param  peer.URL base
  * @param  string format
  */
 protected function writeHead($response, $base, $format)
 {
     $response->setContentType($this->mediaType);
     if (NULL !== $this->contentLength) {
         $response->setContentLength($this->contentLength);
     }
     if (NULL !== $this->lastModified) {
         $response->setHeader('Last-Modified', TimeZone::getByName('GMT')->translate($this->lastModified)->toString('D, d M Y H:i:s \\G\\M\\T'));
     }
 }
Пример #18
0
 /**
  * Format a date by the given strftime()-like format string.
  *
  * These format tokens are not supported intentionally:
  * %a, %A, %b, %B, %c, %h, %p, %U, %x, %X
  *
  * @see     php://strftime
  * @param   string format
  * @param   util.TimeZone outtz default NULL
  * @return  string
  * @throws  lang.IllegalArgumentException if unsupported token has been given
  */
 public function format($format, TimeZone $outtz = NULL)
 {
     return preg_replace_callback('#%([a-zA-Z%])#', array($outtz === NULL ? $this : $outtz->translate($this), 'formatCallback'), $format);
 }
Пример #19
0
echo $form->labelEx($user->profile, 'countryID');
?>
        <?php 
echo $form->dropDownList($user->profile, 'countryID', CHtml::listData(Country::model()->active()->findAll(), 'id', 'name'));
?>
        <?php 
echo $form->error($user->profile, 'countryID');
?>
    </div>

    <div class="row">
        <?php 
echo $form->labelEx($user->profile, 'timeZoneID');
?>
        <?php 
echo $form->dropDownList($user->profile, 'timeZoneID', CHtml::listData(TimeZone::model()->active()->findAll(), 'id', 'name'));
?>
        <?php 
echo $form->error($user->profile, 'timeZoneID');
?>
    </div>

    <div class="row buttons">
        <?php 
echo CHtml::submitButton($user->isNewRecord ? 'Create' : 'Save');
?>
    </div>

    <?php 
$this->endWidget();
?>
Пример #20
0
 public function updateData($from)
 {
     $this->userid = strtolower($this->userid);
     $from->userid = strtolower($from->userid);
     if ($this->userid !== $from->userid) {
         throw new Exception('Trying to update user with a mismatching user id');
     }
     $modified = FALSE;
     if (!empty($from->username)) {
         if ($this->username !== $from->username) {
             // error_log('username from [' . $this->username. '] to [' . $from->username . ']');
             $modified = TRUE;
         }
         $this->username = $from->username;
     }
     if (!empty($from->email)) {
         if ($this->email !== $from->email) {
             // error_log('email from [' . $this->email. '] to [' . $from->email . ']');
             $modified = TRUE;
         }
         $this->email = $from->email;
     }
     if (!empty($from->org)) {
         if ($this->org !== $from->org) {
             // error_log('org from [' . $this->org. '] to [' . $from->org . ']');
             $modified = TRUE;
         }
         $this->org = $from->org;
     }
     if (!empty($from->orgunit)) {
         if ($this->orgunit !== $from->orgunit) {
             // error_log('orgunit from [' . $this->orgunit. '] to [' . $from->orgunit . ']');
             $modified = TRUE;
         }
         $this->orgunit = $from->orgunit;
     }
     if (!empty($from->location)) {
         if ($this->location !== $from->location) {
             // error_log('location from [' . $this->location. '] to [' . $from->location . ']');
             $modified = TRUE;
         }
         $this->location = $from->location;
     }
     if (!empty($from->realm)) {
         if ($this->realm !== $from->realm) {
             // error_log('Realm from [' . $this->realm. '] to [' . $from->realm . ']');
             $modified = TRUE;
         }
         $this->realm = $from->realm;
     }
     if (!empty($from->idp)) {
         if ($this->idp !== $from->idp) {
             // error_log('IdP entityid from [' . $this->idp. '] to [' . $from->idp . ']');
             $modified = TRUE;
         }
         $this->idp = $from->idp;
     }
     if (!empty($from->auth)) {
         if ($this->auth !== $from->auth) {
             // error_log('auth from [' . $this->auth. '] to [' . $from->auth . ']');
             $modified = TRUE;
         }
         $this->auth = $from->auth;
     }
     if (!empty($from->photol)) {
         if ($this->photol !== $from->photol) {
             // error_log('photo url from [' . $this->photol. '] to [' . $from->photol . ']');
             $modified = TRUE;
         }
         $this->photol = $from->photol;
     }
     // Calendar requires some special processing...
     if ($from->hasCalendar()) {
         $before = $this->getCalendar();
         $this->setCalendarsExternal($from->getCalendarURLs('external'));
         $after = $this->getCalendar();
         if ($before !== $after) {
             // error_log('Calendar from [' . var_export($before, TRUE). '] to [' . var_export($after, TRUE) . ']');
             $modified = TRUE;
         }
     }
     if (empty($this->timezone)) {
         $timezone = new TimeZone($this->db, NULL, $this);
         $newtimezone = $timezone->getTimezone();
         if (!empty($newtimezone)) {
             $this->timezone = $newtimezone;
             // error_log('User had no timezone set. Setting to [' . $newtimezone. ']');
             $modified = TRUE;
         }
     }
     #		echo '<pre>'; print_r($from); exit;
     #		// error_log('User set..');
     // TODO: photos
     // TODO: Calendar check...
     // Timezone not updated.
     // features and notidfications not updated.
     // Language is not updated...
     return $modified;
 }
 /**
  * Create record in USERS collection
  *
  * @return object $this
  *
  */
 protected function createNewUser()
 {
     $tzo = Cookie::get('tzo', 0);
     $username = $this->makeUsername($this->aGfcData['displayName']);
     /**
      * Create new record in USERS collection
      * do this first because we need uid from
      * newly created record
      *
      */
     $aUser = array('fn' => $this->aGfcData['displayName'], 'avatar_external' => $this->aGfcData['thumbnailUrl'], 'i_reg_ts' => time(), 'date_reg' => date('r'), 'username' => $username, 'username_lc' => \mb_strtolower($username), 'role' => 'external_auth', 'lang' => $this->Registry->getCurrentLang(), 'locale' => $this->Registry->Locale->getLocale(), 'fcauth' => $this->fcauth, 'tz' => TimeZone::getTZbyoffset($tzo), 'i_pp' => 1, 'i_fv' => false !== ($intFv = Cookie::getSidCookie(true)) ? $intFv : time());
     $aUser = array_merge($this->Registry->Geo->Location->data, $aUser);
     d('aUser: '******'s a newsly registered user
      * and ask the user to provide email address but only
      * during the same session
      *
      * @todo this does not really work right now
      * because newUser field is not included in serialization
      * of user object, thus it's not saved
      * when session is serialized
      * This may change if serialize()/unserialize() methods are
      * modified in User class
      */
     $this->User->setNewUser();
     $this->User->save();
     $this->Registry->Dispatcher->post($this->User, 'onNewUser');
     $this->Registry->Dispatcher->post($this->User, 'onNewGfcUser');
     /**
      * Create new record in USERS_GFC
      */
     $this->updateGfcUserRecord();
     PostRegistration::createReferrerRecord($this->Registry, $this->User);
     return $this;
 }
Пример #22
0
<?php

/* @var $this CountryController */
/* @var $model Country */
$this->breadcrumbs = array('Countries' => array('index'), 'Manage');
$this->menu = array(array('label' => 'List Country', 'url' => array('index')), array('label' => 'Create Country', 'url' => array('create')));
?>

<h1>Manage Countries</h1>

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'country-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('name', array('name' => 'userCount', 'filter' => false), array('name' => 'timeZoneID', 'value' => '$data->timeZone->name', 'filter' => CHtml::listData(TimeZone::model()->active()->findAll(), 'id', 'name')), array('name' => 'status', 'value' => '$data->statusText', 'filter' => Country::$statuses), array('class' => 'CButtonColumn'))));