PHP Класс Morilog\Jalali\jDateTime

Requires PHP >= 5.2 PHP's default 'date' function does not support years higher than 2038. Intorduced in PHP5, DateTime class supports higher years and also invalid date entries. Also, Persian users are using classic 'jdate' function for years now and beside the fact that it's amazing and also helped me to write this one, it's really out of date, and can't be used in modern real world web applications as it is completely written in functions. Copyright (C) 2012 Sallar Kaboli (http://sallar.me) Part of Phoenix Framework (p5x.org) by Phoenix Alternatvie Original Jalali to Gregorian (and vice versa) convertor: Copyright (C) 2000 Roozbeh Pournader and Mohammad Toossi List of supported timezones can be found here: http://www.php.net/manual/en/timezones.php PHP version 5 LICENSE: This source file is subject to version 3.01 of the PHP license that is available through the world-wide-web at the following URI: http://www.php.net/license/3_01.txt. If you did not receive a copy of the PHP License and are unable to obtain it through the web, please send a note to [email protected] so we can mail you a copy immediately.
См. также: DateTime
Автор: Sallar Kaboli ([email protected])
Автор: Omid Pilevar ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
checkDate ( $year, $month, $day, boolean $isJalali = true ) : boolean Checks whether a date is valid or not.
convertNumbers ( string $string ) : string Convert Latin numbers to persian numbers
createCarbonFromFormat ( $format, $str, null $timezone = null ) : Carbon\Carbon
createDateTime ( $timestamp = null, null $timezone = null ) : DateTime | static
createDatetimeFromFormat ( $format, $str, null $timezone = null ) : DateTime
createTimeZone ( null $timezone = null ) : DateTimeZone | null
d2g ( $jdn ) : array
d2j ( integer $jdn ) : array Converts the Julian Day number to a date in the Jalaali calendar.
date ( $format, boolean $stamp = false, boolean $timezone = null ) : mixed
div ( $a, $b ) : float
g2d ( integer $gy, integer $gm, integer $gd ) : integer Calculates the Julian Day number from Gregorian or Julian calendar dates. This integer number corresponds to the noon of the date (i.e. 12 hours of Universal Time).
isLeapJalaliYear ( $jy ) : boolean Is this a leap year or not?
isValidateJalaliDate ( integer $jy, integer $jm, integer $jd ) : boolean Checks whether a Jalaali date is valid or not.
j2d ( integer $jy, integer $jm, integer $jd ) : integer Converts a date of the Jalaali calendar to the Julian Day number.
jalaliCal ( integer $jy ) : array This function determines if the Jalaali (Persian) year is leap (366-day long) or is the common year (365 days), and finds the day in March (Gregorian calendar) of the first day of the Jalaali year (jy).
jalaliMonthLength ( integer $jy, integer $jm ) : integer Number of days in a given month in a Jalaali year.
mod ( $a, $b ) : mixed
parseFromFormat ( $format, $date ) : array
strftime ( $format, boolean $stamp = false, null $timezone = null ) : mixed
toGregorian ( integer $jy, integer $jm, integer $jd ) : array Converts a Jalali date to Gregorian.
toJalali ( $gy, $gm, $gd ) : array Converts a Gregorian date to Jalali.

Приватные методы

Метод Описание
filterArray ( $needle, $haystack, $always = [] )
getDayNames ( $day, $shorten = false, $len = 1, $numeric = false )
getMonthNames ( $month, $shorten = false, $len = 3 )

Описание методов

checkDate() публичный статический метод

Checks whether a date is valid or not.
public static checkDate ( $year, $month, $day, boolean $isJalali = true ) : boolean
$year
$month
$day
$isJalali boolean
Результат boolean

convertNumbers() публичный статический метод

Convert Latin numbers to persian numbers
public static convertNumbers ( string $string ) : string
$string string
Результат string

createCarbonFromFormat() публичный статический метод

public static createCarbonFromFormat ( $format, $str, null $timezone = null ) : Carbon\Carbon
$format
$str
$timezone null
Результат Carbon\Carbon

createDateTime() публичный статический метод

public static createDateTime ( $timestamp = null, null $timezone = null ) : DateTime | static
$timestamp
$timezone null
Результат DateTime | static

createDatetimeFromFormat() публичный статический метод

public static createDatetimeFromFormat ( $format, $str, null $timezone = null ) : DateTime
$format
$str
$timezone null
Результат DateTime

createTimeZone() публичный статический метод

public static createTimeZone ( null $timezone = null ) : DateTimeZone | null
$timezone null
Результат DateTimeZone | null

d2g() публичный статический метод

public static d2g ( $jdn ) : array
$jdn
Результат array

d2j() публичный статический метод

Converts the Julian Day number to a date in the Jalaali calendar.
public static d2j ( integer $jdn ) : array
$jdn integer Julian Day number
Результат array 0: Jalaali year (1 to 3100) 1: Jalaali month (1 to 12) 2: Jalaali day (1 to 29/31)

date() публичный статический метод

public static date ( $format, boolean $stamp = false, boolean $timezone = null ) : mixed
$format
$stamp boolean
$timezone boolean
Результат mixed

div() публичный статический метод

public static div ( $a, $b ) : float
$a
$b
Результат float

g2d() публичный статический метод

The procedure was tested to be good since 1 March, -100100 (of both calendars) up to a few million years into the future.
public static g2d ( integer $gy, integer $gm, integer $gd ) : integer
$gy integer Calendar year (years BC numbered 0, -1, -2, ...)
$gm integer Calendar month (1 to 12)
$gd integer Calendar day of the month (1 to 28/29/30/31)
Результат integer Julian Day number

isLeapJalaliYear() публичный статический метод

Is this a leap year or not?
public static isLeapJalaliYear ( $jy ) : boolean
$jy
Результат boolean

isValidateJalaliDate() публичный статический метод

Checks whether a Jalaali date is valid or not.
public static isValidateJalaliDate ( integer $jy, integer $jm, integer $jd ) : boolean
$jy integer
$jm integer
$jd integer
Результат boolean

j2d() публичный статический метод

Converts a date of the Jalaali calendar to the Julian Day number.
public static j2d ( integer $jy, integer $jm, integer $jd ) : integer
$jy integer Jalaali year (1 to 3100)
$jm integer Jalaali month (1 to 12)
$jd integer Jalaali day (1 to 29/31)
Результат integer Julian Day number

jalaliCal() публичный статический метод

This function determines if the Jalaali (Persian) year is leap (366-day long) or is the common year (365 days), and finds the day in March (Gregorian calendar) of the first day of the Jalaali year (jy).
public static jalaliCal ( integer $jy ) : array
$jy integer Jalaali calendar year (-61 to 3177)
Результат array leap: number of years since the last leap year (0 to 4) gy: Gregorian year of the beginning of Jalaali year march: the March day of Farvardin the 1st (1st day of jy)

jalaliMonthLength() публичный статический метод

Number of days in a given month in a Jalaali year.
public static jalaliMonthLength ( integer $jy, integer $jm ) : integer
$jy integer
$jm integer
Результат integer

mod() публичный статический метод

public static mod ( $a, $b ) : mixed
$a
$b
Результат mixed

parseFromFormat() публичный статический метод

public static parseFromFormat ( $format, $date ) : array
$format
$date
Результат array

strftime() публичный статический метод

public static strftime ( $format, boolean $stamp = false, null $timezone = null ) : mixed
$format
$stamp boolean
$timezone null
Результат mixed

toGregorian() публичный статический метод

Converts a Jalali date to Gregorian.
public static toGregorian ( integer $jy, integer $jm, integer $jd ) : array
$jy integer
$jm integer
$jd integer
Результат array 0: Year 1: Month 2: Day

toJalali() публичный статический метод

Converts a Gregorian date to Jalali.
public static toJalali ( $gy, $gm, $gd ) : array
$gy
$gm
$gd
Результат array 0: Year 1: Month 2: Day