<commit_before><?php
namespace Concrete\Core\Localization\Service;

use Request;
use \Punic\Calendar;
use Localization;
use User;

class Date
{
    /**
     * The PHP date/time format string to be used when dealing with the database.
     * @var string
     * @see http://php.net/manual/function.date.php
     */
    const DB_FORMAT = 'Y-m-d H:i:s';

    /**
     * Subsitute for the native date() function that adds localized date support
     * @param string $mask
     * @param bool|int $timestamp
     * @return string
     */
    public function date($mask, $timestamp = false)
    {
        if ($timestamp === false) {
            $timestamp = time();
        }
        if (Localization::activeLocale() == 'en_US') {
            return date($mask, $timestamp);
        }

        return Calendar::formatEx(
            $timestamp,
            Calendar::convertPhpToIsoFormat($mask)
        );
    }

    /**
     * Returns a keyed array of timezone identifiers (keys are the standard PHP timezone names, values are the localized timezone names)
     * @return array
     * @see http://www.php.net/datetimezone.listidentifiers.php
     */
    public function getTimezones()
    {
        static $cache = array();
        $locale = Localization::activeLocale();
        if (array_key_exists($locale, $cache)) {
            $result = $cache[$locale];
        } else {
            $result = array();
            $continentNames = array(
                'Africa' => \Punic\Territory::getName('002'),
                'Asia' => \Punic\Territory::getName('142'),
                'America' => \Punic\Territory::getName('019'),
                'Antarctica' => \Punic\Territory::getName('AQ'),
                'Arctic' => t('Arctic'),<commit_msg>Add support for destination timezone to date()<commit_after><?php
namespace Concrete\Core\Localization\Service;

use Request;
use \Punic\Calendar;
use Localization;
use User;

class Date
{
    /**
     * The PHP date/time format string to be used when dealing with the database.
     * @var string
     * @see http://php.net/manual/function.date.php
     */
    const DB_FORMAT = 'Y-m-d H:i:s';

    /**
     * Subsitute for the native date() function that adds localized date support.
     * Use *ONLY* if really needed: you may want to use some of the formatDate/Time methods.
     * If you're not working with timestamps you may want to use the formatCustom method.
     * @param string $mask The PHP format mask
     * @param bool|int $timestamp Use false for the current date/time, otherwise a valid Unix timestamp.
     * @return string
     * @see http://php.net/manual/function.date.php
     */
    public function date($mask, $timestamp = false, $toTimezone = 'system')
    {
        if ($timestamp === false) {
            $timestamp = time();
        }
        $result = '';
        $datetime = $this->toDateTime($timestamp, $toTimezone);
        if (is_object($datetime)) {
            if (Localization::activeLocale() == 'en_US') {
                $result = $datetime->format($mask);
            } else {
                $result = Calendar::format(
                    $datetime,
                    Calendar::convertPhpToIsoFormat($mask)
                );
            }
        }

        return $result;
    }

    /**
     * Returns a keyed array of timezone identifiers (keys are the standard PHP timezone names, values are the localized timezone names)
     * @return array
     * @see http://www.php.net/datetimezone.listidentifiers.php
     */
    public function getTimezones()
    {
        static $cache = array();
        $locale = Localization::activeLocale();
        if (array_key_exists($locale, $cache)) {
            $result = $cache[$locale];
        } else {
            $result = array();
            $continentNames = array(
                'Africa' => \Punic\Territory::getName('002'),
                'Asia' => \Punic\Territory::getName('142'),
                'America' => \Punic\Territory::getName('019'),
                'Antarctica' => \Punic\Territory::getName('AQ'),
                'Arctic' => t('Arctic'),
{'fraction_non_alphanumeric': 0.1295526766071865, 'fraction_numerical': 0.004399902224395014, 'mean_word_length': 2.1236641221374044, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5992804', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1137, 'n_words': 311}