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';
}
/* 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) {
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'),[
// 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);
}
// 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);
}
$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 &&
if (strlen($newalbum)) {
$album = $newalbum;
} else {
- $album = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y');
+ $album = Temporal::timezoneNow(date_default_timezone_get(), 'Y');
}
}
$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') {
}
$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;
}
$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;
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.
*
$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--;
'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;
}
$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]);