예제 #1
0
 /**
  * Returns a set of html select-tags (one for hour and minute)
  */
 function select_time($datetime = null, $options = array())
 {
     $datetime = empty($datetime) ? Ak::getDate() : $datetime;
     return DateHelper::select_hour($datetime, $options) . DateHelper::select_minute($datetime, $options) . (!empty($options['include_seconds']) ? DateHelper::select_second($datetime, $options) : '');
 }
예제 #2
0
    function test_DateHelper()
    {
        $this->assertEqual(DateHelper::distance_of_time_in_words('1978-06-16', '2006-01-18'), '10078 days');
        $this->assertEqual(DateHelper::distance_of_time_in_words('1779-12-01', '1780-01-01'), '31 days');
        /**
         * According to the Gregorian calendar, which is the civil calendar in use today, 
         * years evenly divisible by 4 are leap years, with the exception of centurial years 
         * that are not evenly divisible by 400. Therefore, the years 1700, 1800, 1900 and 2100 
         * are not leap years, but 1600, 2000, and 2400 are leap years.
         */
        $this->assertEqual(DateHelper::distance_of_time_in_words('2100-02-01', '2100-03-01'), '28 days');
        $this->assertEqual(DateHelper::distance_of_time_in_words('2096-02-01', '2096-03-01'), '29 days');
        $this->assertEqual(DateHelper::distance_of_time_in_words('2000-02-01', '2000-03-01'), '29 days');
        $this->assertEqual(DateHelper::distance_of_time_in_words('2100-02-01 01:00:00', '2100-02-01 02:50:00'), 'about 2 hours');
        $this->assertEqual(DateHelper::distance_of_time_in_words('2100-02-01 01:00:00', '2100-02-01 02:50:00'), 'about 2 hours');
        $Person =& new MockAkActiveRecord($this);
        $Person->setReturnValue('get', '1978-06-16 04:37:00', array('date'));
        $DateHelper = new DateHelper(array('person' => &$Person));
        $this->assertEqual(join(array_diff(explode("\n", $DateHelper->date_select('person', 'date')), array(''))), join(array_diff(explode("\n", '<select name="person[date(1i)]">
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>
<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978" selected="selected">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
</select>
<select name="person[date(2i)]">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June" selected="selected">June</option>
<option value="July">July</option>
<option value="August">August</option>

<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>

<select name="person[date(3i)]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>

<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>

<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16" selected="selected">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>

<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>

<option value="31">31</option>
</select>

'), array(''))));
        $this->assertEqual(join(array_diff(explode("\n", $DateHelper->date_select('person', 'date', array('include_blank' => true, 'discard_day' => true, 'order' => array('month', 'year')))), array(''))), join(array_diff(explode("\n", '<select name="person[date(2i)]">
<option value=""></option>
<option value="January">January</option>
<option value="February">February</option>

<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June" selected="selected">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>

<option value="December">December</option>
</select>

<select name="person[date(1i)]">
<option value=""></option>
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>
<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978" selected="selected">1978</option>

<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
</select>'), array(''))));
        $this->assertEqual(join(array_diff(explode("\n", $DateHelper->datetime_select('person', 'date')), array(''))), join(array_diff(explode("\n", '<select name="person[date(1i)]">
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>

<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978" selected="selected">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
</select>

<select name="person[date(2i)]">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June" selected="selected">June</option>
<option value="July">July</option>
<option value="August">August</option>

<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>

<select name="person[date(3i)]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>

<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>

<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16" selected="selected">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>

<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>

<option value="31">31</option>
</select>

 &mdash; <select name="person[date(4i)]">
<option value="00">00</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04" selected="selected">04</option>

<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>

<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>

<option value="23">23</option>
</select>

 : <select name="person[date(5i)]">
<option value="00">00</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>

<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>

<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>

<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>

<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37" selected="selected">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>

<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>

<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>

<option value="59">59</option>
</select>'), array(''))));
        //$ActiveRecord->tally();
        $date = '1978-06-16 12:20:30';
        $this->assertEqual(join(array_diff(explode("\n", DateHelper::select_datetime($date) . DateHelper::select_date($date) . DateHelper::select_time($date) . DateHelper::select_second($date) . DateHelper::select_minute($date) . DateHelper::select_hour($date) . DateHelper::select_day($date) . DateHelper::select_month($date) . DateHelper::select_year($date)), array(''))), join(array_diff(explode("\n", '<select name="dateyear">
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>

<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978" selected="selected">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
</select>

<select name="datemonth">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June" selected="selected">June</option>
<option value="July">July</option>
<option value="August">August</option>

<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<select name="dateday">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>

<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>

<option value="14">14</option>
<option value="15">15</option>
<option value="16" selected="selected">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>

<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>

</select>
<select name="datehour">
<option value="00">00</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>

<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12" selected="selected">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>

<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
<select name="dateminute">
<option value="00">00</option>

<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>

<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>

<option value="19">19</option>
<option value="20" selected="selected">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>

<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>

<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>

<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>

<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
<select name="dateyear">
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>

<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978" selected="selected">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
</select>

<select name="datemonth">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June" selected="selected">June</option>
<option value="July">July</option>
<option value="August">August</option>

<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<select name="dateday">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>

<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>

<option value="14">14</option>
<option value="15">15</option>
<option value="16" selected="selected">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>

<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>

</select>
<select name="datehour">
<option value="00">00</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>

<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12" selected="selected">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>

<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
<select name="dateminute">
<option value="00">00</option>

<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>

<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>

<option value="19">19</option>
<option value="20" selected="selected">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>

<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>

<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>

<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>

<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
<select name="datesecond">
<option value="00">00</option>
<option value="01">01</option>
<option value="02">02</option>

<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>

<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>

<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>

<option value="30" selected="selected">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>

<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>

<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>

<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
</select>
<select name="dateminute">
<option value="00">00</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>

<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>

<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20" selected="selected">20</option>
<option value="21">21</option>
<option value="22">22</option>

<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>

<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>

<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>

<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>

<option value="59">59</option>
</select>
<select name="datehour">
<option value="00">00</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>

<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12" selected="selected">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>

<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>

<select name="dateday">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>

<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16" selected="selected">16</option>
<option value="17">17</option>

<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>

<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="datemonth">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>

<option value="April">April</option>
<option value="May">May</option>
<option value="June" selected="selected">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>

</select>
<select name="dateyear">
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>
<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978" selected="selected">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>

<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
</select>'), array(''))));
        //echo DateHelper::distance_of_time_in_words('1779-12-01','1780-01-01');
    }
예제 #3
0
 public function test_select_hour()
 {
     $this->assertEqual(DateHelper::select_hour($this->date), file_get_contents(HelperUnitTest::getFixturesDir() . DS . 'date_helper_select_hour.txt'));
 }
예제 #4
0
 /**
  *  Test select_hour()
  *
  *  Test {@link DateHelper::select_hour()} method
  */
 public function testSelect_hour()
 {
     $dh = new DateHelper();
     //  Test generation with all arguments omitted
     $this->assertContains('selected="selected">' . date('H'), $dh->select_hour());
     //  Test generation with 17 selected, default format
     $this->assertEquals('<select name="hour">' . "\n" . '<option value="00">00</option>' . "\n" . '<option value="01">01</option>' . "\n" . '<option value="02">02</option>' . "\n" . '<option value="03">03</option>' . "\n" . '<option value="04">04</option>' . "\n" . '<option value="05">05</option>' . "\n" . '<option value="06">06</option>' . "\n" . '<option value="07">07</option>' . "\n" . '<option value="08">08</option>' . "\n" . '<option value="09">09</option>' . "\n" . '<option value="10">10</option>' . "\n" . '<option value="11">11</option>' . "\n" . '<option value="12">12</option>' . "\n" . '<option value="13">13</option>' . "\n" . '<option value="14">14</option>' . "\n" . '<option value="15">15</option>' . "\n" . '<option value="16">16</option>' . "\n" . '<option value="17"  selected="selected">17</option>' . "\n" . '<option value="18">18</option>' . "\n" . '<option value="19">19</option>' . "\n" . '<option value="20">20</option>' . "\n" . '<option value="21">21</option>' . "\n" . '<option value="22">22</option>' . "\n" . '<option value="23">23</option>' . "\n" . '</select>' . "\n", $dh->select_hour('17'));
     //  Test generation with 12 selected, name change
     $this->assertEquals('<select name="this-hour">' . "\n" . '<option value="00">00</option>' . "\n" . '<option value="01">01</option>' . "\n" . '<option value="02">02</option>' . "\n" . '<option value="03">03</option>' . "\n" . '<option value="04">04</option>' . "\n" . '<option value="05">05</option>' . "\n" . '<option value="06">06</option>' . "\n" . '<option value="07">07</option>' . "\n" . '<option value="08">08</option>' . "\n" . '<option value="09">09</option>' . "\n" . '<option value="10">10</option>' . "\n" . '<option value="11">11</option>' . "\n" . '<option value="12"  selected="selected">12</option>' . "\n" . '<option value="13">13</option>' . "\n" . '<option value="14">14</option>' . "\n" . '<option value="15">15</option>' . "\n" . '<option value="16">16</option>' . "\n" . '<option value="17">17</option>' . "\n" . '<option value="18">18</option>' . "\n" . '<option value="19">19</option>' . "\n" . '<option value="20">20</option>' . "\n" . '<option value="21">21</option>' . "\n" . '<option value="22">22</option>' . "\n" . '<option value="23">23</option>' . "\n" . '</select>' . "\n", $dh->select_hour('12', array('field_name' => 'this-hour')));
     //  Test generation with 09 selected, include blank
     $this->assertEquals('<select name="hour">' . "\n" . '<option value=""></option>' . "\n" . '<option value="00">00</option>' . "\n" . '<option value="01">01</option>' . "\n" . '<option value="02">02</option>' . "\n" . '<option value="03">03</option>' . "\n" . '<option value="04">04</option>' . "\n" . '<option value="05">05</option>' . "\n" . '<option value="06">06</option>' . "\n" . '<option value="07">07</option>' . "\n" . '<option value="08">08</option>' . "\n" . '<option value="09"  selected="selected">09</option>' . "\n" . '<option value="10">10</option>' . "\n" . '<option value="11">11</option>' . "\n" . '<option value="12">12</option>' . "\n" . '<option value="13">13</option>' . "\n" . '<option value="14">14</option>' . "\n" . '<option value="15">15</option>' . "\n" . '<option value="16">16</option>' . "\n" . '<option value="17">17</option>' . "\n" . '<option value="18">18</option>' . "\n" . '<option value="19">19</option>' . "\n" . '<option value="20">20</option>' . "\n" . '<option value="21">21</option>' . "\n" . '<option value="22">22</option>' . "\n" . '<option value="23">23</option>' . "\n" . '</select>' . "\n", $dh->select_hour('09', array('include_blank' => true)));
     //  Test override of hours argument
     //  Simulate 22 parsed from $_REQUEST
     $dh->attribute_name = 'right_this_hour';
     $dh->request_hours['right_this_hour'] = 22;
     //  Test generation with 17 selected, default format
     $this->assertEquals('<select name="hour">' . "\n" . '<option value="00">00</option>' . "\n" . '<option value="01">01</option>' . "\n" . '<option value="02">02</option>' . "\n" . '<option value="03">03</option>' . "\n" . '<option value="04">04</option>' . "\n" . '<option value="05">05</option>' . "\n" . '<option value="06">06</option>' . "\n" . '<option value="07">07</option>' . "\n" . '<option value="08">08</option>' . "\n" . '<option value="09">09</option>' . "\n" . '<option value="10">10</option>' . "\n" . '<option value="11">11</option>' . "\n" . '<option value="12">12</option>' . "\n" . '<option value="13">13</option>' . "\n" . '<option value="14">14</option>' . "\n" . '<option value="15">15</option>' . "\n" . '<option value="16">16</option>' . "\n" . '<option value="17">17</option>' . "\n" . '<option value="18">18</option>' . "\n" . '<option value="19">19</option>' . "\n" . '<option value="20">20</option>' . "\n" . '<option value="21">21</option>' . "\n" . '<option value="22"  selected="selected">22</option>' . "\n" . '<option value="23">23</option>' . "\n" . '</select>' . "\n", $dh->select_hour('17'));
 }
예제 #5
0
 function test_select_hour()
 {
     $this->assertEqual(DateHelper::select_hour($this->date), file_get_contents(AK_TEST_HELPERS_DIR . DS . 'date_helper_select_hour.txt'));
 }