sorkh.shahin/jalalicalendar

v3.0.1 2021-06-20 17:44 UTC

This package is auto-updated.

Last update: 2024-04-20 23:57:40 UTC


README

A php native-like package for use of Persians and everyone who uses Jalali calendar and wants to get rid of Arabic characters in their php applications.

Installation

You can use composer to install this calendar

$ composer require sorkh.shahin/jalalicalendar

Usage

This package is under ShSo\Jalali namespace and does two things:

  1. Provides Jalali date/time using ShSo\Jalali\DateTime class
  2. Converts English and Arabic numbers to Persian and vice versa using ShSo\Jalali\Converter class

How to use

All methods and functionalities are static methods of the classes ShSo\Jalali\DateTime and ShSo\Jalali\Converter

ShSo\Jalali\DateTime provides:

  • date() Jalali equivalent of php native date() function with options to choose whether use Persian numbers and choose different timezone
  • strftime() Jalali equivalent of php native strftime() function with options to choose whether use Persian numbers
  • mktime() Jalali equivalent of php native mktime() function
  • checkdate() Jalali equivalent of php native checkdate() function
  • getdate() Jalali equivalent of php native getdate() function
  • gregorianToJalali() Converts Gregorian date to Jalali
  • jalaliToGregorian() Converts Jalali date to Gregorian
  • dayOfYear() Returns number of passed days since the start of the year, dayOfYear(6,8) returns 163
  • isLeapYear() Returns true if the given year is leap or false otherwise
  • dayOfMonth() Returns number of days in the month, dayOfMonth(12,1395) returns 30
  • getMonthName() Returns the name of the month, whether in full or short and in Persian or English
  • getWeekName() Returns day of week in Gregorian order whether in Persian or English
  • getShortWeekName() Returns day of week in Gregorian order in 3 letters whether in Persian or English

ShSo\Jalali\Converter provides:

  • numToPersian() Converts all numbers whether in English or Arabic to Persian
  • numToEnglish() Converts all numbers whether in Arabic or Persian to English
  • arabicToPersian() Converts ('ي', 'ك', 'ة') to ('ی', 'ک', 'ه') and ('٤', '٥', '٦') to ('۴', '۵', '۶')

License

This package is under MIT License.