# wp-parsely/3.16.3/src/Metadata/class-date-builder.php

Parse.ly, version 3.16.3. 63 lines.

- Page: https://pluginprobe.com/plugins/wp-parsely/3.16.3/code/src/Metadata/class-date-builder.php
- Raw: https://pluginprobe.com/plugins/wp-parsely/3.16.3/raw/src/Metadata/class-date-builder.php
- Modified: 2023-02-27T12:36:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-parsely/3.16.3/code/src/Metadata/class-date-builder.php#L10-L20`.

```php
<?php
/**
 * Date Page Metadata Builder class
 *
 * @package Parsely
 * @since 3.4.0
 */

declare(strict_types=1);

namespace Parsely\Metadata;

use function Parsely\Utils\get_date_format;
use function Parsely\Utils\get_time_format;

/**
 * Implements abstract Metadata Builder class to generate the metadata array
 * for a date page.
 *
 * @since 3.4.0
 */
class Date_Builder extends Metadata_Builder {
	/**
	 * Generates the metadata object by calling the build_* methods and
	 * returns the value.
	 *
	 * @since 3.4.0
	 *
	 * @return array<string, mixed>
	 */
	public function get_metadata(): array {
		$this->build_basic();
		$this->build_headline();
		$this->build_url();

		return $this->metadata;
	}

	/**
	 * Populates the `headline` field in the metadata object.
	 *
	 * @since 3.4.0
	 */
	private function build_headline(): void {
		$site_date_format = get_date_format();

		if ( is_year() ) {
			/* translators: %s: Archive year */
			$this->metadata['headline'] = sprintf( __( 'Yearly Archive - %s', 'wp-parsely' ), get_the_time( 'Y' ) );
		} elseif ( is_month() ) {
			/* translators: %s: Archive month, formatted as F, Y */
			$this->metadata['headline'] = sprintf( __( 'Monthly Archive - %s', 'wp-parsely' ), get_the_time( 'F, Y' ) );
		} elseif ( is_day() ) {
			/* translators: %s: Archive day, formatted as F jS, Y */
			$this->metadata['headline'] = sprintf( __( 'Daily Archive - %s', 'wp-parsely' ), get_the_time( $site_date_format ) );
		} elseif ( is_time() ) {
			$site_time_format = get_time_format();
			/* translators: %s: Archive time, formatted as F jS g:i:s A */
			$this->metadata['headline'] = sprintf( __( 'Hourly, Minutely, or Secondly Archive - %s', 'wp-parsely' ), get_the_time( "{$site_date_format} {$site_time_format}" ) );
		}
	}
}

```
