diff --git a/fuel/app/classes/extension/date.php b/fuel/app/classes/extension/date.php
index d1c6538..e4198a3 100644
--- a/fuel/app/classes/extension/date.php
+++ b/fuel/app/classes/extension/date.php
@@ -13,6 +13,30 @@ class Date extends \Date
{
+ /**
+ * get real timezone value (example Asia/Bangkok) from timezone number (example (UTC+07:00) Bangkok)
+ * by match timezone number to timezone configuration.
+ *
+ * @param string $timezone_num
+ * @return string timezone value for php.
+ */
+ public static function getRealTimezoneValue($timezone_num)
+ {
+ \Config::load('timezone', 'timezone');
+ $timezone_list = \Config::get('timezone.timezone', array());
+
+ if (is_array($timezone_list) && array_key_exists($timezone_num, $timezone_list)) {
+ $timezone = $timezone_list[$timezone_num];
+ unset($timezone_list);
+ return $timezone;
+ }
+
+ unset($timezone, $timezone_list);
+ // in case that it cannot found any value matched. use UTC (+0.00).
+ return 'UTC';
+ }// getRealTimezoneValue
+
+
/**
* gmt date. the timezone up to current user data.
*
@@ -36,12 +60,17 @@ public static function gmtDate($date_format = '%Y-%m-%d %H:%M:%S', $timestamp =
$timestamp = strtotime($timestamp);
}
}
+
+ // make very sure that selected timezone is in the timezone list or converted to real timezone.
+ if ($timezone != null) {
+ $timezone = static::isValidTimezone($timezone);
+ }
// check timezone
if ($timezone == null) {
$account_model = new \Model_Accounts();
$cookie = $account_model->getAccountCookie();
- $site_timezone = \Model_Config::getval('site_timezone');
+ $site_timezone = static::getRealTimezoneValue(\Model_Config::getval('site_timezone'));
if (!isset($cookie['account_id'])) {
// not member or not log in. use default config timezone.
@@ -51,7 +80,7 @@ public static function gmtDate($date_format = '%Y-%m-%d %H:%M:%S', $timestamp =
$row = \Model_Accounts::find($cookie['account_id']);
if (!empty($row)) {
- $timezone = $row->account_timezone;
+ $timezone = static::getRealTimezoneValue($row->account_timezone);
} else {
$timezone = $site_timezone;
}
@@ -89,6 +118,29 @@ public static function isValidTimeStamp($timestamp) {
}// isValidTimeStamp
+ /**
+ * is valid timezone.
+ * check and return real timezone value.
+ *
+ * @param string $timezone check timezone
+ * @return string return checked and get timezone value. if found that this is invalid then return null.
+ */
+ public static function isValidTimezone($timezone) {
+ \Config::load('timezone', 'timezone');
+ $timezone_list = \Config::get('timezone.timezone', array());
+ if (array_key_exists($timezone, $timezone_list)) {
+ // found in timezone list key. convert to timezone list value.
+ $timezone = static::getRealTimezoneValue($timezone);
+ } elseif (\Arr::search($timezone_list, $timezone) === null) {
+ // not found in the timezone list value. this is not the timezone key and not even timezone value.!
+ $timezone = null;
+ }
+ unset($timezone_list);
+
+ return $timezone;
+ }// isValidTimezone
+
+
/**
* get gmt timestamp from local timestamp
*
diff --git a/public/public/themes/system/admin/templates/account/account_form_v.php b/public/public/themes/system/admin/templates/account/account_form_v.php
index 31aac41..62f09a6 100644
--- a/public/public/themes/system/admin/templates/account/account_form_v.php
+++ b/public/public/themes/system/admin/templates/account/account_form_v.php
@@ -4,200 +4,200 @@