Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change instance() to createFromInstance() #4654

Merged
merged 1 commit into from
May 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/I18n/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ protected function setValue(string $name, $value)
public function setTimezone($timezone)
{
$timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
return Time::instance($this->toDateTime()->setTimezone($timezone), $this->locale);
return Time::createFromInstance($this->toDateTime()->setTimezone($timezone), $this->locale);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions user_guide_src/source/libraries/time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ This method takes a UNIX timestamp and, optionally, the timezone and locale, to

$time = Time::createFromTimestamp(1501821586, 'America/Chicago', 'en_US');

instance()
----------
createFromInstance()
--------------------

When working with other libraries that provide a DateTime instance, you can use this method to convert that
to a Time instance, optionally setting the locale. The timezone will be automatically determined from the DateTime
instance passed in::

$dt = new DateTime('now');
$time = Time::instance($dt, 'en_US');
$time = Time::createFromInstance($dt, 'en_US');

toDateTime()
------------
Expand Down