The poll opening / closing dates are stored in the database as stings in UTC time, but the conversion to timestamps in advpoll_get_data uses strtotime without the timezone. This results in incorrect opening / closing date calculation.

I fixed this by appending " UTC" to the time values used:

if ($node->advpoll_dates) {
      (isset($node->advpoll_dates[$lang])) ? $data['start_date'] = strtotime($node->advpoll_dates[$lang][0]['value'] . ' UTC') : $data['start_date'] = strtotime($node->advpoll_dates['und'][0]['value'] . ' UTC');
      (isset($node->advpoll_dates[$lang])) ? $data['end_date'] = strtotime($node->advpoll_dates[$lang][0]['value2'] . ' UTC') : $data['end_date'] = strtotime($node->advpoll_dates['und'][0]['value2'] . ' UTC');
    } else {
      $data['start_date'] = 0;
      $data['end_date'] = 0;
    }

This is a hack, it should use the time zone data as stored in the field. I'll get around to writing it up properly one day and submitting a patch, unless someone wants to beat me to it :)

Comments

tripper54’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new3.97 KB

Patch attached. Might not be the best approach, but it works for me.

Leeteq’s picture

Priority: Normal » Major
tripper54’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch fails to apply on the latest dev, needs reroll.

+++ b/includes/advpoll_helper.inc
@@ -49,8 +49,8 @@ function advpoll_get_data($node) {
+      (isset($node->advpoll_dates[$lang])) ? $data['end_date'] = strtotime($node->advpoll_dates[$lang][0]['value2'] .  ' UTC') : $data['end_date'] = strtotime($node->advpoll_dates['und'][0]['value2'] . ' UTC');

Should probably use LANGUAGE_NONE instead of 'und'.

tripper54’s picture

Status: Needs work » Needs review
StatusFileSize
new1.11 KB

Reroll. This is a bit cleaner.

tripper54’s picture

Status: Needs review » Fixed

Committed.

  • tripper54 committed d140301 on 7.x-3.x
    Issue #1896264 by tripper54: Poll availability date does not calculate...

Status: Fixed » Closed (fixed)

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