Someone has obviously forgotten to count from 1 instead of 0.

When you pass a node creation day as an argument, it always uses the day prior to the day you have passed.

If I have a view with path /myview/[dd] and the title as %1, I visit /myview/21 and it comes back with the title as 20, and it filters for 20 instead of 21.

This is very troublesome as you can't look at the 31st day of any month - passing 32 rolls back to 1.

$view = new view;
$view->name = 'Blog';
$view->description = 'The view for blog entries.';
$view->tag = 'blog';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('sorts', array(
  'created' => array(
    'order' => 'DESC',
    'granularity' => 'minute',
    'id' => 'created',
    'table' => 'node',
    'field' => 'created',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'created_year' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '%1',
    'breadcrumb' => 'Blog',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'id' => 'created_year',
    'table' => 'node',
    'field' => 'created_year',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'poll' => 0,
      'blog' => 0,
      'page' => 0,
      'portfolio' => 0,
      'service' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '2' => 0,
      '1' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_php' => '',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'created_month' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '%2 / %1',
    'breadcrumb' => '%1',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'id' => 'created_month',
    'table' => 'node',
    'field' => 'created_month',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'poll' => 0,
      'blog' => 0,
      'page' => 0,
      'portfolio' => 0,
      'service' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '2' => 0,
      '1' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_php' => '',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'created_day' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '%3 / %2 / %1',
    'breadcrumb' => '%2',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'id' => 'created_day',
    'table' => 'node',
    'field' => 'created_day',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'poll' => 0,
      'blog' => 0,
      'page' => 0,
      'portfolio' => 0,
      'service' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '2' => 0,
      '1' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_php' => '',
    'override' => array(
      'button' => 'Override',
    ),
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'blog' => 'blog',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('use_ajax', TRUE);
$handler->override_option('use_pager', '1');
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
  'relationship' => 'none',
  'build_mode' => 'teaser',
  'links' => 1,
  'comments' => 0,
));
$handler = $view->new_display('page', 'Page-Blog', 'page_1');
$handler->override_option('title', 'Blog');
$handler->override_option('path', 'blog');
$handler->override_option('menu', array(
  'type' => 'normal',
  'title' => 'Blog',
  'description' => 'Blog',
  'weight' => '0',
  'name' => 'primary-links',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
$handler = $view->new_display('feed', 'Feed-Blog', 'feed_1');
$handler->override_option('items_per_page', 30);
$handler->override_option('style_plugin', 'rss');
$handler->override_option('style_options', array(
  'mission_description' => 1,
  'description' => '',
));
$handler->override_option('row_plugin', 'node_rss');
$handler->override_option('row_options', array());
$handler->override_option('path', 'blog/%/%/%/feed');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
$handler->override_option('displays', array(
  'page_1' => 'page_1',
  'default' => 0,
));
$handler->override_option('sitename_title', 1);

Visit http://www.rhubarbweb.com/drupal/2009/07/21 to see it in action.

Comments

Finbarr’s picture

fabio84’s picture

I have the same problem, and I found that some time ago there was the opposite problem: http://drupal.org/node/345546

I don't know if the problem is about counting from 0 or 1, for example in your site if you visit http://www.rhubarbweb.com/drupal/blog/2009/07/1 or http://www.rhubarbweb.com/drupal/blog/2009/07/32 or http://www.rhubarbweb.com/drupal/blog/2009/07/34 you'll see odd things.

dawehner’s picture

This is sadly out of scope of views

Views uses

  return "EXTRACT(DAY FROM($field))";
blackice2999’s picture

Hi @all,

the problem is the php function strtotime since PHP 5.1 using the timezone from system or from ini variable date.timezone - but drupal uses a own timezone system to respect the user timezones. So we need a way to say strtotime we want UTC and not for example "Europe/Berlin" i have wroten a small patch to say strtotime that we want 00:00:00 UTC as time, and its work for me but i think the better way to be constant over all strtotime usages in drupal is to set the timezone variable...

blackice2999’s picture

new patch. sorry i have forgotten the month and year handler.

dawehner’s picture

Status: Active » Needs review

Update status

dawehner’s picture

Version: 6.x-2.6 » 6.x-2.x-dev

Change version

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This looks fine.

blackice2999’s picture

a new one, no changes but diff created with git diff --no-prefix (thanks dereine)

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

As we talked in irc, it should fix all other instances: week, year etc, too

dawehner’s picture

Status: Needs work » Reviewed & tested by the community

/me sucks

It was late, and i forgot http://drupal.org/node/526106#comment-3234298

merlinofchaos’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Applied to 6.x branches; currently does not apply to 7.x

dawehner’s picture

Status: Patch (to be ported) » Fixed

And ported.

And fixed a todo in the code :)

tim.plunkett’s picture

Status: Fixed » Needs work

Warning: timezone_open(): Unknown or bad timezone (0) in format_date() (line 1855 of /includes/common.inc).
Warning: date_timezone_set() expects parameter 2 to be DateTimeZone, boolean given in format_date() (line 1882 of includes/common.inc).

Apparently 0 isn't a valid timezone?

D7 HEAD, views-7.x-3.x-dev, PHP 5.2.13

dawehner’s picture

Status: Needs work » Postponed (maintainer needs more info)

This is a bug report?

tim.plunkett’s picture

Uh, I guess I filed against the wrong issue? Should I open a new one?

I got the above error when using the default "archive" view.

Chris Gillis’s picture

Status: Postponed (maintainer needs more info) » Fixed

@tim.plunkett
Please refer to this issue: http://drupal.org/node/894560

Status: Fixed » Closed (fixed)

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

gilzero’s picture

Subscribe

unic’s picture

Version: 7.x-3.x-dev » 6.x-2.12
Priority: Normal » Major
Status: Closed (fixed) » Needs work

In 2.12 I still have this bug:

"If I have a view with path /myview/[dd] and the title as %1, I visit /myview/21 and it comes back with the title as 20".

Problem is in file views_handler_argument_dates_various.inc. Needs to apply patch from #9.

merlinofchaos’s picture

Version: 6.x-2.12 » 7.x-3.x-dev
Priority: Major » Normal
Status: Needs work » Closed (fixed)

That patch was committed to -dev ages ago, as mentioned in #12. There's not more to do until we can get another 2.x release but resources for this are lacking. Please don't hijack issues. Committed to -dev means just that.