summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Wehner2011-02-19 07:11:01 (GMT)
committer Daniel Wehner2011-02-19 07:11:01 (GMT)
commit3f7d1df7399de92888e266b42832b3f3d89e1dc5 (patch)
tree950c84428a7ca1e9bf95431354814a1414149d42
parent0d8ee6b7e96ee5237c0d2a739f37d41dd0490c25 (diff)
#970162 by longwave: Add "time hence" options to date field format
-rw-r--r--CHANGELOG.txt1
-rw-r--r--handlers/views_handler_field_date.inc15
2 files changed, 13 insertions, 3 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 3fdeafe..5466c9d 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -77,6 +77,7 @@ Fix fieldsets in field handler.
#870960 by bojanz, dereine: Field label should derive from field Label, not field name.
#1056824 by greggles: Rename the displayed permission from "access all views" to "bypass views access control".
#1022052 bojanz, dereine: Don't add the field_info into the views data array
+#970162 by longwave: Add "time hence" options to date field format
Views 3.x-7.x-alpha1 (05-Jan-2011)
==================================
diff --git a/handlers/views_handler_field_date.inc b/handlers/views_handler_field_date.inc
index ec8352e..b9814aa 100644
--- a/handlers/views_handler_field_date.inc
+++ b/handlers/views_handler_field_date.inc
@@ -28,7 +28,10 @@ class views_handler_field_date extends views_handler_field {
'custom' => t('Custom'),
'raw time ago' => t('Time ago'),
'time ago' => t('Time ago (with "ago" appended)'),
- 'raw time span' => t('Time span (future dates start with - )'),
+ 'raw time hence' => t('Time hence'),
+ 'time hence' => t('Time hence (with "hence" appended)'),
+ 'raw time span' => t('Time span (future dates have "-" prepended)'),
+ 'inverse time span' => t('Time span (past dates have "-" prepended)'),
'time span' => t('Time span (with "ago/hence" appended)'),
),
'#default_value' => isset($this->options['date_format']) ? $this->options['date_format'] : 'small',
@@ -39,14 +42,14 @@ class views_handler_field_date extends views_handler_field {
'#description' => t('If "Custom", see <a href="http://us.php.net/manual/en/function.date.php" target="_blank">the PHP docs</a> for date formats. If "Time ago" this is the the number of different units to display, which defaults to two.'),
'#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '',
'#process' => array('ctools_dependent_process'),
- '#dependency' => array('edit-options-date-format' => array('custom', 'raw time ago', 'time ago', 'raw time span', 'time span')),
+ '#dependency' => array('edit-options-date-format' => array('custom', 'raw time ago', 'time ago', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span')),
);
}
function render($values) {
$value = $values->{$this->field_alias};
$format = $this->options['date_format'];
- if (in_array($format, array('custom', 'raw time ago', 'time ago', 'raw time span', 'time span'))) {
+ if (in_array($format, array('custom', 'raw time ago', 'time ago', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span'))) {
$custom_format = $this->options['custom_date_format'];
}
@@ -57,8 +60,14 @@ class views_handler_field_date extends views_handler_field {
return format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2);
case 'time ago':
return t('%time ago', array('%time' => format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2)));
+ case 'raw time hence':
+ return format_interval(-$time_diff, is_numeric($custom_format) ? $custom_format : 2);
+ case 'time hence':
+ return t('%time hence', array('%time' => format_interval(-$time_diff, is_numeric($custom_format) ? $custom_format : 2)));
case 'raw time span':
return ($time_diff < 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2);
+ case 'inverse time span':
+ return ($time_diff > 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2);
case 'time span':
return t(($time_diff < 0 ? '%time hence' : '%time ago'), array('%time' => format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2)));
case 'custom':