HEX
Server: LiteSpeed
System: Linux s383.bitcommand.com 5.14.0-687.24.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jul 9 18:14:06 EDT 2026 x86_64
User: pclast (1605)
PHP: 8.1.34
Disabled: exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/pclast/public_html/wp-content/themes/irankala/vendor/morilog/jalali/src/Converter.php
<?php

namespace Morilog\Jalali;

use Carbon\Exceptions\UnitException;
use Date;

/**
 * Trait Converter.
 *
 * Change date into different string formats and types and
 * handle the string cast.
 */
trait Converter
{

    /**
     * Format the instance as date
     *
     * @return string
     */
    public function toDateString()
    {
        return $this->format("Y/m/d");
    }

    /**
     * Format the instance as a readable date
     *
     * @return string
     */
    public function toFormattedDateString()
    {
        return $this->format('j F Y');
    }

    /**
     * Format the instance with the day, and a readable date
     *
     * @return string
     */
    public function toFormattedDayDateString()
    {
        return $this->format('l j F Y');
    }

    /**
     * Format the instance as time
     *
     * @param string $unitPrecision
     *
     * @return string
     */
    public function toTimeString($unitPrecision = 'second')
    {
        return $this->format(static::getTimeFormatByPrecision($unitPrecision));
    }

    /**
     * Format the instance as date and time
     *
     * @param string $unitPrecision
     *
     * @return string
     */
    public function toDateTimeString($unitPrecision = 'second')
    {
        return $this->format('Y/m/d ' . static::getTimeFormatByPrecision($unitPrecision));
    }

    /**
     * Format the instance as a readable date and time
     *
     * @param string $unitPrecision
     *
     * @return string
     */
    public function toFormattedDateTimeString($unitPrecision = 'second')
    {
        return $this->format('j F Y ' . static::getTimeFormatByPrecision($unitPrecision));
    }

    /**
     * Return a format from H:i to H:i:s.u according to given unit precision.
     *
     * @param string $unitPrecision "minute", "second", "millisecond" or "microsecond"
     *
     * @return string
     */
    public static function getTimeFormatByPrecision($unitPrecision)
    {
        switch (Date::singularUnit($unitPrecision)) {
            case 'minute':
                return 'H:i';
            case 'second':
                return 'H:i:s';
            case 'm':
            case 'millisecond':
                return 'H:i:s.v';
            case 'ยต':
            case 'microsecond':
                return 'H:i:s.u';
        }

        throw new UnitException('Precision unit expected among: minute, second, millisecond and microsecond.');
    }

    /**
     * Format the instance as date and time T-separated with no timezone
     * echo Jalalian::now()->toDateTimeLocalString('minute'); // You can specify precision among: minute, second, millisecond and microsecond
     * ```
     *
     * @param string $unitPrecision
     *
     * @return string
     */
    public function toDateTimeLocalString($unitPrecision = 'second')
    {
        return $this->format('Y-m-d\T' . static::getTimeFormatByPrecision($unitPrecision));
    }

    /**
     * Format the instance with day, date and time
     *
     * @param string $unitPrecision
     *
     * @return string
     */
    public function toDayDateTimeString($unitPrecision = 'second')
    {
        return $this->format('l j F Y ' . static::getTimeFormatByPrecision($unitPrecision));
    }

    /**
     * Format the instance with the year, and a readable month
     *
     * @return string
     */
    public function toFormattedMonthYearString()
    {
        return $this->format('F Y');
    }

}