I have a table that has DATETIME fields, but for some reason this module is expecting the fields to be a Unix epoch number, rather than the ISO string that it actually is.

Is there a simple way around this?

Comments

dave kopecek’s picture

Same question here.

patcon’s picture

I'm working along a similar things in:
#950020: How to get an array of all handlers
#703864-1: date_api_filter_handler can't find what views_handler_filter_date can see

Only core handlers are options by default in Data module. This shouldn't be an issue for the field handler, since I believe date api automatically takes over for views_handler_field_date (this isn't the case for the core date FILTER handler, and I'll explain that below). But anyhow, even though date api can take over, unless otherwise indicated, it assumes UNIX time.

If you have an ISO time or whatever, you'll need to define your date field in a custom module with HOOK_date_api_fields(), or else drupal won't know the format of your date (core otherwise assumes UNIX). This is done automatically for CCK fields, but if you're just working with a simple database table, drupal doesn't know.

Just copy this format for your own function:
http://api.lullabot.com/date_api_date_api_fields

And if it comes time to try to assign a filter for your date from the Data module UI, you need to use drupal_data_views_handlers_alter($handlers) to add the date_api_filter_handler, since only views_handler_filter_date is available by default in the UI. You can see where this drupal_alter() function is created in data.views.inc, so you can check out how it expects $handlers to be formatted.

Does this get at what you needed?

arski’s picture

what about when one is creating a table through the Data interface? Any chance to add date field option there?

Thanks

joachim’s picture

Issue summary: View changes
Status: Active » Fixed

Works on D7. Unlikely to be ported to D6.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.