summaryrefslogtreecommitdiff
path: root/lib/util.php
diff options
context:
space:
mode:
authorMike Cochrane <mikec@mikenz.geek.nz>2008-07-20 10:13:25 -0400
committerMike Cochrane <mikec@mikenz.geek.nz>2008-07-20 10:13:25 -0400
commit88717d88057ac0c51a2d7842305c808691404e6f (patch)
tree891a722a92bbc9e91799367cbbd0506f6725bdea /lib/util.php
parent060fecf5ec59202c5eaf3448f9723a81820d5735 (diff)
User definable timezones. Work in UTC internally and display per user/site default. http://laconi.ca/PITS/00011
darcs-hash:20080720141325-533db-87cb60501434c9dc0ac13716ba5d8b17754431f5.gz
Diffstat (limited to 'lib/util.php')
-rw-r--r--lib/util.php36
1 files changed, 28 insertions, 8 deletions
diff --git a/lib/util.php b/lib/util.php
index 1ec68863e..c095fe768 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -435,6 +435,18 @@ function common_textarea($id, $label, $content=NULL, $instructions=NULL) {
common_element_end('p');
}
+function common_timezone() {
+ if (common_logged_in()) {
+ $user = common_current_user();
+ if ($user->timezone) {
+ return $user->timezone;
+ }
+ }
+
+ global $config;
+ return $config['site']['timezone'];
+}
+
function common_language() {
$httplang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : NULL;
$language = array();
@@ -920,23 +932,31 @@ function common_date_string($dt) {
}
function common_exact_date($dt) {
- $t = strtotime($dt);
- return date(DATE_RFC850, $t);
+ $dateStr = date('d F Y H:i:s', strtotime($dt));
+ $d = new DateTime($dateStr, new DateTimeZone('UTC'));
+ $d->setTimezone(new DateTimeZone(common_timezone()));
+ return $d->format(DATE_RFC850);
}
function common_date_w3dtf($dt) {
- $t = strtotime($dt);
- return date(DATE_W3C, $t);
+ $dateStr = date('d F Y H:i:s', strtotime($dt));
+ $d = new DateTime($dateStr, new DateTimeZone('UTC'));
+ $d->setTimezone(new DateTimeZone(common_timezone()));
+ return $d->format(DATE_W3C);
}
function common_date_rfc2822($dt) {
- $t = strtotime($dt);
- return date("r", $t);
+ $dateStr = date('d F Y H:i:s', strtotime($dt));
+ $d = new DateTime($dateStr, new DateTimeZone('UTC'));
+ $d->setTimezone(new DateTimeZone(common_timezone()));
+ return $d->format('r');
}
function common_date_iso8601($dt) {
- $t = strtotime($dt);
- return date("c", $t);
+ $dateStr = date('d F Y H:i:s', strtotime($dt));
+ $d = new DateTime($dateStr, new DateTimeZone('UTC'));
+ $d->setTimezone(new DateTimeZone(common_timezone()));
+ return $d->format('c');
}
function common_redirect($url, $code=307) {