/** * Answer the name of the month. * * @return string * @access public * @since 5/3/05 */ function monthName() { return Month::nameOfMonth($this->month()); }
/** * Print the dateRange form * * @param object DateAndTime $startDate * @param object DateAndTime $endDate * @return void * @access public * @since 3/8/06 */ function printDateRangeForm($startDate, $endDate) { $min = $this->minDate(); $max = DateAndTime::tomorrow(); $harmoni = Harmoni::instance(); print "\n<form action='"; $harmoni->request->forget('startYear'); $harmoni->request->forget('startMonth'); $harmoni->request->forget('startDay'); $harmoni->request->forget('startHour'); $harmoni->request->forget('endYear'); $harmoni->request->forget('endMonth'); $harmoni->request->forget('endDay'); $harmoni->request->forget('endHour'); print $harmoni->request->quickURL('logs', 'browse'); $harmoni->request->passthrough('log', 'priority', 'startYear', 'startMonth', 'startDay', 'startHour', 'endYear', 'endMonth', 'endDay', 'endHour', 'agent_id', 'node_id', 'category'); print "' method='post'>"; print "\n\t<select name='" . RequestContext::name("startMonth") . "'>"; $month = 1; while ($month <= 12) { print "\n\t\t<option value='" . $month . "'"; print $month == $startDate->month() ? " selected='selected'" : ""; print ">" . Month::nameOfMonth($month) . "</option>"; $month++; } print "\n\t</select>"; print "\n\t<select name='" . RequestContext::name("startDay") . "'>"; $day = 1; while ($day <= 31) { print "\n\t\t<option value='" . $day . "'"; print $day == $startDate->dayOfMonth() ? " selected='selected'" : ""; print ">" . $day . "</option>"; $day++; } print "\n\t</select>"; print "\n\t<select name='" . RequestContext::name("startYear") . "'>"; $year = $max->year(); $minYear = $min->year(); while ($year >= $minYear) { print "\n\t\t<option value='" . $year . "'"; print $year == $startDate->year() ? " selected='selected'" : ""; print ">{$year}</option>"; $year--; } print "\n\t</select>"; print "\n\t<select name='" . RequestContext::name("startHour") . "'>"; $hour = 0; while ($hour <= 23) { print "\n\t\t<option value='" . $hour . "'"; print $hour == $startDate->hour() ? " selected='selected'" : ""; print ">" . sprintf("%02d", $hour) . ":00</option>"; $hour++; } print "\n\t</select>"; print "\n\t<strong> to: </strong>"; print "\n\t<select name='" . RequestContext::name("endMonth") . "'>"; $month = 1; while ($month <= 12) { print "\n\t\t<option value='" . $month . "'"; print $month == $endDate->month() ? " selected='selected'" : ""; print ">" . Month::nameOfMonth($month) . "</option>"; $month++; } print "\n\t</select>"; print "\n\t<select name='" . RequestContext::name("endDay") . "'>"; $day = 1; while ($day <= 31) { print "\n\t\t<option value='" . $day . "'"; print $day == $endDate->dayOfMonth() ? " selected='selected'" : ""; print ">" . $day . "</option>"; $day++; } print "\n\t</select>"; print "\n\t<select name='" . RequestContext::name("endYear") . "'>"; $year = $max->year(); $minYear = $min->year(); while ($year >= $minYear) { print "\n\t\t<option value='" . $year . "'"; print $year == $endDate->year() ? " selected='selected'" : ""; print ">{$year}</option>"; $year--; } print "\n\t</select>"; print "\n\t<select name='" . RequestContext::name("endHour") . "'>"; $hour = 0; while ($hour <= 23) { print "\n\t\t<option value='" . $hour . "'"; print $hour == $endDate->hour() ? " selected='selected'" : ""; print ">" . sprintf("%02d", $hour) . ":00</option>"; $hour++; } print "\n\t</select>"; print "\n\t<input type='submit' value='" . _("Set Range") . "'/>"; print "\n\t<a href='"; print $harmoni->request->quickURL('logs', 'browse', array('startYear' => $min->year(), 'startMonth' => $min->month(), 'startDay' => $min->dayOfMonth(), 'startHour' => $min->hour(), 'endYear' => $max->year(), 'endMonth' => $max->month(), 'endDay' => $max->dayOfMonth(), 'endHour' => $max->hour())); print "'>"; print "\n\t\t<input type='button' value='" . _("Clear") . "' />"; print "</a>"; print "\n</form>"; }
/** * Print a description of the receiver on aStream using the format * denoted the argument, formatArray: * * array(item, item, item, sep, monthfmt, yearfmt, twoDigits) * * items: 1=day 2=month 3=year will appear in the order given, * * separated by sep which is eaither an ascii code or character. * * monthFmt: 1=09 2=Sep 3=September * * yearFmt: 1=1996 2=96 * * digits: (missing or)1=9 2=09. * * See the examples in printOn: and mmddyy * * @param array $formatArray * @return string * @access public * @since 5/20/05 */ function printableStringWithFormat($formatArray) { $result = ''; $twoDigits = count($formatArray) > 6 && $formatArray[6] > 1; $monthFormat = $formatArray[4]; $yearFormat = $formatArray[5]; $separator = $formatArray[3]; for ($i = 0; $i < 3; $i++) { $element = $formatArray[$i]; switch ($element) { case 1: if ($twoDigits) { $result .= str_pad($this->dayOfMonth(), 2, '0', STR_PAD_LEFT); } else { $result .= $this->dayOfMonth(); } break; case 2: if ($monthFormat == 1) { if ($twoDigits) { $result .= str_pad($this->startMonth(), 2, '0', STR_PAD_LEFT); } else { $result .= $this->startMonth(); } } else { if ($monthFormat == 2) { $result .= substr(Month::nameOfMonth($this->startMonth()), 0, 3); } else { if ($monthFormat == 3) { $result .= Month::nameOfMonth($this->startMonth()); } } } break; case 3: if ($yearFormat == 2) { $result .= str_pad($this->startYear() % 100, 2, '0', STR_PAD_LEFT); } else { $result .= $this->startYear(); } } if ($i < 2 && $separator) { $result .= $separator; } } return $result; }