本文整理汇总了PHP中DateTimeUtils::ToString方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeUtils::ToString方法的具体用法?PHP DateTimeUtils::ToString怎么用?PHP DateTimeUtils::ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeUtils
的用法示例。
在下文中一共展示了DateTimeUtils::ToString方法的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: testToString
/**
* @covers DateTimeUtils::ToString
*/
public function testToString()
{
$this->assertEquals($this->stringDate1, DateTimeUtils::ToString($this->dfpDate1));
$this->assertEquals($this->stringDate2, DateTimeUtils::ToString($this->dfpDate2));
$this->assertEquals($this->stringDate3, DateTimeUtils::ToString($this->dfpDate3));
}
示例6: dirname
require_once 'Google/Api/Ads/Dfp/Util/v201511/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
try {
// Get DfpUser from credentials in "../auth.ini"
// relative to the DfpUser.php file's directory.
$user = new DfpUser();
// Log SOAP XML request and response.
$user->LogDefaults();
// Get the ReconciliationReportService.
$reconciliationReportService = $user->GetService('ReconciliationReportService', 'v201511');
// Get the NetworkService.
$networkService = $user->GetService('NetworkService', 'v201511');
$network = $networkService->getCurrentNetwork();
// Create a statement to select the last month's reconciliation report.
$statementBuilder = new StatementBuilder();
$statementBuilder->Where('startDate = :startDate')->OrderBy('id ASC')->Limit(1)->WithBindVariableValue('startDate', DateTimeUtils::ToString(DateTimeUtils::ToDfpDateTime(new DateTime('first day of last month', new DateTimeZone($network->timeZone)))->date));
// Default for total result set size.
$totalResultSetSize = 0;
do {
// Get reconciliation reports by statement.
$page = $reconciliationReportService->getReconciliationReportsByStatement($statementBuilder->ToStatement());
// Display results.
if (isset($page->results)) {
$totalResultSetSize = $page->totalResultSetSize;
$i = $page->startIndex;
foreach ($page->results as $reconciliationReport) {
printf("%d) Reconciliation report with ID %d for month %s/%s was found.\n", $i++, $reconciliationReport->id, $reconciliationReport->startDate->month, $reconciliationReport->startDate->year);
}
}
$statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
} while ($statementBuilder->GetOffset() < $totalResultSetSize);
开发者ID:stevenmaguire,项目名称:googleads-php-lib,代码行数:31,代码来源:GetReconciliationReportForLastBillingPeriod.php