diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-11-13 15:38:54 -0500 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-11-13 15:38:54 -0500 |
commit | 7c5d3649a3f137cc4c4bdd36dbb3639f2638d52c (patch) | |
tree | ba7bc9255f90db3f4cc2f2fb0f3a26190b55ffd1 | |
parent | 24c3d0c92e954cbe76c1742f4155f8488caa1ad1 (diff) |
use the core functions for relative dates
-rw-r--r-- | controllers/news.controller.php | 1 | ||||
-rw-r--r-- | js/items.js | 2 | ||||
-rw-r--r-- | lib/utils.php | 20 | ||||
-rw-r--r-- | templates/part.items.php | 3 |
4 files changed, 15 insertions, 11 deletions
diff --git a/controllers/news.controller.php b/controllers/news.controller.php index 0338c23e9..daa84d13f 100644 --- a/controllers/news.controller.php +++ b/controllers/news.controller.php @@ -41,7 +41,6 @@ class NewsController extends Controller { $this->addScript('news'); $this->addScript('menu'); $this->addScript('items'); - $this->add3rdPartyScript('jquery.timeago'); $this->addStyle('news'); $this->addStyle('settings'); diff --git a/js/items.js b/js/items.js index 65b5483ec..d055dfa15 100644 --- a/js/items.js +++ b/js/items.js @@ -632,7 +632,7 @@ var News = News || {}; self._toggleKeepUnread(); }); - this._$html.find('time.timeago').timeago(); + //this._$html.find('time.timeago').timeago(); }; /** diff --git a/lib/utils.php b/lib/utils.php index 298639675..aa1111dec 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -20,29 +20,33 @@ class Utils { /** * @brief Transform a date from UNIX timestamp format to MDB2 timestamp format - * @param dbtimestamp - * @returns + * @param dbtimestamp a date in the UNIX timestamp format + * @returns a date in the MDB2 timestamp format, or NULL if an error occurred */ public static function unixtimeToDbtimestamp($unixtime) { - if ($unixtime === null) + if ($unixtime === null) { return null; + } $dt = \DateTime::createFromFormat('U', $unixtime); - if ($dt === false) + if ($dt === false) { return null; + } return $dt->format('Y-m-d H:i:s'); } /** * @brief Transform a date from MDB2 timestamp format to UNIX timestamp format - * @param dbtimestamp - * @returns + * @param dbtimestamp a date in the MDB2 timestamp format + * @returns a date in the UNIX timestamp format, or NULL if an error occurred */ public static function dbtimestampToUnixtime($dbtimestamp) { - if ($dbtimestamp === null) + if ($dbtimestamp === null) { return null; + } $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $dbtimestamp); - if ($dt === false) + if ($dt === false) { return null; + } return $dt->format('U'); } diff --git a/templates/part.items.php b/templates/part.items.php index fcb2b12d8..efad98830 100644 --- a/templates/part.items.php +++ b/templates/part.items.php @@ -22,8 +22,9 @@ foreach($items as $item) { echo '<li class="feed_item ' . $newsItemClass .'" data-id="' . $item->getId() . '" data-feedid="' . $item->getFeedId() . '">'; echo '<span class="timestamp">' . $item->getDate() . '</span>'; + $relative_modified_date = OCP\relative_modified_date($item->getDate()); echo '<h2 class="item_date"><time class="timeago" datetime="' . - date('c', $item->getDate()) . '">' . date('F j, Y, g:i a', $item->getDate()) . '</time>' . '</h2>'; + date('c', $item->getDate()) . '">' . $relative_modified_date . '</time>' . '</h2>'; echo '<div class="utils">'; echo '<ul class="primary_item_utils">'; |