本文整理汇总了PHP中Carbon\Carbon::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::__construct方法的具体用法?PHP Carbon::__construct怎么用?PHP Carbon::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon\Carbon
的用法示例。
在下文中一共展示了Carbon::__construct方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Returns new DateTime object.
*
* @param string $time
* @param string|DateTimeZone $timezone
* @return Date
*/
public function __construct($time = null, $timezone = null)
{
// Create Date from timestamp.
if (is_int($time)) {
$time = "@{$time}";
}
parent::__construct($time, $timezone);
}
示例2: __construct
/**
* @{inheritdoc}
*/
public function __construct($time = null, $tz = null, $locale = null)
{
parent::__construct($time, $tz);
$this->locale = is_null($locale) ? 'en' : $locale;
foreach (static::$builtInLanguages as $lang) {
$this->setLanguageFilePath($lang, __DIR__ . '/l10n/' . $lang . '.php');
}
}
示例3: __construct
/**
* Returns new DateTime object.
*
* @param string $time
* @param string|DateTimeZone $timezone
* @return Date
*/
public function __construct($time = null, $timezone = null)
{
// Create Date from timestamp.
if (is_int($time)) {
$time = "@{$time}";
}
// Get default timezone from app config.
if (is_null($timezone) and class_exists('Illuminate\\Support\\Facades\\Config')) {
$timezone = \Illuminate\Support\Facades\Config::get('app.timezone');
}
parent::__construct($time, $timezone);
}
示例4: __construct
/**
* Se o time for string ele aceita o formato TDateTime (d/m/Y H:i:s |d/m/YTH:i:s), não aceita formato americano (m/d/Y H:i:s)
*
* @param string|int|DateTime|object $time
* @param \DateTimeZone|string $tz
*
* @throws DomainException
*/
public function __construct($time = null, $tz = null)
{
if (null !== $time) {
$date = static::prepareDate($time);
if (!$date) {
throw new DomainException("Data {$time} inválida!");
}
$time = $date;
}
parent::__construct($time, $tz);
$this->init();
}
示例5: __construct
/**
* Create a new DateValue instance.
*
* @param DateTimeInterface|string|null $time
* @param \DateTimeZone|string $tz
*/
public function __construct($time = null, $tz = null)
{
if ($time instanceof DateTimeInterface) {
$create_from = $time->format('Y-m-d H:i:s');
} else {
$create_from = $time;
}
if (empty($tz)) {
$tz = 'UTC';
}
parent::__construct($create_from, $tz);
}
示例6: __construct
/**
* Create a new Sunny instance.
*
* @param string $time
* @param DateTimeZone|string $tz
* @param float $latitude
* @param float $longitude
*/
public function __construct($time = null, $tz = null, $latitude = null, $longitude = null)
{
parent::__construct($time, $tz);
$this->setLocation($latitude, $longitude);
/**
* According to these sources default date.sunrise_zenith and
* date.sunset_zenith in php is wrong. So fixing it here.
* https://bugs.php.net/bug.php?id=49448
* http://aa.usno.navy.mil/faq/docs/RST_defs.php
*/
$this->zenith = 90 + 50 / 60;
}
示例7: __construct
/**
* Returns new DateTime object.
*
* @param string $time
* @param string|DateTimeZone $timezone
* @return Date
*/
public function __construct($time = null, $timezone = 'Asia/Bangkok')
{
if (is_int($time)) {
$timestamp = $time;
$time = null;
} else {
$timestamp = null;
}
parent::__construct($time, $timezone);
if ($timestamp !== null) {
$this->setTimestamp($timestamp);
}
}
示例8: __construct
/**
* {@inheritdoc}
*/
public function __construct($time = null, $timezone = null)
{
if (!self::$init) {
self::init();
}
parent::__construct($time, $timezone);
if ($timezone) {
$convert = is_string($timezone) && $timezone != date_default_timezone_get();
$convert = $timezone instanceof \DateTimeZone && $timezone->getName() != date_default_timezone_get() ? true : $convert;
if ($convert) {
$this->setTimezone(new \DateTimeZone(date_default_timezone_get()));
}
}
}
示例9: __construct
public function __construct($time, $type, $tz)
{
parent::__construct($time, $tz);
$this->calendar_type = $type;
}
示例10: __construct
/**
* {@inheritDoc}
*/
public function __construct($time = null, $tz = null)
{
if ($time instanceof \DateTime) {
list($time, $tz) = [$time->format('Y-m-d H:i:s'), $time->getTimeZone()];
}
if (is_numeric($time)) {
$time = '@' . $time;
}
parent::__construct($time, $tz);
}
示例11: __construct
/**
* Create a new instance of this class.
*
* @return void
*/
public function __construct($time = null, $tz = null)
{
parent::__construct($time, $tz);
}
示例12: __construct
public function __construct($time = null, $tz = null, Lookup $lookup = null)
{
parent::__construct($time, $tz);
$this->setLookup($lookup);
}
示例13: __construct
public function __construct()
{
parent::__construct();
}