本文整理汇总了PHP中DateTimeUtils::ToStringWithTimeZone方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeUtils::ToStringWithTimeZone方法的具体用法?PHP DateTimeUtils::ToStringWithTimeZone怎么用?PHP DateTimeUtils::ToStringWithTimeZone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeUtils
的用法示例。
在下文中一共展示了DateTimeUtils::ToStringWithTimeZone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateValue
/**
* @covers Pql::CreateValue
*/
public function testCreateValue()
{
$this->assertEquals('hello', Pql::CreateValue(new TextValue('hello'))->value);
$this->assertEquals('value1', Pql::CreateValue('value1')->value);
$this->assertEquals(false, Pql::CreateValue(false)->value);
$this->assertEquals('1', Pql::CreateValue(1)->value);
$this->assertEquals('1.02', Pql::CreateValue(1.02)->value);
$this->assertEquals('2012-12-02T12:45:00+08:00', DateTimeUtils::ToStringWithTimeZone(Pql::CreateValue($this->dateTime1)->value));
$this->assertEquals('2012-12-02', DateTimeUtils::ToString(Pql::CreateValue($this->dateTime1->date)->value));
}
示例2: testCreateValue
/**
* @covers Pql::CreateValue
*/
public function testCreateValue()
{
$this->assertEquals('hello', Pql::CreateValue(new TextValue('hello'))->value);
$this->assertEquals('value1', Pql::CreateValue('value1')->value);
$this->assertEquals(false, Pql::CreateValue(false)->value);
$this->assertEquals('1', Pql::CreateValue(1)->value);
$this->assertEquals('1.02', Pql::CreateValue(1.02)->value);
$this->assertEquals('2012-12-02T12:45:00+08:00', DateTimeUtils::ToStringWithTimeZone(Pql::CreateValue($this->dateTime1)->value));
$this->assertEquals('2012-12-02', DateTimeUtils::ToString(Pql::CreateValue($this->dateTime1->date)->value));
$values = Pql::CreateValue([23, 42, 5, 10, 1])->values;
$this->assertEquals(5, count($values));
$this->assertEquals(23, $values[0]->value);
$this->assertEquals(42, $values[1]->value);
$this->assertEquals(5, $values[2]->value);
$this->assertEquals(10, $values[3]->value);
$this->assertEquals(1, $values[4]->value);
}
示例3: ToString
/**
* Creates a String from the Value.
*
* @param Value $value the value to convert
* @return string the string representation of the value
* @throws InvalidArgumentException if value cannot be converted
*/
public static function ToString(Value $value)
{
if ($value instanceof BooleanValue) {
return $value->value ? 'true' : 'false';
} else {
if ($value instanceof NumberValue || $value instanceof TextValue) {
return strval($value->value);
} else {
if ($value instanceof DateTimeValue) {
return isset($value->value) ? DateTimeUtils::ToStringWithTimeZone($value->value) : '';
} else {
if ($value instanceof DateValue) {
return DateTimeUtils::ToString($value->value);
} else {
throw new InvalidArgumentException(sprintf("Unsupported Value type [%s]", get_class($value)));
}
}
}
}
}
示例4: ToString
/**
* Creates a String from the Value.
*
* @param Value $value the value to convert
* @return string the string representation of the value
* @throws InvalidArgumentException if value cannot be converted
*/
public static function ToString(Value $value)
{
if ($value instanceof BooleanValue) {
return $value->value ? 'true' : 'false';
} else {
if ($value instanceof NumberValue || $value instanceof TextValue) {
return strval($value->value);
} else {
if ($value instanceof DateTimeValue) {
return isset($value->value) ? DateTimeUtils::ToStringWithTimeZone($value->value) : '';
} else {
if ($value instanceof DateValue) {
return DateTimeUtils::ToString($value->value);
} else {
if ($value instanceof SetValue) {
$pqlValues = $value->values;
if (!isset($pqlValues)) {
return '';
} else {
$valuesAsStrings = array();
foreach ($pqlValues as $pqlValue) {
$valuesAsStrings[] = self::ToString($pqlValue);
}
return implode(',', $valuesAsStrings);
}
} else {
throw new InvalidArgumentException(sprintf("Unsupported Value type [%s]", get_class($value)));
}
}
}
}
}
}
示例5: testToStringWithTimeZone
/**
* @covers DateTimeUtils::ToStringWithTimeZone
*/
public function testToStringWithTimeZone()
{
$this->assertEquals($this->stringDateTimeWithTimeZone1, DateTimeUtils::ToStringWithTimeZone($this->dfpDateTime1));
$this->assertEquals($this->stringDateTimeWithTimeZone2, DateTimeUtils::ToStringWithTimeZone($this->dfpDateTime2));
$this->assertEquals($this->stringDateTimeWithTimeZone3, DateTimeUtils::ToStringWithTimeZone($this->dfpDateTime3));
}
示例6: DfpUser
// relative to the DfpUser.php file's directory.
$user = new DfpUser();
// Log SOAP XML request and response.
$user->LogDefaults();
$proposalService = $user->GetService('ProposalService', 'v201608');
// Create a statement to select Marketplace comments.
$statementBuilder = new StatementBuilder();
$statementBuilder->Where('proposalId = :proposalId')->WithBindVariableValue('proposalId', $proposalId);
// Retrieve a small amount of Marketplace comments at a time, paging through
// until all comments have been retrieved.
$totalResultSetSize = 0;
do {
$page = $proposalService->getMarketplaceCommentsByStatement($statementBuilder->ToStatement());
if ($page->results !== null) {
// Print out some information for each Marketplace comment.
$totalResultSetSize = $page->totalResultSetSize;
$i = $page->startIndex;
foreach ($page->results as $marketplaceComment) {
printf("%d) Marketplace comment with creation time '%s' and comment '%s' " . "was found.\n", $i++, DateTimeUtils::ToStringWithTimeZone($marketplaceComment->creationTime), $marketplaceComment->comment);
}
}
$statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
} while ($statementBuilder->GetOffset() < $totalResultSetSize);
printf("Number of results found: %d\n", $totalResultSetSize);
} catch (OAuth2Exception $e) {
ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
ExampleUtils::CheckForOAuth2Errors($e);
} catch (Exception $e) {
printf("%s\n", $e->getMessage());
}