Replace _api_get_timezone with api_get_timezone

pull/2487/head
jmontoyaa 9 years ago
parent 3a9c18e342
commit 3151b8a099
  1. 2
      main/admin/settings.lib.php
  2. 4
      main/admin/skill_list.php
  3. 6
      main/inc/lib/TicketManager.php
  4. 4
      main/inc/lib/agenda.lib.php
  5. 10
      main/inc/lib/internationalization.lib.php
  6. 2
      main/inc/lib/template.lib.php
  7. 2
      tests/main/inc/lib/internationalization.lib.test.php

@ -1529,7 +1529,7 @@ function generateSettingsForm($settings, $settings_by_access_list)
case 'timezone_value': case 'timezone_value':
$timezone = $row['selected_value']; $timezone = $row['selected_value'];
if (empty($timezone)) { if (empty($timezone)) {
$timezone = _api_get_timezone(); $timezone = api_get_timezone();
} }
$form->addLabel('', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'), $timezone, api_get_local_time())); $form->addLabel('', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'), $timezone, api_get_local_time()));
break; break;

@ -38,7 +38,7 @@ switch ($action) {
} else { } else {
$updatedAt = new DateTime( $updatedAt = new DateTime(
api_get_utc_datetime(), api_get_utc_datetime(),
new DateTimeZone(_api_get_timezone()) new DateTimeZone(api_get_timezone())
); );
$skill->setStatus(1); $skill->setStatus(1);
@ -71,7 +71,7 @@ switch ($action) {
} else { } else {
$updatedAt = new DateTime( $updatedAt = new DateTime(
api_get_utc_datetime(), api_get_utc_datetime(),
new DateTimeZone(_api_get_timezone()) new DateTimeZone(api_get_timezone())
); );
$skill->setStatus(0); $skill->setStatus(0);

@ -1284,15 +1284,15 @@ class TicketManager
$row['course'] = null; $row['course'] = null;
$row['start_date_from_db'] = $row['start_date']; $row['start_date_from_db'] = $row['start_date'];
$row['start_date'] = api_convert_and_format_date( $row['start_date'] = api_convert_and_format_date(
api_get_local_time($row['start_date']), DATE_TIME_FORMAT_LONG, _api_get_timezone() api_get_local_time($row['start_date']), DATE_TIME_FORMAT_LONG, api_get_timezone()
); );
$row['end_date_from_db'] = $row['end_date']; $row['end_date_from_db'] = $row['end_date'];
$row['end_date'] = api_convert_and_format_date( $row['end_date'] = api_convert_and_format_date(
api_get_local_time($row['end_date']), DATE_TIME_FORMAT_LONG, _api_get_timezone() api_get_local_time($row['end_date']), DATE_TIME_FORMAT_LONG, api_get_timezone()
); );
$row['sys_lastedit_datetime_from_db'] = $row['sys_lastedit_datetime']; $row['sys_lastedit_datetime_from_db'] = $row['sys_lastedit_datetime'];
$row['sys_lastedit_datetime'] = api_convert_and_format_date( $row['sys_lastedit_datetime'] = api_convert_and_format_date(
api_get_local_time($row['sys_lastedit_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone() api_get_local_time($row['sys_lastedit_datetime']), DATE_TIME_FORMAT_LONG, api_get_timezone()
); );
$row['course_url'] = null; $row['course_url'] = null;
if ($row['course_id'] != 0) { if ($row['course_id'] != 0) {

@ -1851,7 +1851,7 @@ class Agenda
private function formatEventDate($utcTime) private function formatEventDate($utcTime)
{ {
$utcTimeZone = new DateTimeZone('UTC'); $utcTimeZone = new DateTimeZone('UTC');
$platformTimeZone = new DateTimeZone(_api_get_timezone()); $platformTimeZone = new DateTimeZone(api_get_timezone());
$eventDate = new DateTime($utcTime, $utcTimeZone); $eventDate = new DateTime($utcTime, $utcTimeZone);
$eventDate->setTimezone($platformTimeZone); $eventDate->setTimezone($platformTimeZone);
@ -2718,7 +2718,7 @@ class Agenda
); );
$sentTo = array('everyone' => true); $sentTo = array('everyone' => true);
$calendar = Sabre\VObject\Reader::read($data); $calendar = Sabre\VObject\Reader::read($data);
$currentTimeZone = _api_get_timezone(); $currentTimeZone = api_get_timezone();
if (!empty($calendar->VEVENT)) { if (!empty($calendar->VEVENT)) {
foreach ($calendar->VEVENT as $event) { foreach ($calendar->VEVENT as $event) {
$start = $event->DTSTART->getDateTime(); $start = $event->DTSTART->getDateTime();

@ -353,7 +353,7 @@ function api_get_timezones()
* *
* @return string The timezone chosen * @return string The timezone chosen
*/ */
function _api_get_timezone() function api_get_timezone()
{ {
// First, get the default timezone of the server // First, get the default timezone of the server
$to_timezone = date_default_timezone_get(); $to_timezone = date_default_timezone_get();
@ -394,7 +394,7 @@ function _api_get_timezone()
*/ */
function api_get_utc_datetime($time = null, $return_null_if_invalid_date = false, $returnObj = false) function api_get_utc_datetime($time = null, $return_null_if_invalid_date = false, $returnObj = false)
{ {
$from_timezone = _api_get_timezone(); $from_timezone = api_get_timezone();
$to_timezone = 'UTC'; $to_timezone = 'UTC';
if (is_null($time) || empty($time) || $time === '0000-00-00 00:00:00') { if (is_null($time) || empty($time) || $time === '0000-00-00 00:00:00') {
if ($return_null_if_invalid_date) { if ($return_null_if_invalid_date) {
@ -451,7 +451,7 @@ function api_get_local_time(
} }
// Determining the timezone to be converted to // Determining the timezone to be converted to
if (is_null($to_timezone)) { if (is_null($to_timezone)) {
$to_timezone = _api_get_timezone(); $to_timezone = api_get_timezone();
} }
// If time is a timestamp, convert it to a string // If time is a timestamp, convert it to a string
@ -525,7 +525,7 @@ function api_strtotime($time, $timezone = null)
function api_format_date($time, $format = null, $language = null) function api_format_date($time, $format = null, $language = null)
{ {
$system_timezone = date_default_timezone_get(); $system_timezone = date_default_timezone_get();
date_default_timezone_set(_api_get_timezone()); date_default_timezone_set(api_get_timezone());
if (is_string($time)) { if (is_string($time)) {
$time = strtotime($time); $time = strtotime($time);
@ -677,7 +677,7 @@ function date_to_str_ago($date, $timeZone = 'UTC')
return ''; return '';
} }
$getOldTimezone = _api_get_timezone(); $getOldTimezone = api_get_timezone();
$timeAgo = new TimeAgo($timeZone, api_get_language_isocode()); $timeAgo = new TimeAgo($timeZone, api_get_language_isocode());
$value = $timeAgo->inWords($date); $value = $timeAgo->inWords($date);

@ -514,7 +514,7 @@ class Template
'site_name' => api_get_setting('siteName'), 'site_name' => api_get_setting('siteName'),
'institution' => api_get_setting('Institution'), 'institution' => api_get_setting('Institution'),
'date' => api_format_date('now', DATE_FORMAT_LONG), 'date' => api_format_date('now', DATE_FORMAT_LONG),
'timezone' => _api_get_timezone(), 'timezone' => api_get_timezone(),
'gamification_mode' => api_get_setting('gamification_mode') 'gamification_mode' => api_get_setting('gamification_mode')
); );
$this->assign('_s', $_s); $this->assign('_s', $_s);

@ -971,7 +971,7 @@ class TestInternationalization extends UnitTestCase {
public function test_api_get_utc_datetime_with_string() { public function test_api_get_utc_datetime_with_string() {
$timestamp = time(); $timestamp = time();
$timezone = _api_get_timezone(); $timezone = api_get_timezone();
$system_timezone = date_default_timezone_get(); $system_timezone = date_default_timezone_get();
date_default_timezone_set($timezone); date_default_timezone_set($timezone);
$datetime = date('Y-m-d H:i:s', $timestamp); $datetime = date('Y-m-d H:i:s', $timestamp);

Loading…
Cancel
Save