Fixed time zone issue
authorMarcel Werk <burntime@woltlab.com>
Sat, 26 Apr 2014 11:22:40 +0000 (13:22 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sat, 26 Apr 2014 11:22:40 +0000 (13:22 +0200)
com.woltlab.wcf/templates/__messageFormPoll.tpl
wcfsetup/install/files/lib/system/poll/PollManager.class.php

index 943ea4d4252af68540709d9069da4f6491aea9c3..d3aca6a9f07e120a020febb928bdcc81703e67a8 100644 (file)
@@ -40,7 +40,7 @@
                                        <label for="pollEndTime">{lang}wcf.poll.endTime{/lang}</label>
                                </dt>
                                <dd>
-                                       <input type="datetime" name="pollEndTime" id="pollEndTime" value="{if $pollEndTime}{@'Y-m-d H:i'|gmdate:$pollEndTime}{/if}" class="medium" />
+                                       <input type="datetime" name="pollEndTime" id="pollEndTime" value="{if $pollEndTime}{@$pollEndTime|date:'c'}{/if}" class="medium" data-ignore-timezone="true" />
                                        {if $errorField == 'pollEndTime'}
                                                <small class="innerError">
                                                        {lang}wcf.poll.endTime.error.{@$errorType}{/lang}
index d86a6db3d97d5e824b404d1bd2ea3f446155249f..a52be2dfa44dc00f6d8316f54dcc06980c88d7cf 100644 (file)
@@ -161,10 +161,8 @@ class PollManager extends SingletonFactory {
                
                // poll data
                if (isset($_POST['pollEndTime'])) {
-                       $endTime = StringUtil::trim($_POST['pollEndTime']);
-                       $endTime = (!empty($endTime)) ? @strtotime($endTime . ':00') : '';
-                       
-                       $this->pollData['endTime'] = ($endTime) ?: 0;
+                       $d = \DateTime::createFromFormat('Y-m-d H:i', $_POST['pollEndTime'], WCF::getUser()->getTimeZone());
+                       $this->pollData['endTime'] = ($d !== false) ? $d->getTimestamp() : 0;
                }
                
                if (isset($_POST['pollMaxVotes'])) $this->pollData['maxVotes'] = max(intval($_POST['pollMaxVotes']), 1); // force a minimum of 1