Closed (fixed)
Project:
Views (for Drupal 7)
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
21 Jan 2014 at 15:56 UTC
Updated:
18 Apr 2019 at 14:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
joachim commentedHere's a patch.
The intention here is that contrib modules could declare this handler in their hook_views_data() for table fields that hold MySQL datetime data.
Comment #2
jblumenfeld commentedThis seems useful, but for completeness it would probably also need something to handle sort and filter?
Comment #3
joachim commentedIt's a few weeks since I worked on this, but I seem to remember that sort and filter work as they are.
Comment #4
Andre-BIf I understand correctly: currently a contrib module would have to extend the views_handler_field_date and override the render method to provide datetime support?
saw a reference here: http://drupal.stackexchange.com/questions/34261/creating-a-sortable-field
Comment #5
lucyp commentedThe patch works for me, and I really appreciate this change. Now I'm able to extend that handler in all kinds of useful ways. I vote that it gets incorporated into Views.
Comment #6
JulienThomas commentedInstead of patching date field handler, why not creating a specific field handler?
as even the patch suggest, the patch itself makes a big assumption
So why not going toward a field handler such as
that way, we still use views_handler_field_date and add a specific strtotime for SQL datatime fields plugged in from hooks_view_data.
obviously, you need to add the following line to module.info
files[] = handlers/module_handler_field_datetime.inc
Comment #7
berliner commentedparent::renderexpects the full$valuesobject, so this would be better:Comment #8
caminadaf commentedI'm sorry @JulienThomas, but I disagree with you. It is not pratical at all to have different field handlers for each "date" sql column.
Also, is it really such a big assumption to try to turn the value into timestamp if it isnt a numeric? Is there any possibility of this assumption to break something?
IMO this is such a simple change that can help so many people without any impact on the current functionality.
I believe this should be patched.
Comment #9
natanmoraesReworked the patch with latest dev code.
Comment #10
mustanggb commented#9 is just a straightforward re-roll, so back to RTBC as per #8.
Comment #11
pythagory commented#9 no longer applying for me after updating to 3.20, rerolled patch attached.
Comment #12
natanmoraes#11 also works for 3.21
Any chance this could be added to the next release? It's RTBC for 2 years already
Comment #13
damienmckennaComment #15
damienmckennaCommitted. Thanks!