aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-07-11 16:20:17 -0700
committerfriendica <info@friendica.com>2012-07-11 16:20:17 -0700
commit71afdf3d9c8cce686f0b996f4ab08e480edfc5d0 (patch)
treea5a7288320ae42794380d586cf2d7234bfece299
parent6105211e73934542b084f20d903b1ff3431df7e9 (diff)
downloadvolse-hubzilla-71afdf3d9c8cce686f0b996f4ab08e480edfc5d0.tar.gz
volse-hubzilla-71afdf3d9c8cce686f0b996f4ab08e480edfc5d0.tar.bz2
volse-hubzilla-71afdf3d9c8cce686f0b996f4ab08e480edfc5d0.zip
gracefully recover from datetime constructor issues
-rw-r--r--include/datetime.php25
-rw-r--r--version.inc2
2 files changed, 24 insertions, 3 deletions
diff --git a/include/datetime.php b/include/datetime.php
index 75ae685f3..9f145e5c7 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -100,8 +100,29 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
return str_replace('1','0',$d->format($fmt));
}
- $d = new DateTime($s, new DateTimeZone($from));
- $d->setTimeZone(new DateTimeZone($to));
+ try {
+ $from_obj = new DateTimeZone($from);
+ }
+ catch(Exception $e) {
+ $from_obj = new DateTimeZone('UTC');
+ }
+
+ try {
+ $d = new DateTime($s, $from_obj);
+ }
+ catch(Exception $e) {
+ logger('datetime_convert: exception: ' . $e->getMessage());
+ $d = newDateTime('now', $from_obj);
+ }
+
+ try {
+ $to_obj = new DateTimeZone($to);
+ }
+ catch(Exception $e) {
+ $to_obj = new DateTimeZone('UTC');
+ }
+
+ $d->setTimeZone($to_obj);
return($d->format($fmt));
}}
diff --git a/version.inc b/version.inc
index 9f77d5be5..f779f55b9 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2012-07-10.11
+2012-07-11.12