Add Temporal::local() shorthand for Temporal::convert()

This commit is contained in:
Hypolite Petovan 2018-01-26 19:29:06 -05:00
parent 25954314ec
commit 0bee706e51
11 changed files with 48 additions and 36 deletions

View file

@ -135,6 +135,18 @@ class Temporal
return self::convert($time, 'UTC', 'UTC', $format);
}
/**
* convert() shorthand for local.
*
* @param string $time A date/time string
* @param string $format DateTime format string or Temporal constant
* @return string
*/
public static function local($time, $format = self::MYSQL)
{
return self::convert($time, date_default_timezone_get(), 'UTC', $format);
}
/**
* convert() shorthand for timezoned now.
*
@ -154,7 +166,7 @@ class Temporal
*/
public static function localNow($format = self::MYSQL)
{
return self::convert('now', date_default_timezone_get(), 'UTC', $format);
return self::local('now', $format);
}
/**
@ -165,7 +177,7 @@ class Temporal
*/
public static function utcNow($format = self::MYSQL)
{
return self::convert('now', 'UTC', 'UTC', $format);
return self::utc('now', $format);
}
/**