本文整理汇总了PHP中QDateTime::IsTimeNull方法的典型用法代码示例。如果您正苦于以下问题:PHP QDateTime::IsTimeNull方法的具体用法?PHP QDateTime::IsTimeNull怎么用?PHP QDateTime::IsTimeNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::IsTimeNull方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Q
public static function Q(QDateTime $objQDateTime)
{
if ($objQDateTime->IsTimeNull()) {
//error_log("NotNUll: " . sprintf("'%s'", $objQDateTime->__toString('YYYY-MM-DD')));
return $objQDateTime->__toString('YYYY-MM-DD');
} else {
//error_log("IS NULL: " . sprintf("'%s'", $objQDateTime->__toString(QDateTime::FormatIso)));
return $objQDateTime->__toString(QDateTime::FormatIso);
}
}
示例2: testIncompleteDates
public function testIncompleteDates()
{
$obj1 = new QDateTime("Feb 12");
$this->assertFalse($obj1->IsNull());
$this->assertFalse($obj1->IsDateNull());
$this->assertTrue($obj1->IsTimeNull());
$obj2 = new QDateTime("March 2003");
$this->assertFalse($obj2->IsNull());
$this->assertFalse($obj2->IsDateNull());
$this->assertTrue($obj2->IsTimeNull());
}
示例3: GetControlHtml
//.........这里部分代码省略.........
} else {
$strSelected = '';
}
$strDayListbox .= sprintf('<option value="%s"%s>%s</option>', $intDay, $strSelected, $intDay);
}
}
$strDayListbox .= '</select>';
// Year
$strYearListbox = sprintf('<select name="%s_lstYear" id="%s_lstYear" class="year" %s%s>', $this->strControlId, $this->strControlId, $strAttributes, $strCommand);
if (!$this->blnRequired || $dttDateTime->IsDateNull()) {
$strYearListbox .= '<option value="">--</option>';
}
for ($intYear = $this->intMinimumYear; $intYear <= $this->intMaximumYear; $intYear++) {
if ($dttDateTime->Year == $intYear || $this->intSelectedYear == $intYear) {
$strSelected = ' selected="selected"';
} else {
$strSelected = '';
}
$strYearListbox .= sprintf('<option value="%s"%s>%s</option>', $intYear, $strSelected, $intYear);
}
$strYearListbox .= '</select>';
// Put it all together
switch ($this->strDateTimePickerFormat) {
case QDateTimePickerFormat::MonthDayYear:
$strToReturn .= $strMonthListbox . $strDayListbox . $strYearListbox;
break;
case QDateTimePickerFormat::DayMonthYear:
$strToReturn .= $strDayListbox . $strMonthListbox . $strYearListbox;
break;
case QDateTimePickerFormat::YearMonthDay:
$strToReturn .= $strYearListbox . $strMonthListbox . $strDayListbox;
break;
}
}
switch ($this->strDateTimePickerType) {
case QDateTimePickerType::DateTime:
case QDateTimePickerType::DateTimeSeconds:
$strToReturn .= '<span class="divider"></span>';
}
switch ($this->strDateTimePickerType) {
case QDateTimePickerType::Time:
case QDateTimePickerType::TimeSeconds:
case QDateTimePickerType::DateTime:
case QDateTimePickerType::DateTimeSeconds:
// Hour
$strHourListBox = sprintf('<select name="%s_lstHour" id="%s_lstHour" class="hour" %s>', $this->strControlId, $this->strControlId, $strAttributes);
if (!$this->blnRequired || $dttDateTime->IsTimeNull()) {
$strHourListBox .= '<option value="">--</option>';
}
for ($intHour = 0; $intHour <= 23; $intHour++) {
if (!$dttDateTime->IsTimeNull() && $dttDateTime->Hour == $intHour) {
$strSelected = ' selected="selected"';
} else {
$strSelected = '';
}
$strHourListBox .= sprintf('<option value="%s"%s>%s</option>', $intHour, $strSelected, date('g A', mktime($intHour, 0, 0, 1, 1, 2000)));
}
$strHourListBox .= '</select>';
// Minute
$strMinuteListBox = sprintf('<select name="%s_lstMinute" id="%s_lstMinute" class="minute" %s>', $this->strControlId, $this->strControlId, $strAttributes);
if (!$this->blnRequired || $dttDateTime->IsTimeNull()) {
$strMinuteListBox .= '<option value="">--</option>';
}
for ($intMinute = 0; $intMinute <= 59; $intMinute++) {
if (!$dttDateTime->IsTimeNull() && $dttDateTime->Minute == $intMinute) {
$strSelected = ' selected="selected"';
} else {
$strSelected = '';
}
$strMinuteListBox .= sprintf('<option value="%s"%s>%02d</option>', $intMinute, $strSelected, $intMinute);
}
$strMinuteListBox .= '</select>';
// Seconds
$strSecondListBox = sprintf('<select name="%s_lstSecond" id="%s_lstSecond" class="second" %s>', $this->strControlId, $this->strControlId, $strAttributes);
if (!$this->blnRequired || $dttDateTime->IsTimeNull()) {
$strSecondListBox .= '<option value="">--</option>';
}
for ($intSecond = 0; $intSecond <= 59; $intSecond++) {
if (!$dttDateTime->IsTimeNull() && $dttDateTime->Second == $intSecond) {
$strSelected = ' selected="selected"';
} else {
$strSelected = '';
}
$strSecondListBox .= sprintf('<option value="%s"%s>%02d</option>', $intSecond, $strSelected, $intSecond);
}
$strSecondListBox .= '</select>';
// PUtting it all together
if ($this->strDateTimePickerType == QDateTimePickerType::DateTimeSeconds || $this->strDateTimePickerType == QDateTimePickerType::TimeSeconds) {
$strToReturn .= $strHourListBox . ':' . $strMinuteListBox . ':' . $strSecondListBox;
} else {
$strToReturn .= $strHourListBox . ':' . $strMinuteListBox;
}
}
if ($this->strCssClass) {
$strCssClass = ' class="' . $this->strCssClass . '"';
} else {
$strCssClass = '';
}
return sprintf('<span id="%s"%s>%s</span>', $this->strControlId, $strCssClass, $strToReturn);
}
示例4: testSetProperties
public function testSetProperties()
{
$obj1 = new QDateTime();
$obj1->setDate(2002, 3, 15);
$this->assertTrue($obj1->IsTimeNull(), "Setting only a date after null constructor keeps time null");
$obj2 = new QDateTime("2002-03-15");
$obj3 = new QDateTime("2002-03-15 13:15");
$obj4 = new QDateTime("2002-03-16");
$this->assertTrue($obj1->IsEqualTo($obj2));
$this->assertTrue($obj1->IsEqualTo($obj3));
// dates are the same!
$this->assertFalse($obj3->IsEqualTo($obj4));
// dates are different!
$obj5 = new QDateTime('13:15:02', null, QDateTime::TimeOnlyType);
$this->assertTrue($obj5->IsDateNull(), "Setting only a date after null constructor keeps time null");
$obj6 = new QDateTime('2002-03-15 13:15:02');
$obj1->SetTime($obj5);
$this->assertFalse($obj1->IsTimeNull(), "Setting a time with object results in a change in null time status");
$this->assertTrue($obj1->IsEqualTo($obj6), "SetTime correctly combines date only and time only values");
}
示例5: setTime
/**
* Sets the time portion to the given time. If a QDateTime is given, will use the time portion of that object.
* Works around a problem in php that if you set the time across a daylight savings time boundary, the timezone
* does not advance. This version will detect that and advance the timezone.
*
* @param int|QDateTime $mixValue
* @param int|null $intMinute
* @param int|null $intSecond
* @return QDateTime
*/
public function setTime($mixValue, $intMinute = null, $intSecond = null)
{
if ($mixValue instanceof QDateTime) {
if ($mixValue->IsTimeNull()) {
$this->blnTimeNull = true;
$this->ReinforceNullProperties();
return $this;
}
// normalize the timezones
$tz = $this->getTimezone();
if ($tz && in_array($tz->getName(), timezone_identifiers_list())) {
// php limits you to ID only timezones here, so make sure we have one of those
$mixValue->setTimezone($tz);
}
$intHour = $mixValue->Hour;
$intMinute = $mixValue->Minute;
$intSecond = $mixValue->Second;
} else {
$intHour = $mixValue;
}
// If HOUR or MINUTE is NULL...
if (is_null($intHour) || is_null($intMinute)) {
parent::setTime($intHour, $intMinute, $intSecond);
$this->blnTimeNull = true;
$this->ReinforceNullProperties();
return $this;
}
$intHour = QType::Cast($intHour, QType::Integer);
$intMinute = QType::Cast($intMinute, QType::Integer);
$intSecond = QType::Cast($intSecond, QType::Integer);
$this->blnTimeNull = false;
/*
// Possible fix for a PHP problem. Can't reproduce, so leaving code here just in case it comes back.
// The problem is with setting times across dst barriers
if ($this->Hour == 0 && preg_match('/[0-9]+/', $this->getTimezone()->getName())) {
// fix a php problem with GMT and relative timezones
$s = 'PT' . $intHour . 'H' . $intMinute . 'M' . $intSecond . 'S';
$this->add (new DateInterval ($s));
// will continue and set again to make sure, because boundary crossing will change the time
}*/
parent::setTime($intHour, $intMinute, $intSecond);
return $this;
}