Add Temporal::timezoneNow() shorthand for Temporal::convert()
This commit is contained in:
parent
35d06bd9eb
commit
89602e44da
4
boot.php
4
boot.php
|
@ -1142,10 +1142,10 @@ function feed_birthday($uid, $tz)
|
|||
if (DBM::is_result($p)) {
|
||||
$tmp_dob = substr($p[0]['dob'], 5);
|
||||
if (intval($tmp_dob)) {
|
||||
$y = Temporal::convert('now', $tz, $tz, 'Y');
|
||||
$y = Temporal::timezoneNow($tz, 'Y');
|
||||
$bd = $y . '-' . $tmp_dob . ' 00:00';
|
||||
$t_dob = strtotime($bd);
|
||||
$now = strtotime(Temporal::convert('now', $tz, $tz));
|
||||
$now = strtotime(Temporal::timezoneNow($tz));
|
||||
if ($t_dob < $now) {
|
||||
$bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
|
||||
}
|
||||
|
|
|
@ -416,7 +416,7 @@ function drop_item($id) {
|
|||
|
||||
/* arrange the list in years */
|
||||
function list_post_dates($uid, $wall) {
|
||||
$dnow = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y-m-d');
|
||||
$dnow = Temporal::timezoneNow(date_default_timezone_get(), 'Y-m-d');
|
||||
|
||||
$dthen = Item::firstPostDate($uid, $wall);
|
||||
if (!$dthen) {
|
||||
|
@ -474,7 +474,7 @@ function posted_date_widget($url, $uid, $wall) {
|
|||
return $o;
|
||||
}
|
||||
|
||||
$cutoff_year = intval(Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y')) - $visible_years;
|
||||
$cutoff_year = intval(Temporal::timezoneNow(date_default_timezone_get(), 'Y')) - $visible_years;
|
||||
$cutoff = ((array_key_exists($cutoff_year, $ret))? true : false);
|
||||
|
||||
$o = replace_macros(get_markup_template('posted_date_widget.tpl'),[
|
||||
|
|
|
@ -152,8 +152,8 @@ function cal_content(App $a)
|
|||
|
||||
// The view mode part is similiar to /mod/events.php
|
||||
if ($mode == 'view') {
|
||||
$thisyear = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y');
|
||||
$thismonth = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'm');
|
||||
$thisyear = Temporal::timezoneNow(date_default_timezone_get(), 'Y');
|
||||
$thismonth = Temporal::timezoneNow(date_default_timezone_get(), 'm');
|
||||
if (!$y) {
|
||||
$y = intval($thisyear);
|
||||
}
|
||||
|
|
|
@ -276,8 +276,8 @@ function events_content(App $a) {
|
|||
// The view mode part is similiar to /mod/cal.php
|
||||
if ($mode == 'view') {
|
||||
|
||||
$thisyear = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y');
|
||||
$thismonth = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'm');
|
||||
$thisyear = Temporal::timezoneNow(date_default_timezone_get(), 'Y');
|
||||
$thismonth = Temporal::timezoneNow(date_default_timezone_get(), 'm');
|
||||
if (! $y) {
|
||||
$y = intval($thisyear);
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ function photos_post(App $a)
|
|||
$resource_id = $a->argv[2];
|
||||
|
||||
if (!strlen($albname)) {
|
||||
$albname = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y');
|
||||
$albname = Temporal::timezoneNow(date_default_timezone_get(), 'Y');
|
||||
}
|
||||
|
||||
if (x($_POST,'rotate') !== false &&
|
||||
|
@ -738,7 +738,7 @@ function photos_post(App $a)
|
|||
if (strlen($newalbum)) {
|
||||
$album = $newalbum;
|
||||
} else {
|
||||
$album = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y');
|
||||
$album = Temporal::timezoneNow(date_default_timezone_get(), 'Y');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ function ping_init(App $a)
|
|||
$all_events = count($ev);
|
||||
|
||||
if ($all_events) {
|
||||
$str_now = Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d');
|
||||
$str_now = Temporal::timezoneNow($a->timezone, 'Y-m-d');
|
||||
foreach ($ev as $x) {
|
||||
$bd = false;
|
||||
if ($x['type'] === 'birthday') {
|
||||
|
|
|
@ -659,7 +659,7 @@ class Profile
|
|||
}
|
||||
|
||||
$strt = Temporal::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC', 'UTC', 'Y-m-d');
|
||||
if ($strt === Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d')) {
|
||||
if ($strt === Temporal::timezoneNow($a->timezone, 'Y-m-d')) {
|
||||
$istoday = true;
|
||||
}
|
||||
|
||||
|
@ -676,11 +676,11 @@ class Profile
|
|||
|
||||
$strt = Temporal::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC');
|
||||
|
||||
if (substr($strt, 0, 10) < Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d')) {
|
||||
if (substr($strt, 0, 10) < Temporal::timezoneNow($a->timezone, 'Y-m-d')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$today = ((substr($strt, 0, 10) === Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d')) ? true : false);
|
||||
$today = ((substr($strt, 0, 10) === Temporal::timezoneNow($a->timezone, 'Y-m-d')) ? true : false);
|
||||
|
||||
$rr['title'] = $title;
|
||||
$rr['description'] = $description;
|
||||
|
|
|
@ -135,6 +135,17 @@ class Temporal
|
|||
return self::convert($time, 'UTC', 'UTC', $format);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert() shorthand for UTC now.
|
||||
*
|
||||
* @param string $format DateTime format string or Temporal constant
|
||||
* @return string
|
||||
*/
|
||||
public static function timezoneNow($timezone, $format = self::MYSQL)
|
||||
{
|
||||
return self::convert('now', $timezone, 'UTC', $format);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert() shorthand for UTC now.
|
||||
*
|
||||
|
@ -459,9 +470,9 @@ class Temporal
|
|||
|
||||
$birthdate = self::convert($dob . ' 00:00:00+00:00', $owner_tz, 'UTC', 'Y-m-d');
|
||||
list($year, $month, $day) = explode("-", $birthdate);
|
||||
$year_diff = self::convert('now', $viewer_tz, 'UTC', 'Y') - $year;
|
||||
$curr_month = self::convert('now', $viewer_tz, 'UTC', 'm');
|
||||
$curr_day = self::convert('now', $viewer_tz, 'UTC', 'd');
|
||||
$year_diff = self::timezoneNow($viewer_tz, 'Y') - $year;
|
||||
$curr_month = self::timezoneNow($viewer_tz, 'm');
|
||||
$curr_day = self::timezoneNow($viewer_tz, 'd');
|
||||
|
||||
if (($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day))) {
|
||||
$year_diff--;
|
||||
|
@ -531,8 +542,8 @@ class Temporal
|
|||
'October', 'November', 'December'
|
||||
];
|
||||
|
||||
$thisyear = self::convert('now', date_default_timezone_get(), 'UTC', 'Y');
|
||||
$thismonth = self::convert('now', date_default_timezone_get(), 'UTC', 'm');
|
||||
$thisyear = self::timezoneNow(date_default_timezone_get(), 'Y');
|
||||
$thismonth = self::timezoneNow(date_default_timezone_get(), 'm');
|
||||
if (!$y) {
|
||||
$y = $thisyear;
|
||||
}
|
||||
|
@ -549,7 +560,7 @@ class Temporal
|
|||
$started = false;
|
||||
|
||||
if (($y == $thisyear) && ($m == $thismonth)) {
|
||||
$tddate = intval(self::convert('now', date_default_timezone_get(), 'UTC', 'j'));
|
||||
$tddate = intval(self::timezoneNow(date_default_timezone_get(), 'j'));
|
||||
}
|
||||
|
||||
$str_month = day_translate($mtab[$m]);
|
||||
|
|
Loading…
Reference in a new issue