プロジェクト

全般

プロフィール

Bug(バグ) #3291

Yuya Watanabe11年以上前に更新

h3. 概要

後に示すテストコードを実行した際にパスしない. sfValidatorDate ではパスするため,もしかするとタイムゾーンの環境や設定によっては正しい動作をしない可能性がある.実際に起こりうる問題については調査しきれていないため、タイトル通り「可能性がある」という点でチケットを作成しておく.
問題点や修正点が明確になった場合はチケットタイトルおよびチケット本文を正しいものに差し替えてください.

h3. テストコード

<pre>
1 <?php
2
3 include_once dirname(__FILE__) . '/../../bootstrap/unit.php';
4
5 $t = new lime_test(1, new lime_output_color());
6
7 $v = new opValidatorDate();
8
9 $t->diag('opValidatorDate');
10
11 // timezones
12 $defaultTimezone = new DateTimeZone(date_default_timezone_get());
13 $otherTimezone = new DateTimeZone('US/Pacific');
14 if ($defaultTimezone->getOffset(new DateTime()) == $otherTimezone->getOffset(new DateTime()))
15 {
16 $otherTimezone = new DateTimeZone('US/Eastern');
17 }
18
19 $date = new DateTime('2000-01-01T00:00:00-00:00');
20 $date->setTimezone($otherTimezone);
21 $v->setOption('with_time', true);
22 $clean = $v->clean($date->format(DATE_ATOM));
23
24 $date->setTimezone($defaultTimezone);
25 $t->is($clean, $date->format('Y-m-d H:i:s'), '->clean() respects incoming and default timezones');
</pre>

実行結果
<pre>
$ php opValidatorDateTestForTimezone.php
not ok 1 - ->clean() respects incoming and default timezones
# Failed test (./opValidatorDateTestForTimezone.php at line 25)
# got: '1999-12-31 16:00:00'
# expected: '2000-01-01 09:00:00'
</pre>

h3. 関連チケット

Bug(バグ) #2882: opValidatorDate で「年」に 0 を入力した場合に空値として認識される - OpenPNE 3 - OpenPNE Issue Tracking System
https://redmine.openpne.jp/issues/2882#note-11

戻る