Repository: sallar/jDateTime Branch: master Commit: 74fa0b2c3cfd Files: 9 Total size: 33.6 KB Directory structure: gitextract_5e_8l9_n/ ├── .travis.yml ├── README.md ├── Tests/ │ ├── JDateTimeTest.php │ └── bootstrap.php ├── composer.json ├── examples-static.php ├── examples.php ├── jdatetime.class.php └── phpunit.xml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .travis.yml ================================================ language: php php: # using major version aliases # - 5.2 - 5.3 - 5.4 - 5.5 - 5.6 - hhvm script: phpunit --configuration phpunit.xml --coverage-text ================================================ FILE: README.md ================================================ UNMAINTAINED === :warning: This package is deprecated and unmaintained. Please **DO NOT** use it in production unless it’s absolutely necessary and at your own risk. There are several other modern Shamsi/Jalali date packages out there like [this one](http://farhadi.ir/blog/1389/02/10/persian-calendar-for-php-53/) which you can use. :round_pushpin: If you happen to be a php developer and want to maintain this project, please give me a shout so I can give you write access to this project. # jDateTime PHP class to convert dates from Gregorian calendar system to Jalali calendar system and vice versa. Supports dates beyond 2038. Jalali, also known as Shamsi or Hijri Shamsi is the Iranian calendar system. [](https://travis-ci.org/sallar/jDateTime) # About v2.2.0 PHP's default `date` function does not support years higher than 2038, so the `DateTime` class was introduced in PHP5 to solve this problem and provide more sophisticated date methods. Iranian users have been using an old `jdate` function to convert Gregorian date to the Jalali equivalent, which is completely based on the old php `date` function so its pretty much out-dated. # Requirements jDateTime Requires **PHP >= 5.2** # Installation ## Using Composer You can install this package using [composer](https://getcomposer.org). Add this package to your `composer.json`: ``` "require": { "sallar/jdatetime": "dev-master" } ``` or if you prefer command line, change directory to project root and: ``` php composer.phar require "sallar/jdatetime":"dev-master" ``` ## Manual Installation Get a copy of package source code. You can do this in two ways: 1. Download ZIP version of the source code and unzip it in desired location 2. Run `git clone https://github.com/sallar/jDateTime.git` to clone this repository After getting a copy of source code, it is enough to include `jdatetime.class.php` where you need to use it. ```php require_once 'path/to/source/jdatetime.class.php'; ``` # Examples Please see [examples.php](examples.php) and [example-static.php](examples-static.php) for working examples. # Contributors: - [Sallar Kaboli](http://sallar.me) - [Omid Pilevar](http://pilevar.ir) - [Afshin Mehrabani](http://afshinm.name) - [Amir Latifi](http://amiir.me) - [Ruhollah Namjoo](https://github.com/namjoo) ## License jDateTime was created by [Sallar Kaboli](http://sallar.me) and released under the [MIT License](http://opensource.org/licenses/mit-license.php). Copyright (C) 2016 [Sallar Kaboli](http://sallar.me) Original Jalali to Gregorian (and vice versa) convertor: Copyright (C) 2000 Roozbeh Pournader and Mohammad Toossi The MIT License (MIT) Copyright (C) 2003-2016 Sallar Kaboli Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 1- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 2- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # Resources - [List of supported timezones](http://www.php.net/manual/en/timezones.php) - [Documentation and Instructions in Persian](http://sallar.me/farsi/projects/jdatetime/) ================================================ FILE: Tests/JDateTimeTest.php ================================================ obj = new jDateTime(true, true, 'Asia/Tehran'); } //EOF public function tearDown() { //nothing } public function testMakeJalaliTime() { $time = $this->obj->mktime(0,0,0,10,02,1368); $this->assertEquals($time, 630361800); $this->assertEquals($this->obj->date("l Y/m/d", $time), "شنبه ۱۳۶۸/۱۰/۰۲"); $this->assertEquals($this->obj->date("c", $time, false), "1368-10-02T00:00:00+03:30"); $time = $this->obj->mktime(NULL, NULL, NULL, 10, 14, 1395); $this->assertEquals($time, 1483389000); } public function testMakeGregorianTime() { $time = $this->obj->mktime(0,0,0,1,1,2010, false, 'America/New_York'); $this->assertEquals($time, 1262322000); $this->assertEquals($this->obj->date("c", $time, false, false, 'America/New_York'), "2010-01-01T00:00:00-05:00"); $this->assertEquals($this->obj->date("c", $time, false, false, 'Europe/Berlin'), "2010-01-01T06:00:00+01:00"); } public function testConvertFormatToFormat() { $a = '2016-02-14 14:20:38'; $date = \jDateTime::convertFormatToFormat('Y-m-d H:i:s', 'Y-m-d H:i:s', $a, 'Asia/Tehran'); $this->assertEquals($date, '۱۳۹۴-۱۱-۲۵ ۱۴:۲۰:۳۸'); } } ================================================ FILE: Tests/bootstrap.php ================================================ =5.2.0" }, "autoload": { "classmap": [ "jdatetime.class.php" ] }, "minimum-stability": "dev", "require-dev": { "phpunit/phpunit": "^5.2" } } ================================================ FILE: examples-static.php ================================================ "; echo "
"; echo ""; echo ""; echo ""; date_default_timezone_set('Asia/Tehran'); echo jDateTime::date('l j F Y H:i'); echo "