コード例 #1
0
ファイル: amr-rrule.php プロジェクト: greg3560/plailly
function amr_process_RRULE($p, $start, $astart, $aend, $limit)
{
    /* RRULE a parsed array.  If the specified event repeats between the given start and
     * end times, return one or more nonrepeating date strings in array
     */
    global $amr_wkst, $amr_timeperiod_conv;
    /* converts daily to day etc */
    /* now we should have if they are there: $p[freq], $p[interval, $until, $wkst, $ count, $byweekno etc */
    /* check  / set limits  NB don't forget the distinction between the two kinds of limits  */
    $tz = date_timezone_get($start);
    if (isset($_GET['rdebug'])) {
        echo '<br />&nbsp;start=' . $start->format('c') . ' <br />astart=' . $astart->format('c') . '<br /> parameter passed: ';
        if (is_array($p)) {
            foreach ($p as $k => $i) {
                echo $k . ' ';
                if (is_object($i)) {
                    echo $i->format('c');
                } else {
                    print_r($i);
                }
                echo '<br />';
            }
        } else {
            echo '<br />rule passed';
            var_dump($p);
        }
    }
    if (!isset($p['COUNT'])) {
        $count = AMR_MAX_REPEATS;
    } else {
        $count = $p['COUNT'];
    }
    if (isset($_GET['cdebug'])) {
        echo '<br />Limiting the repeats to ' . $count;
    }
    $until = amr_newDateTime();
    $original_until = amr_newDateTime();
    if (!isset($p['UNTIL'])) {
        $until = clone $aend;
        $original_until = clone $aend;
    } else {
        $until = clone $p['UNTIL'];
        $original_until = clone $p['UNTIL'];
        if ($until > $aend) {
            $until = clone $aend;
        }
    }
    // 2014 07 09
    $original_start = amr_newDateTime();
    $original_start = clone $start;
    $next_start = amr_newDateTime();
    $next_start = clone $start;
    if (amr_is_before($until, $astart)) {
        return false;
    }
    /* if it ends before our overall start, then skip */
    /* now prepare out "intervals array for date incrementing eg: p[monthly] = 2 etc... Actualy there should only be 1 */
    if (isset($p['FREQ'])) {
        /* so know yearly, daily or weekly etc  - setup increments eg 2 yearsly or what */
        if (!isset($p['INTERVAL'])) {
            $p['INTERVAL'] = 1;
        }
        switch ($p['FREQ']) {
            case 'WEEKLY':
                $int['day'] = $p['INTERVAL'] * 7;
                break;
            default:
                $inttype = $amr_timeperiod_conv[$p['FREQ']];
                $int[$inttype] = $p['INTERVAL'];
        }
        $freq = $p['FREQ'];
    }
    /*  use the freq increment to get close to our listing start time.  If we are within one freq of our listing start, we should be safe in calculating the odd rrules. */
    /* NOTE we can only do this if we do not have the count or a bysetpos !!!!   */
    //	if (empty($int)) var_dump($p);
    if (empty($p['COUNT']) and empty($p['BYSETPOS']) and !empty($int)) {
        $next_start = amr_get_a_closer_start($next_start, $astart, $int);
    }
    // 20110301 the nbydays, especially the negs, require that one initially consider a wider valid range so as not to unintentionally exclude a date before the expand/contract has beeen applied .  Ie we might iterate to 28th and exclude, but actually once one has applied the -2Mo or some such rule, the date would have contracted into the valid range.  So apply restrictions later.
    $until = amr_increment_datetime($until, $int);
    unset($p['UNTIL']);
    /* unset so we can use other params more cleanly, we have count saved etc */
    unset($p['COUNT']);
    unset($p['FREQ']);
    unset($p['INTERVAL']);
    if (!empty($p['WKST'])) {
        $wkst = $p['WKST'];
        unset($p['WKST']);
    } else {
        $wkst = $amr_wkst;
    }
    if (count($p) === 0) {
        $p = null;
    }
    /* If that was all we had, get rid of it anyway */
    if (isset($p['NBYDAY'])) {
        /* if we separated these in the parsing process, merge them here,    NOOO - will cause problems with the +1's and bool */
        if (isset($p['BYDAY'])) {
            $p['BYDAY'] = array_merge($p['NBYDAY'], $p['BYDAY']);
        } else {
            $p['BYDAY'] = $p['NBYDAY'];
        }
        unset($p['NBYDAY']);
    }
    while ($next_start <= $until) {
        /* don't check astart here - may miss some */
        $datearray[] = amr_get_date_parts($next_start);
        if (isset($_GET['rdebug'])) {
            echo '<hr>Checked start against extra until (1 extra iteration to allow for negativebydays) etc ' . $next_start->format('c') . ' ' . $until->format('c');
            echo '<br />date array = ';
            var_dump($datearray);
        }
        switch ($freq) {
            /* the 'bys' are now in an array $p .  NOTE THE sequence here is important */
            case 'SECONDLY':
                if (isset($p['month'])) {
                    $datearray = amr_limit($datearray, $p['month'], 'month');
                }
                /* BYWEEK NO not applicable here */
                if (isset($p['BYYEARDAY'])) {
                    $datearray = amr_limit_by_yearday($datearray, $p['BYYEARDAY'], $tz);
                }
                if (isset($p['day'])) {
                    $datearray = amr_limit($datearray, $p['day'], 'day');
                }
                if (isset($p['BYDAY'])) {
                    $datearray = amr_limit_by_day_of_week($datearray, $p['BYDAY'], $tz);
                }
                //				foreach ($p as $i => $by) amr_limit_dates_withby($dates);
                if (isset($p['hour'])) {
                    $datearray = amr_limit($datearray, $p['hour'], 'hour');
                }
                if (isset($p['minute'])) {
                    $datearray = amr_limit($datearray, $p['minute'], 'minute');
                }
                if (isset($p['second'])) {
                    $datearray = amr_limit($datearray, $p['second'], 'second');
                }
                break;
            case 'MINUTELY':
                if (isset($p['month'])) {
                    $datearray = amr_limit($datearray, $p['month'], 'month');
                }
                /* BYWEEK NO not applicable here */
                if (isset($p['BYYEARDAY'])) {
                    $datearray = amr_limit_by_yearday($datearray, $p['BYYEARDAY'], $tz);
                }
                if (isset($p['day'])) {
                    $datearray = amr_limit($datearray, $p['day'], 'day');
                }
                if (isset($p['BYDAY'])) {
                    $datearray = amr_limit_by_day_of_week($datearray, $p['BYDAY'], $tz);
                }
                if (isset($p['hour'])) {
                    $datearray = amr_limit($datearray, $p['hour'], 'hour');
                }
                if (isset($p['minute'])) {
                    $datearray = amr_limit($datearray, $p['minute'], 'minute');
                }
                if (isset($p['second'])) {
                    $datearray = amr_expand($datearray, $p['second'], 'second', $tz);
                }
                break;
            case 'HOURLY':
                if (isset($p['month'])) {
                    $datearray = amr_limit($datearray, $p['month'], 'month');
                }
                /* BYWEEK NO not applicable here */
                if (isset($p['BYYEARDAY'])) {
                    $datearray = amr_limit_by_yearday($datearray, $p['BYYEARDAY'], $tz);
                }
                if (isset($p['day'])) {
                    $datearray = amr_limit($datearray, $p['day'], 'day');
                }
                if (isset($p['BYDAY'])) {
                    $datearray = amr_limit_by_day_of_week($datearray, $p['BYDAY'], $tz);
                }
                if (isset($p['hour'])) {
                    $datearray = amr_limit($datearray, $p['hour'], 'hour', $tz);
                }
                if (isset($p['minute'])) {
                    $datearray = amr_expand($datearray, $p['minute'], 'minute', $tz);
                }
                if (isset($p['second'])) {
                    $datearray = amr_expand($datearray, $p['second'], 'second', $tz);
                }
                break;
            case 'DAILY':
                if (isset($p['month'])) {
                    $datearray = amr_limit($datearray, $p['month'], 'month');
                }
                /* BYWEEK NO and BYYEARDAY not applicable here */
                if (isset($p['day'])) {
                    $datearray = amr_limit($datearray, $p['day'], 'day');
                }
                if (isset($p['BYDAY'])) {
                    $datearray = amr_limit_by_day_of_week($datearray, $p['BYDAY'], $tz);
                }
                if (isset($p['hour'])) {
                    $datearray = amr_expand($datearray, $p['hour'], 'hour', $tz);
                }
                if (isset($p['minute'])) {
                    $datearray = amr_expand($datearray, $p['minute'], 'minute', $tz);
                }
                if (isset($p['second'])) {
                    $datearray = amr_expand($datearray, $p['second'], 'second', $tz);
                }
                break;
            case 'WEEKLY':
                if (isset($p['month'])) {
                    $datearray = amr_limit($datearray, $p['month'], 'month');
                }
                /* BYWEEK NO and BYYEARDAY and BYMONTH DAY not applicable here */
                if (isset($p['BYDAY'])) {
                    $datearray = amr_expand_by_day_of_week_for_weekly($datearray, $p, $tz, $wkst);
                }
                if (isset($p['hour'])) {
                    $datearray = amr_expand($datearray, $p['hour'], 'hour', $tz);
                }
                if (isset($p['minute'])) {
                    $datearray = amr_expand($datearray, $p['minute'], 'minute', $tz);
                }
                if (isset($p['second'])) {
                    $datearray = amr_expand($datearray, $p['second'], 'second', $tz);
                }
                break;
            case 'MONTHLY':
                if (isset($p['month'])) {
                    $datearray = amr_limit($datearray, $p['month'], 'month');
                }
                /* BYWEEK NO and BYYEARDAY not applicable here */
                if (isset($p['day'])) {
                    $datearray = amr_expand($datearray, $p['day'], 'day', $tz);
                }
                if (isset($p['BYDAY']) or isset($p['NBYDAY'])) {
                    /* as per note 1  on page 44 of http://www.rfc-archive.org/getrfc.php?rfc=5545 */
                    if (isset($p['day'])) {
                        /* BYDAY limits if BYMONTH DAY is present , else a special expand for monthly */
                        $datearray = amr_limit_by_day_of_week($datearray, $p, $tz);
                    } else {
                        $datearray = amr_special_expand_by_day_of_week_and_month_note1($datearray, $p, $tz);
                    }
                }
                if (isset($p['hour'])) {
                    $datearray = amr_expand($datearray, $p['hour'], 'hour', $tz);
                }
                if (isset($p['minute'])) {
                    $datearray = amr_expand($datearray, $p['minute'], 'minute', $tz);
                }
                if (isset($p['second'])) {
                    $datearray = amr_expand($datearray, $p['second'], 'second', $tz);
                }
                break;
            case 'YEARLY':
                if (isset($p['month'])) {
                    $datearray = amr_expand($datearray, $p['month'], 'month', $tz);
                }
                if (isset($p['BYWEEKNO'])) {
                    $datearray = amr_expand_by_weekno($datearray, $p['BYWEEKNO'], $tz);
                }
                if (isset($p['BYYEARDAY'])) {
                    $datearray = amr_expand_by_yearday($datearray, $p['BYYEARDAY'], $tz);
                }
                if (isset($p['day'])) {
                    $datearray = amr_expand($datearray, $p['day'], 'day', $tz);
                }
                if (isset($p['BYDAY'])) {
                    if (isset($p['day']) or isset($p['BYYEARDAY'])) {
                        /*Note 2:  BYDAY limits if BYMONTH DAY or BYYEARDAY  is present */
                        $datearray = amr_limit_by_day_of_week($datearray, $p['BYDAY'], $tz);
                    } else {
                        $datearray = amr_expand_by_day_of_week_for_year($datearray, $p, $tz);
                    }
                }
                //				if (isset($p['NBYDAY'])) {
                //					if (isset($p['day']) or isset($p['BYYEARDAY'])) /*Note 2:  BYDAY limits if BYMONTH DAY or BYYEARDAY  is present */
                //												$datearray = amr_limit_by_day_of_week ($datearray, $p['NBYDAY'],$tz);
                //					else 						$datearray = amr_expand_by_day_of_week_for_year ($datearray, $p,$tz);
                //				}
                if (isset($p['hour'])) {
                    $datearray = amr_expand($datearray, $p['hour'], 'hour', $tz);
                }
                if (isset($p['minute'])) {
                    $datearray = amr_expand($datearray, $p['minute'], 'minute', $tz);
                }
                if (isset($p['second'])) {
                    $datearray = amr_expand($datearray, $p['second'], 'second', $tz);
                }
                break;
        }
        $datearray = amr_sort_date_array($datearray);
        if (isset($_GET['rdebug'])) {
            echo '<br /> We have in date array: ';
            print_r($datearray);
        }
        // There will only be > 1 if there was an expanding BY:
        if (!empty($datearray) and !empty($p['BYSETPOS'])) {
            $datearray = amr_limit_by_setpos($datearray, $p['BYSETPOS']);
            if (isset($_GET['rdebug'])) {
                echo '<br />Selected after bysetpos:';
                print_r($p['BYSETPOS']);
                echo '</br>';
                print_date_array($datearray);
            }
            $datearray = amr_sort_date_array($datearray);
            /* sort again as the set position may have trashed it */
        }
        //		$num_events = count($datearray);
        //		if (isset ($_GET['cdebug'])) {echo '<br />We have '. $num_events.' events.  We want max:'.$count;	}
        //		if ($num_events > $count)  $datearray = array_slice($datearray,0, $count);
        //		if (isset ($_GET['cdebug'])) {echo '<br />Limit date array, now have :'.count($datearray);
        //			echo '<br>From  '.$astart->format('Y m d h:i').' until '.$until->format('Y m d h:i');
        //		}
        if (!empty($datearray)) {
            foreach ($datearray as $d) {
                /* create the date objects  */
                $possdate = amr_create_date_from_parts($d, $tz);
                if (is_object($possdate)) {
                    if (isset($_GET['rdebug'])) {
                        echo '<br>Possdate=' . $possdate->format('Y m d h:i:s');
                    }
                    //					if 	(($possdate <= $until) and ($possdate >= $astart)) {
                    $repeats[] = $possdate;
                    //						if (isset ($_GET['rdebug'])) echo ' - saved';
                }
            }
        }
        unset($datearray);
        /* now get next start */
        $next_start = amr_increment_datetime($next_start, $int);
        if (isset($_GET['rdebug'])) {
            echo '<hr>Next start data after incrementing = ' . $next_start->format('Y m d l h:i:s');
        }
    }
    /* end while*/
    //-----------------------------------------------------------------------
    if (isset($_GET['rdebug'])) {
        echo '<hr>Stop now..checked start against extra until <br>start=' . $next_start->format('c') . '<br>until=' . $until->format('c') . ' the extra until!';
        if ($next_start > $until) {
            echo '<br /><b>php says start > extra until </b>';
        }
    }
    if (!empty($repeats)) {
        $repeats = amr_limit_occurences($repeats, $count);
        foreach ($repeats as $i => $d) {
            /* check if it is within date limits  */
            if (isset($_GET['rdebug'])) {
                echo '<br>*** Check for this rrule - original until. ' . '<br />-------astart = ' . $astart->format('c') . '<br />original start = ' . $original_start->format('c') . '<br />instancedate = ' . $d->format('c') . '<br />originaluntil= ' . $original_until->format('c') . '<br />';
            }
            if (!($d <= $original_until and $d >= $original_start)) {
                //note these are rrule limits, not the overall limits
                unset($repeats[$i]);
                if (isset($_GET['rdebug'])) {
                    echo '<br>Event instance not within rrule limits - <b>removed</b> ' . $d->format('Y m d h:i') . '<br />';
                }
            } else {
                if (isset($_GET['rdebug'])) {
                    echo '<br>Event instance within rrule limits ' . $d->format('Y m d h:i') . '<br />';
                }
            }
        }
    }
    if (isset($_GET['rdebug'])) {
        if (empty($repeats)) {
            echo '<b>No repeats!</b><hr>';
        } else {
            echo '<b>' . count($repeats) . ' repeats before further processing, exclusions etc</b><hr>';
            foreach ($repeats as $i => $r) {
                echo '<br />' . $r->format('c');
            }
            echo '<hr/>Need use debugexc to check exclusion logic';
        }
    }
    if (empty($repeats)) {
        return null;
    }
    return $repeats;
}
コード例 #2
0
ファイル: date_timezone.php プロジェクト: ezoic/hhvm
<?php

date_default_timezone_set("America/Los_Angeles");
var_dump(date_default_timezone_get());
var_dump(date_default_timezone_set("Asia/Shanghai"));
var_dump(date_default_timezone_get());
var_dump(date_default_timezone_set("America/Los_Angeles"));
var_dump(date_default_timezone_get());
$dt = date_create("2008-08-08 12:34:56");
var_dump(timezone_name_get(date_timezone_get($dt)));
$dt = date_create("2008-08-08 12:34:56");
date_timezone_set($dt, timezone_open("Asia/Shanghai"));
var_dump(timezone_name_get(date_timezone_get($dt)));
var_dump(date_format($dt, 'Y-m-d H:i:s'));
var_dump(timezone_name_from_abbr("CET"));
var_dump(timezone_name_from_abbr("", 3600, 0));
$tz = timezone_open("Asia/Shanghai");
var_dump(timezone_name_get($tz));
// Create two timezone objects, one for Taipei (Taiwan) and one for
// Tokyo (Japan)
$dateTimeZoneTaipei = timezone_open("Asia/Taipei");
$dateTimeZoneJapan = timezone_open("Asia/Tokyo");
// Create two DateTime objects that will contain the same Unix timestamp, but
// have different timezones attached to them.
$dateTimeTaipei = date_create("2008-08-08", $dateTimeZoneTaipei);
$dateTimeJapan = date_create("2008-08-08", $dateTimeZoneJapan);
var_dump(date_offset_get($dateTimeTaipei));
var_dump(date_offset_get($dateTimeJapan));
$tz = timezone_open("Asia/Shanghai");
var_dump(timezone_name_get($tz));
$timezone = timezone_open("CET");
コード例 #3
0
<?php

/* Prototype  : DateTimeZone date_timezone_get  ( DateTimeInterface $object  )
 * Description: Return time zone relative to given DateTimeInterface
 * Source code: ext/date/php_date.c
 * Alias to functions: DateTimeInterface::getTimezone
 */
// Set timezone
date_default_timezone_set("Europe/London");
echo "*** Testing date_timezone_get() : error conditions ***\n";
echo "\n-- Testing date_timezone_get() function with zero arguments --\n";
var_dump(date_timezone_get());
echo "\n-- Testing date_timezone_get() function with more than expected no. of arguments --\n";
$datetime = date_create("2009-01-30 17:57:32");
$extra_arg = 99;
var_dump(date_timezone_get($datetime, $extra_arg));
echo "\n-- Testing date_timezone_get() function with an invalid values for \$object argument --\n";
$invalid_obj = new stdClass();
var_dump(date_timezone_get($invalid_obj));
$invalid_obj = 10;
var_dump(date_timezone_get($invalid_obj));
$invalid_obj = null;
var_dump(date_timezone_get($invalid_obj));
?>
===DONE===
コード例 #4
0
<?php

/* Prototype  : public DateTime DateTime::setTimezone  ( DateTimeZone $timezone  )
 * Description: Sets the time zone for the DateTime object
 * Source code: ext/date/php_date.c
 * Alias to functions: date_timezone_set
 */
echo "*** Testing DateTime::setTimezone() : basic functionality ***\n";
//Set the default time zone
date_default_timezone_set("Europe/London");
$datetime = new DateTime("2009-01-30 17:57:32");
echo "Default timezone: " . date_timezone_get($datetime)->getName() . "\n";
$la_time = new DateTimezone("America/Los_Angeles");
$datetime->setTimezone($la_time);
echo "New timezone: " . date_timezone_get($datetime)->getName() . "\n";
?>
===DONE===
コード例 #5
0
<?php

/* Prototype  : DateTime date_timezone_set  ( DateTime $object  , DateTimeZone $timezone  )
 * Description: Sets the time zone for the DateTime object
 * Source code: ext/date/php_date.c
 * Alias to functions: DateTime::setTimezone
 */
echo "*** Testing date_timezone_set() : basic functionality ***\n";
//Set the default time zone
date_default_timezone_set("Europe/London");
$datetime = date_create("2009-01-30 17:57:32");
$tz = date_timezone_get($datetime);
echo "Default timezone: " . timezone_name_get($tz) . "\n";
$datetime = date_create("2009-01-30 22:57:32");
$la_time = timezone_open("America/Los_Angeles");
date_timezone_set($datetime, $la_time);
$tz = date_timezone_get($datetime);
echo "New timezone: " . timezone_name_get($tz) . "\n";
?>
===DONE===
コード例 #6
0
// define some classes
class classWithToString
{
    public function __toString()
    {
        return "Class A object";
    }
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// add arrays
$index_array = array(1, 2, 3);
$assoc_array = array('one' => 1, 'two' => 2);
// resource
$file_handle = fopen(__FILE__, 'r');
//array of values to iterate over
$inputs = array('int 0' => 0, 'int 1' => 1, 'int 12345' => 12345, 'int -12345' => -12345, 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float .5' => 0.5, 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), 'uppercase NULL' => NULL, 'lowercase null' => null, 'lowercase true' => true, 'lowercase false' => false, 'uppercase TRUE' => TRUE, 'uppercase FALSE' => FALSE, 'empty string DQ' => "", 'empty string SQ' => '', 'string DQ' => "string", 'string SQ' => 'string', 'mixed case string' => "sTrInG", 'heredoc' => $heredoc, 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), 'undefined var' => @$undefined_var, 'unset var' => @$unset_var, 'resource' => $file_handle);
foreach ($inputs as $variation => $object) {
    echo "\n-- {$variation} --\n";
    var_dump(date_timezone_get($object));
}
// closing the resource
fclose($file_handle);
?>
===DONE===
コード例 #7
0
ファイル: Calendar.php プロジェクト: CIGIHub/bsia-drupal8
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     // @todo Move to $this->validate()
     if (empty($this->view->rowPlugin) || !$this->hasCalendarRowPlugin()) {
         debug('\\Drupal\\calendar\\Plugin\\views\\style\\CalendarStyle: The calendar row plugin is required when using the calendar style, but it is missing.');
         return;
     }
     if (!($argument = CalendarHelper::getDateArgumentHandler($this->view))) {
         debug('\\Drupal\\calendar\\Plugin\\views\\style\\CalendarStyle: A calendar date argument is required when using the calendar style, but it is missing or is not using the default date.');
         return;
     }
     if (!$argument->validateValue()) {
         if (!$argument->getDateArg()->getValue()) {
             $msg = 'No calendar date argument value was provided.';
         } else {
             $msg = t('The value <strong>@value</strong> is a valid date argument for @granularity', ['@value' => $argument->getDateArg()->getValue(), '@granularity' => $argument->getGranularity()]);
         }
         drupal_set_message($msg, 'error');
         return;
     }
     // Add information from the date argument to the view.
     $this->dateInfo->setGranularity($argument->getGranularity());
     $this->dateInfo->setCalendarType($this->options['calendar_type']);
     $this->dateInfo->setDateArgument($argument->getDateArg());
     $this->dateInfo->setMinYear($argument->getMinDate()->format('Y'));
     $this->dateInfo->setMinMonth($argument->getMinDate()->format('n'));
     $this->dateInfo->setMinDay($argument->getMinDate()->format('j'));
     // @todo We shouldn't use DATETIME_DATE_STORAGE_FORMAT.
     $this->dateInfo->setMinWeek(CalendarHelper::dateWeek(date_format($argument->getMinDate(), DATETIME_DATE_STORAGE_FORMAT)));
     //$this->dateInfo->setRange($argument->options['calendar']['date_range']);
     $this->dateInfo->setMinDate($argument->getMinDate());
     $this->dateInfo->setMaxDate($argument->getMaxDate());
     // @todo implement limit
     //    $this->dateInfo->limit = $argument->limit;
     // @todo What if the display doesn't have a route?
     //$this->dateInfo->url = $this->view->getUrl();
     $this->dateInfo->setForbid(isset($argument->getDateArg()->forbid) ? $argument->getDateArg()->forbid : FALSE);
     // Add calendar style information to the view.
     $this->styleInfo->setCalendarPopup($this->displayHandler->getOption('calendar_popup'));
     $this->styleInfo->setNameSize($this->options['name_size']);
     $this->styleInfo->setMini($this->options['mini']);
     $this->styleInfo->setShowWeekNumbers($this->options['with_weekno']);
     $this->styleInfo->setMultiDayTheme($this->options['multiday_theme']);
     $this->styleInfo->setThemeStyle($this->options['theme_style']);
     $this->styleInfo->setMaxItems($this->options['max_items']);
     $this->styleInfo->setMaxItemsStyle($this->options['max_items_behavior']);
     if (!empty($this->options['groupby_times_custom'])) {
         $this->styleInfo->setGroupByTimes(explode(',', $this->options['groupby_times_custom']));
     } else {
         $this->styleInfo->setGroupByTimes(calendar_groupby_times($this->options['groupby_times']));
     }
     $this->styleInfo->setCustomGroupByField($this->options['groupby_field']);
     // TODO make this an option setting.
     $this->styleInfo->setShowEmptyTimes(!empty($this->options['groupby_times_custom']) ? TRUE : FALSE);
     // Set up parameters for the current view that can be used by the row plugin.
     $display_timezone = date_timezone_get($this->dateInfo->getMinDate());
     $this->dateInfo->setTimezone($display_timezone);
     // @TODO min and max date timezone info shouldn't be stored separately.
     $date = clone $this->dateInfo->getMinDate();
     date_timezone_set($date, $display_timezone);
     //    $this->dateInfo->min_zone_string = date_format($date, DATETIME_DATE_STORAGE_FORMAT);
     $date = clone $this->dateInfo->getMaxDate();
     date_timezone_set($date, $display_timezone);
     //    $this->dateInfo->max_zone_string = date_format($date, DATETIME_DATE_STORAGE_FORMAT);
     // Let views render fields the way it thinks they should look before we
     // start massaging them.
     $this->renderFields($this->view->result);
     // Invoke the row plugin to massage each result row into calendar items.
     // Gather the row items into an array grouped by date and time.
     $items = [];
     foreach ($this->view->result as $row_index => $row) {
         $this->view->row_index = $row_index;
         $events = $this->view->rowPlugin->render($row);
         // @todo Check what comes out here.
         /** @var \Drupal\calendar\CalendarEvent $event_info */
         foreach ($events as $event_info) {
             //        $event->granularity = $this->dateInfo->granularity;
             $item_start = $event_info->getStartDate()->format('Y-m-d');
             $item_end = $event_info->getEndDate()->format('Y-m-d');
             $time_start = $event_info->getStartDate()->format('H:i:s');
             $event_info->setRenderedFields($this->rendered_fields[$row_index]);
             $items[$item_start][$time_start][] = $event_info;
         }
     }
     ksort($items);
     $rows = [];
     $this->currentDay = clone $this->dateInfo->getMinDate();
     $this->items = $items;
     // Retrieve the results array using a the right method for the granularity of the display.
     switch ($this->options['calendar_type']) {
         case 'year':
             $rows = [];
             $this->styleInfo->setMini(TRUE);
             for ($i = 1; $i <= 12; $i++) {
                 $rows[$i] = $this->calendarBuildMiniMonth();
             }
             $this->styleInfo->setMini(FALSE);
             break;
         case 'month':
             $rows = !empty($this->styleInfo->isMini()) ? $this->calendarBuildMiniMonth() : $this->calendarBuildMonth();
             break;
         case 'day':
             $rows = $this->calendarBuildDay();
             break;
         case 'week':
             $rows = $this->calendarBuildWeek();
             // Merge the day names in as the first row.
             $rows = array_merge([CalendarHelper::weekHeader($this->view)], $rows);
             break;
     }
     // Send the sorted rows to the right theme for this type of calendar.
     $this->definition['theme'] = 'calendar_' . $this->options['calendar_type'];
     // Adjust the theme to match the currently selected default.
     // Only the month view needs the special 'mini' class,
     // which is used to retrieve a different, more compact, theme.
     if ($this->options['calendar_type'] == 'month' && !empty($this->styleInfo->isMini())) {
         $this->definition['theme'] = 'calendar_mini';
     } elseif (in_array($this->options['calendar_type'], ['week', 'day']) && !empty($this->options['multiday_theme']) && !empty($this->options['theme_style'])) {
         $this->definition['theme'] .= '_overlap';
     }
     $output = ['#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#rows' => $rows];
     unset($this->view->row_index);
     return $output;
 }
コード例 #8
0
ファイル: bug44742.php プロジェクト: badlamer/hhvm
<?php

date_default_timezone_set('Europe/London');
$dates = array("2008-04-11 00:00:00+0000", "2008-04-11 00:00:00+0200", "2008-04-11 00:00:00+0330", "2008-04-11 00:00:00-0500", "2008-04-11 00:00:00-1130", "2008-04-11 00:00:00 CEST", "2008-04-11 00:00:00 CET", "2008-04-11 00:00:00 UTC", "2008-04-11 00:00:00 America/New_York", "2008-04-11 00:00:00 Europe/Oslo", "2008-04-11 00:00:00 Asia/Singapore");
foreach ($dates as $date) {
    $date = date_create($date);
    var_dump(timezone_offset_get(date_timezone_get($date), $date));
}
コード例 #9
0
ファイル: Date.class.php プロジェクト: johannes85/core
 /**
  * Retrieve timezone object associated with this date
  *
  * @return  util.TimeZone
  */
 public function getTimeZone()
 {
     return new TimeZone(date_timezone_get($this->date));
 }
コード例 #10
0
ファイル: PropelDateTimeTest.php プロジェクト: naldz/cyberden
 public function testCreateHighPrecisioniTz()
 {
     $originalTimezone = date_default_timezone_get();
     date_default_timezone_set('America/New_York');
     $createHP = PropelDateTime::createHighPrecision();
     $dt = new \DateTime();
     $dt->setTimezone(new \DateTimeZone('America/New_York'));
     $this->assertEquals(date_timezone_get($dt), date_timezone_get($createHP));
     date_default_timezone_set($originalTimezone);
 }
コード例 #11
0
<?php

/* Prototype  : DateTimeZone date_timezone_get  ( DateTime $object  )
 * Description: Return time zone relative to given DateTime
 * Source code: ext/date/php_date.c
 * Alias to functions: DateTime::setTimezone
 */
echo "*** Testing date_timezone_get() : basic functionality ***\n";
date_default_timezone_set("Europe/London");
$object = date_create("2009-01-30 17:57:32");
$tz = date_timezone_get($object);
var_dump(timezone_name_get($tz));
date_default_timezone_set("America/New_York");
$object = date_create("2009-01-30 17:57:32");
$tz = date_timezone_get($object);
var_dump(timezone_name_get($tz));
$la_time = timezone_open("America/Los_Angeles");
date_timezone_set($object, $la_time);
$tz = date_timezone_get($object);
var_dump(timezone_name_get($tz));
?>
===DONE===
コード例 #12
0
ファイル: 014.php プロジェクト: badlamer/hhvm
<?php

date_default_timezone_set('UTC');
$dto = date_create("2006-12-12");
var_dump($dto);
$dtz = date_timezone_get($dto);
var_dump($dtz);
var_dump(timezone_offset_get());
var_dump(timezone_offset_get($dtz, $dto));
var_dump(timezone_offset_get($dto, $dtz));
echo "Done\n";
コード例 #13
0
ファイル: Test.php プロジェクト: CamTosh/Mediastorrent
 function ca()
 {
     date_default_timezone_set("UTC");
     echo "UTC:" . time();
     echo "<br>";
     date_default_timezone_set("Europe/Helsinki");
     echo "Europe/Helsinki:" . time();
     echo "<br>";
     $erre = false;
     try {
         //throw new \Exception("dd");
     } catch (\Exception $e) {
         $erre = true;
     }
     var_dump(\date_timezone_get());
     die;
 }
コード例 #14
0
ファイル: Date.class.php プロジェクト: xp-framework/core
 /** Retrieve timezone object associated with this date */
 public function getTimeZone() : Timezone
 {
     return new TimeZone(date_timezone_get($this->handle));
 }