[
  {
    "path": ".travis.yml",
    "content": "language: php\n\nphp:\n  # using major version aliases\n  # - 5.2\n  - 5.3\n  - 5.4\n  - 5.5\n  - 5.6\n  - hhvm\n\nscript: phpunit --configuration phpunit.xml --coverage-text\n"
  },
  {
    "path": "README.md",
    "content": "UNMAINTAINED\n===\n: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.\n\n: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.\n\n# jDateTime\n\nPHP class to convert dates from Gregorian calendar system to Jalali calendar system and vice versa. Supports dates beyond 2038.  \nJalali, also known as Shamsi or Hijri Shamsi is the Iranian calendar system.  \n[![Build Status](https://travis-ci.org/sallar/jDateTime.png?branch=master)](https://travis-ci.org/sallar/jDateTime)\n\n# About v2.2.0\n\nPHP'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. \n\n# Requirements\n\njDateTime Requires **PHP >= 5.2**  \n\n# Installation\n\n## Using Composer\n\nYou can install this package using [composer](https://getcomposer.org). Add this package to your `composer.json`:  \n\n```\n\"require\": {\n\t\"sallar/jdatetime\": \"dev-master\"\n}\n```\n\nor if you prefer command line, change directory to project root and:\n\n```\nphp composer.phar require \"sallar/jdatetime\":\"dev-master\"\n```\n\n## Manual Installation\n\nGet a copy of package source code. You can do this in two ways:\n\n1. Download ZIP version of the source code and unzip it in desired location  \n2. Run `git clone https://github.com/sallar/jDateTime.git` to clone this repository  \n\nAfter getting a copy of source code, it is enough to include `jdatetime.class.php` where you need to use it.\n\n```php\nrequire_once 'path/to/source/jdatetime.class.php';\n```\n\n# Examples\n\nPlease see [examples.php](examples.php) and [example-static.php](examples-static.php) for working examples.\n\n# Contributors:\n- [Sallar Kaboli](http://sallar.me)  \n- [Omid Pilevar](http://pilevar.ir)\n- [Afshin Mehrabani](http://afshinm.name)  \n- [Amir Latifi](http://amiir.me)\n- [Ruhollah Namjoo](https://github.com/namjoo)\n\n## License\njDateTime was created by [Sallar Kaboli](http://sallar.me) and released under the [MIT License](http://opensource.org/licenses/mit-license.php).\n\nCopyright (C) 2016 [Sallar Kaboli](http://sallar.me)  \n  \nOriginal Jalali to Gregorian (and vice versa) convertor:  \nCopyright (C) 2000  Roozbeh Pournader and Mohammad Toossi\n\n    The MIT License (MIT)\n    \n    Copyright (C) 2003-2016 Sallar Kaboli\n\n    Permission is hereby granted, free of charge, to any person obtaining a\n    copy of this software and associated documentation files (the \"Software\"),\n    to deal in the Software without restriction, including without limitation\n    the rights to use, copy, modify, merge, publish, distribute, sublicense,\n    and/or sell copies of the Software, and to permit persons to whom the\n    Software is furnished to do so, subject to the following conditions:\n\n    1- The above copyright notice and this permission notice shall be included\n    in all copies or substantial portions of the Software.\n    \n    2- THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n    DEALINGS IN THE SOFTWARE.\n\n# Resources\n- [List of supported timezones](http://www.php.net/manual/en/timezones.php)  \n- [Documentation and Instructions in Persian](http://sallar.me/farsi/projects/jdatetime/)  \n"
  },
  {
    "path": "Tests/JDateTimeTest.php",
    "content": "<?php\n\nclass JDateTimeTest extends PHPUnit_Framework_TestCase\n{\n    //Start test\n    public function setUp()\n    {\n        $this->obj = new jDateTime(true, true, 'Asia/Tehran');\n    }\n    //EOF\n    public function tearDown()\n    {\n        //nothing\n    }\n\n    public function testMakeJalaliTime()\n    {\n        $time = $this->obj->mktime(0,0,0,10,02,1368);\n        $this->assertEquals($time, 630361800);\n        $this->assertEquals($this->obj->date(\"l Y/m/d\", $time), \"شنبه ۱۳۶۸/۱۰/۰۲\");\n        $this->assertEquals($this->obj->date(\"c\", $time, false), \"1368-10-02T00:00:00+03:30\");\n        $time = $this->obj->mktime(NULL, NULL, NULL, 10, 14, 1395);\n        $this->assertEquals($time, 1483389000);\n    }\n\n    public function testMakeGregorianTime()\n    {\n        $time = $this->obj->mktime(0,0,0,1,1,2010, false, 'America/New_York');\n        $this->assertEquals($time, 1262322000);\n        $this->assertEquals($this->obj->date(\"c\", $time, false, false, 'America/New_York'), \"2010-01-01T00:00:00-05:00\");\n        $this->assertEquals($this->obj->date(\"c\", $time, false, false, 'Europe/Berlin'), \"2010-01-01T06:00:00+01:00\");\n    }\n\n    public function testConvertFormatToFormat()\n    {\n        $a = '2016-02-14 14:20:38';\n        $date = \\jDateTime::convertFormatToFormat('Y-m-d H:i:s', 'Y-m-d H:i:s', $a, 'Asia/Tehran');\n        $this->assertEquals($date, '۱۳۹۴-۱۱-۲۵ ۱۴:۲۰:۳۸');\n    }\n}\n"
  },
  {
    "path": "Tests/bootstrap.php",
    "content": "<?php\n\nfunction loader($class)\n{\n    $file = dirname(dirname(__FILE__)) .'/'. strtolower($class) . '.class.php';\n    if (file_exists($file)) {\n        require $file;\n    }\n}\n\nspl_autoload_register('loader');"
  },
  {
    "path": "composer.json",
    "content": "{\n    \"name\": \"sallar/jdatetime\",\n    \"type\": \"library\",\n    \"description\": \"Jalali (Shamsi) DateTime class written in PHP, Supports year higher than 2038\",\n    \"keywords\": [\"date\", \"datetime\", \"jalali\", \"jalalidate\", \"jdatetime\",\"shamsi\",\"iran\",\"farsi\",\"persian\",\"time\"],\n    \"homepage\": \"http://sallar.me/projects/jdatetime/\",\n    \"license\": \"MIT\",\n    \"authors\": [\n        {\n            \"name\": \"Sallar Kaboli\",\n            \"email\": \"sallar.kaboli@gmail.com\",\n            \"homepage\": \"http://sallar.me\",\n            \"role\": \"Developer\"\n        }\n    ],\n    \"require\": {\n        \"php\": \">=5.2.0\"\n    },\n    \"autoload\": {\n        \"classmap\": [\n            \"jdatetime.class.php\"\n        ]\n    },\n    \"minimum-stability\": \"dev\",\n    \"require-dev\": {\n        \"phpunit/phpunit\": \"^5.2\"\n    }\n}\n"
  },
  {
    "path": "examples-static.php",
    "content": "<?php\n\n//Include\nrequire_once dirname(__FILE__) . '/jdatetime.class.php';\n\n//Just adding routine html tags and setting encoding to view Persian characters correctly.\necho \"<html>\";\necho \"<head>\";\necho \"<meta charset='utf-8'>\";\necho \"</head>\";\necho \"<body>\";\n\ndate_default_timezone_set('Asia/Tehran');\n\necho jDateTime::date('l j F Y H:i');\necho \"<br />\";\necho jDateTime::date('Y-m-d', false, false);\necho \"<br />\";\necho jDateTime::date('Y-m-d', false, false, false);\necho \"<br />\";\necho jDateTime::date(\"l j F Y H:i T\", false, null, null, 'America/New_York');\n\n//Just adding routine html tags.\necho \"</body>\";\necho \"</html>\";"
  },
  {
    "path": "examples.php",
    "content": "<?php\n\n//Include\nrequire_once dirname(__FILE__) . '/jdatetime.class.php';\n\n//Just add routine html tags and encoding the settings to view Persian characters correctly.\necho \"<html>\";\necho \"<head>\";\necho \"<meta charset='utf-8'>\";\necho \"</head>\";\necho \"<body>\";\n\n//Init\n$date = new jDateTime(true, true, 'Asia/Tehran');\n\necho $date->date(\"l j F Y H:i\"); // Outputs: پنجشنبه ۱۵ اردیبهشت ۱۳۹۰ ۰۰:۰۰\necho \"<br />\\n\";\necho $date->date(\"Y-m-d\", false, false); // Outputs: 1390-02-15\necho \"<br />\\n\";\necho $date->date(\"Y-m-d\", false, false, false); //Outputs: 2011-05-05\n     //Or you could just use: $date->gDate(\"Y-m-d\"); \n     //Same as above\necho \"<br />\\n\";\necho $date->date(\"l j F Y H:i T\", false, null, null, 'America/New_York'); //چهارشنبه ۱۴ اردیبهشت ۱۳۹۰ ۱۵:۳۰ EDT\n\necho \"<br />\\n\";\necho \"<br />\\n\";\n\n$time = $date->mktime(0,0,0,10,2,1368); //630361800\n\necho $date->date(\"l Y/m/d\", $time); //Outputs: شنبه ۱۳۶۸/۱۰/۰۲\necho \"<br />\\n\";\necho $date->date(\"l M jS, Y\", $time, false, false); //Outputs: Saturday Dec 23rd, 1989\n\necho \"<br />\\n\";\necho \"<br />\\n\";\n\n$time2 = $date->mktime(0,0,0,1,1,2010, false, 'America/New_York');  //1262322000\n\necho $date->date(\"c\", $time2, false, false, 'America/New_York'); //Outputs: 2010-01-01T00:00:00-05:00\necho \"<br />\\n\";\n//Lets see whens its January 1st in New York, What Time is it in Berlin?\necho $date->date(\"c\", $time2, false, false, 'Europe/Berlin'); //Outputs: 2010-01-01T06:00:00+01:0\n//Or Iran in Native Time?\necho \"<br />\\n\";\necho $date->date(\"c\", $time2, false, true, 'Asia/Tehran'); //Outputs: 1388-10-11T08:30:00+03:30\n\n//Just adding routine html tags.\necho \"</body>\";\necho \"</html>\";\n"
  },
  {
    "path": "jdatetime.class.php",
    "content": "<?php\n/**\n * Jalali (Shamsi) DateTime Class. Supports years higher than 2038.\n *\n * Copyright (c) 2012 Sallar Kaboli <sallar.kaboli@gmail.com>\n * http://sallar.me\n *\n * The MIT License (MIT)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * 1- The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n * \n * 2- THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n *\n * Original Jalali to Gregorian (and vice versa) convertor:\n * Copyright (C) 2000  Roozbeh Pournader and Mohammad Toossi\n *\n * List of supported timezones can be found here:\n * http://www.php.net/manual/en/timezones.php\n *\n *\n * @package    jDateTime\n * @author     Sallar Kaboli <sallar.kaboli@gmail.com>\n * @author     Omid Pilevar <omid.pixel@gmail.com>\n * @copyright  2003-2012 Sallar Kaboli\n * @license    http://opensource.org/licenses/mit-license.php The MIT License\n * @link       https://github.com/sallar/jDateTime\n * @see        DateTime\n * @version    2.2.0\n */\nclass jDateTime\n{\n\n    /**\n     * Defaults\n     */\n    private static $jalali   = true; //Use Jalali Date, If set to false, falls back to gregorian\n    private static $convert  = true; //Convert numbers to Farsi characters in utf-8\n    private static $timezone = null; //Timezone String e.g Asia/Tehran, Defaults to Server Timezone Settings\n    private static $temp = array();\n\n    /**\n     * jDateTime::Constructor\n     *\n     * Pass these parameteres when creating a new instance\n     * of this Class, and they will be used as defaults.\n     * e.g $obj = new jDateTime(false, true, 'Asia/Tehran');\n     * To use system defaults pass null for each one or just\n     * create the object without any parameters.\n     *\n     * @author Sallar Kaboli\n     * @param $convert bool Converts numbers to Farsi\n     * @param $jalali bool Converts date to Jalali\n     * @param $timezone string Timezone string\n     */\n    public function __construct($convert = null, $jalali = null, $timezone = null)\n    {\n        if ( $jalali   !== null ) self::$jalali   = (bool) $jalali;\n        if ( $convert  !== null ) self::$convert  = (bool) $convert;\n        if ( $timezone !== null ) self::$timezone = $timezone;\n    }\n\n    /**\n     * Convert a formatted string from Georgian Calendar to Jalali Calendar.\n     * This will be useful to directly convert time strings coming from databases.\n     * Example:\n     *\n     *  // Suppose this comes from database\n     *  $a = '2016-02-14 14:20:38';\n     *  $date = \\jDateTime::convertFormatToFormat('Y-m-d H:i:s', 'Y-m-d H:i:s', $a);\n     *  // $date will now be '۱۳۹۴-۱۱-۲۵ ۱۴:۲۰:۳۸'\n     *\n     * @author Vahid Fazlollahzade\n     * @param string $jalaliFormat Return format. Same as static::date(...)\n     * @param string $georgianFormat The format of $timeString. See php.net/date\n     * @param string $timeString The time itself, formatted as $georgianFormat\n     * @param null|\\DateTimeZone|string $timezone The timezone. Same as static::date(...)\n     * @return string\n     */\n    public static function convertFormatToFormat($jalaliFormat, $georgianFormat, $timeString, $timezone=null)\n    {\n        // Normalize $timezone, take from static::date(...)\n        $timezone = ($timezone != null) ? $timezone : ((self::$timezone != null) ? self::$timezone : date_default_timezone_get());\n        if (is_string($timezone)) {\n            $timezone = new \\DateTimeZone($timezone);\n        } elseif (!$timezone instanceof \\DateTimeZone) {\n            throw new \\RuntimeException('Provided timezone is not correct.');\n        }\n\n        // Convert to timestamp, then to Jalali\n        $datetime = \\DateTime::createFromFormat($georgianFormat, $timeString, $timezone);\n        return static::date($jalaliFormat, $datetime->getTimestamp());\n    }\n\n    /**\n     * jDateTime::Date\n     *\n     * Formats and returns given timestamp just like php's\n     * built in date() function.\n     * e.g:\n     * $obj->date(\"Y-m-d H:i\", time());\n     * $obj->date(\"Y-m-d\", time(), false, false, 'America/New_York');\n     *\n     * @author Sallar Kaboli\n     * @param $format string Acceps format string based on: php.net/date\n     * @param $stamp int Unix Timestamp (Epoch Time)\n     * @param $convert bool (Optional) forces convert action. pass null to use system default\n     * @param $jalali bool (Optional) forces jalali conversion. pass null to use system default\n     * @param $timezone string (Optional) forces a different timezone. pass null to use system default\n     * @return string Formatted input\n     */\n    public static function date($format, $stamp = false, $convert = null, $jalali = null, $timezone = null)\n    {\n        //Timestamp + Timezone\n        $stamp    = ($stamp !== false) ? $stamp : time();\n        $timezone = ($timezone != null) ? $timezone : ((self::$timezone != null) ? self::$timezone : date_default_timezone_get());\n        $obj      = new DateTime('@' . $stamp, new DateTimeZone($timezone));\n        $obj->setTimezone(new DateTimeZone($timezone));\n\n        if ( (self::$jalali === false && $jalali === null) || $jalali === false ) {\n            return $obj->format($format);\n        }\n        else {\n            \n            //Find what to replace\n            $chars  = (preg_match_all('/([a-zA-Z]{1})/', $format, $chars)) ? $chars[0] : array();\n            \n            //Intact Keys\n            $intact = array('B','h','H','g','G','i','s','I','U','u','Z','O','P');\n            $intact = self::filterArray($chars, $intact);\n            $intactValues = array();\n\n            foreach ($intact as $k => $v) {\n                $intactValues[$k] = $obj->format($v);\n            }\n            //End Intact Keys\n\n\n            //Changed Keys\n            list($year, $month, $day) = array($obj->format('Y'), $obj->format('n'), $obj->format('j'));\n            list($jyear, $jmonth, $jday) = self::toJalali($year, $month, $day);\n\n            $keys   = array('d','D','j','l','N','S','w','z','W','F','m','M','n','t','L','o','Y','y','a','A','c','r','e','T');\n            $keys   = self::filterArray($chars, $keys, array('z'));\n            $values = array();\n\n            foreach ($keys as $k => $key) {\n\n                $v = '';\n                switch ($key) {\n                    //Day\n                    case 'd':\n                        $v = sprintf('%02d', $jday);\n                        break;\n                    case 'D':\n                        $v = self::getDayNames($obj->format('D'), true);\n                        break;\n                    case 'j':\n                        $v = $jday;\n                        break;\n                    case 'l':\n                        $v = self::getDayNames($obj->format('l'));\n                        break;\n                    case 'N':\n                        $v = self::getDayNames($obj->format('l'), false, 1, true);\n                        break;\n                    case 'S':\n                        $v = 'ام';\n                        break;\n                    case 'w':\n                        $v = self::getDayNames($obj->format('l'), false, 1, true) - 1;\n                        break;\n                    case 'z':\n                        if ($jmonth > 6) {\n                            $v = 186 + (($jmonth - 6 - 1) * 30) + $jday;\n                        }\n                        else {\n                            $v = (($jmonth - 1) * 31) + $jday;\n                        }\n                        self::$temp['z'] = $v;\n                        break;\n                    //Week\n                    case 'W':\n                        $v = is_int(self::$temp['z'] / 7) ? (self::$temp['z'] / 7) : intval(self::$temp['z'] / 7 + 1);\n                        break;\n                    //Month\n                    case 'F':\n                        $v = self::getMonthNames($jmonth);\n                        break;\n                    case 'm':\n                        $v = sprintf('%02d', $jmonth);\n                        break;\n                    case 'M':\n                        $v = self::getMonthNames($jmonth, true);\n                        break;\n                    case 'n':\n                        $v = $jmonth;\n                        break;\n                    case 't':\n                    \tif ($jmonth>=1 && $jmonth<=6) $v=31;\n                    \telse if ($jmonth>=7 && $jmonth<=11) $v=30;\n                    \telse if($jmonth==12 && $jyear % 4 ==3) $v=30;\n                    \telse if ($jmonth==12 && $jyear % 4 !=3) $v=29;\n                        break;\n                    //Year\n                    case 'L':\n                        $tmpObj = new DateTime('@'.(time()-31536000));\n                        $v = $tmpObj->format('L');\n                        break;\n                    case 'o':\n                    case 'Y':\n                        $v = $jyear;\n                        break;\n                    case 'y':\n                        $v = $jyear % 100;\n                        break;\n                    //Time\n                    case 'a':\n                        $v = ($obj->format('a') == 'am') ? 'ق.ظ' : 'ب.ظ';\n                        break;\n                    case 'A':\n                        $v = ($obj->format('A') == 'AM') ? 'قبل از ظهر' : 'بعد از ظهر';\n                        break;\n                    //Full Dates\n                    case 'c':\n                        $v  = $jyear.'-'.sprintf('%02d', $jmonth).'-'.sprintf('%02d', $jday).'T';\n                        $v .= $obj->format('H').':'.$obj->format('i').':'.$obj->format('s').$obj->format('P');\n                        break;\n                    case 'r':\n                        $v  = self::getDayNames($obj->format('D'), true).', '.sprintf('%02d', $jday).' '.self::getMonthNames($jmonth, true);\n                        $v .= ' '.$jyear.' '.$obj->format('H').':'.$obj->format('i').':'.$obj->format('s').' '.$obj->format('P');\n                        break;\n                    //Timezone\n                    case 'e':\n                        $v = $obj->format('e');\n                        break;\n                    case 'T':\n                        $v = $obj->format('T');\n                        break;\n\n                }\n                $values[$k] = $v;\n\n            }\n            //End Changed Keys\n\n            //Merge\n            $keys   = array_merge($intact, $keys);\n            $values = array_merge($intactValues, $values);\n\n            //Return\n            $ret = strtr($format, array_combine($keys, $values));\n            return\n                ($convert === false ||\n                ($convert === null && self::$convert === false) ||\n                ( $jalali === false || $jalali === null && self::$jalali === false ))\n                ? $ret : self::convertNumbers($ret);\n\n        }\n\n    }\n\n    /**\n     * jDateTime::gDate\n     *\n     * Same as jDateTime::Date method\n     * but this one works as a helper and returns Gregorian Date\n     * in case someone doesn't like to pass all those false arguments\n     * to Date method.\n     *\n     * e.g. $obj->gDate(\"Y-m-d\") //Outputs: 2011-05-05\n     *      $obj->date(\"Y-m-d\", false, false, false); //Outputs: 2011-05-05\n     *      Both return the exact same result.\n     *\n     * @author Sallar Kaboli\n     * @param $format string Acceps format string based on: php.net/date\n     * @param $stamp int Unix Timestamp (Epoch Time)\n     * @param $timezone string (Optional) forces a different timezone. pass null to use system default\n     * @return string Formatted input\n     */\n    public static function gDate($format, $stamp = false, $timezone = null)\n    {\n        return self::date($format, $stamp, false, false, $timezone);\n    }\n    \n    /**\n     * jDateTime::Strftime\n     *\n     * Format a local time/date according to locale settings\n     * built in strftime() function.\n     * e.g:\n     * $obj->strftime(\"%x %H\", time());\n     * $obj->strftime(\"%H\", time(), false, false, 'America/New_York');\n     *\n     * @author Omid Pilevar\n     * @param $format string Acceps format string based on: php.net/date\n     * @param $stamp int Unix Timestamp (Epoch Time)\n     * @param $convert bool (Optional) forces convert action. pass null to use system default\n     * @param $jalali bool (Optional) forces jalali conversion. pass null to use system default\n     * @param $timezone string (Optional) forces a different timezone. pass null to use system default\n     * @return string Formatted input\n     */\n    public static function strftime($format, $stamp = false, $convert = null, $jalali = null, $timezone = null)\n    {\n        $str_format_code = array(\n            '%a', '%A', '%d', '%e', '%j', '%u', '%w',\n            '%U', '%V', '%W',\n            '%b', '%B', '%h', '%m',\n            '%C', '%g', '%G', '%y', '%Y',\n            '%H', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X', '%z', '%Z',\n            '%c', '%D', '%F', '%s', '%x',\n            '%n', '%t', '%%'\n        );\n        \n        $date_format_code = array(\n            'D', 'l', 'd', 'j', 'z', 'N', 'w',\n            'W', 'W', 'W',\n            'M', 'F', 'M', 'm',\n            'y', 'y', 'y', 'y', 'Y',\n            'H', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'h:i:s', 'H', 'H',\n            'D j M H:i:s', 'd/m/y', 'Y-m-d', 'U', 'd/m/y',\n            '\\n', '\\t', '%'\n        );\n\n        //Change Strftime format to Date format\n        $format = str_replace($str_format_code, $date_format_code, $format);\n\n        //Convert to date\n        return self::date($format, $stamp, $convert, $jalali, $timezone);\n    }\n\t\n   /**\n     * jDateTime::Mktime\n     *\n     * Creates a Unix Timestamp (Epoch Time) based on given parameters\n     * works like php's built in mktime() function.\n     * e.g:\n     * $time = $obj->mktime(0,0,0,2,10,1368);\n     * $obj->date(\"Y-m-d\", $time); //Format and Display\n     * $obj->date(\"Y-m-d\", $time, false, false); //Display in Gregorian !\n     *\n     * You can force gregorian mktime if system default is jalali and you\n     * need to create a timestamp based on gregorian date\n     * $time2 = $obj->mktime(0,0,0,12,23,1989, false);\n     *\n     * @author Sallar Kaboli\n     * @param $hour int Hour based on 24 hour system\n     * @param $minute int Minutes\n     * @param $second int Seconds\n     * @param $month int Month Number\n     * @param $day int Day Number\n     * @param $year int Four-digit Year number eg. 1390\n     * @param $jalali bool (Optional) pass false if you want to input gregorian time\n     * @param $timezone string (Optional) acceps an optional timezone if you want one\n     * @return int Unix Timestamp (Epoch Time)\n     */\n    public static function mktime($hour, $minute, $second, $month, $day, $year, $jalali = null, $timezone = null)\n    {\n        //Defaults\n        $month = (intval($month) == 0) ? self::date('m') : $month;\n        $day   = (intval($day)   == 0) ? self::date('d') : $day;\n        $year  = (intval($year)  == 0) ? self::date('Y') : $year;\n        $hour  = intval($hour);\n        $minute  = intval($minute);\n        $second  = intval($second);\n\n        //Convert to Gregorian if necessary\n        if ( $jalali === true || ($jalali === null && self::$jalali === true) ) {\n            list($year, $month, $day) = self::toGregorian($year, $month, $day);\n        }\n\n        //Create a new object and set the timezone if available\n        $date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $day).' '.$hour.':'.$minute.':'.$second;\n\n        if ( self::$timezone != null || $timezone != null ) {\n            $obj = new DateTime($date, new DateTimeZone(($timezone != null) ? $timezone : self::$timezone));\n        }\n        else {\n            $obj = new DateTime($date);\n        }\n\n        //Return\n        return $obj->format('U');\n    }\n    \n    /**\n     * jDateTime::Checkdate\n     *\n     * Checks the validity of the date formed by the arguments.\n     * A date is considered valid if each parameter is properly defined.\n     * works like php's built in checkdate() function.\n     * Leap years are taken into consideration.\n     * e.g:\n     * $obj->checkdate(10, 21, 1390); // Return true\n     * $obj->checkdate(9, 31, 1390);  // Return false\n     *\n     * You can force gregorian checkdate if system default is jalali and you\n     * need to check based on gregorian date\n     * $check = $obj->checkdate(12, 31, 2011, false);\n     *\n     * @author Omid Pilevar\n     * @param $month int The month is between 1 and 12 inclusive.\n     * @param $day int The day is within the allowed number of days for the given month.\n     * @param $year int The year is between 1 and 32767 inclusive.\n     * @param $jalali bool (Optional) pass false if you want to input gregorian time\n     * @return bool\n     */\n    public static function checkdate($month, $day, $year, $jalali = null)\n    {\n        //Defaults\n        $month = (intval($month) == 0) ? self::date('n') : intval($month);\n        $day   = (intval($day)   == 0) ? self::date('j') : intval($day);\n        $year  = (intval($year)  == 0) ? self::date('Y') : intval($year);\n        \n        //Check if its jalali date\n        if ( $jalali === true || ($jalali === null && self::$jalali === true) )\n        {\n            $epoch = self::mktime(0, 0, 0, $month, $day, $year);\n            \n            if( self::date('Y-n-j', $epoch,false) == \"$year-$month-$day\" ) {\n                $ret = true;\n            }\n            else{\n                $ret = false; \n            }\n        }\n        else //Gregorian Date\n        { \n            $ret = checkdate($month, $day, $year);\n        }\n        \n        //Return\n        return $ret;\n    }\n    \n    /**\n     * jDateTime::getdate\n     *\n     * Like php built-in function, returns an associative array containing the date information of a timestamp, or the current local time if no timestamp is given. .\n     *\n     * @author Meysam Pour Ganji\n     * @param $timestamp int The timestamp that whould convert to date information array, if NULL passed, current timestamp will be processed.\n     * @return An associative array of information related to the timestamp. For see elements of the returned associative array see {@link http://php.net/manual/en/function.getdate.php#refsect1-function.getdate-returnvalues}.\n     */\n    public static function getdate($timestamp = null)\n    {\n        if ( $timestamp === null )\n        {\n            $timestamp = time();\n        }\n        \n        if ( is_string($timestamp) )\n        {\n            if( ctype_digit($timestamp) || ( $timestamp[0] == '-' && ctype_digit(substr($timestamp, 1)) ) )\n            {\n                $timestamp = (int)$timestamp;\n            }\n            else\n            {\n                $timestamp = strtotime($timestamp);\n            }\n        }\n        \n        $dateString = self::date(\"s|i|G|j|w|n|Y|z|l|F\", $timestamp);\n        $dateArray = explode(\"|\", $dateString);\n        \n        $result = array(\n            \"seconds\" => $dateArray[0],\n            \"minutes\" => $dateArray[1],\n            \"hours\" => $dateArray[2],\n            \"mday\" => $dateArray[3],\n            \"wday\" => $dateArray[4],\n            \"mon\" => $dateArray[5],\n            \"year\" => $dateArray[6],\n            \"yday\" => $dateArray[7],\n            \"weekday\" => $dateArray[8],\n            \"month\" => $dateArray[9],\n            0 => $timestamp\n        ); \n        \n        return $result;\n    }\n\n    /**\n     * System Helpers below\n     * ------------------------------------------------------\n     */\n    \n    /**\n     * Filters out an array\n     */\n    private static function filterArray($needle, $heystack, $always = array())\n    {\n        return array_intersect(array_merge($needle, $always), $heystack);\n    }\n    \n    /**\n     * Returns correct names for week days\n     */\n    private static function getDayNames($day, $shorten = false, $len = 1, $numeric = false)\n    {\n        $days = array(\n            'sat' => array(1, 'شنبه'),\n            'sun' => array(2, 'یکشنبه'),\n            'mon' => array(3, 'دوشنبه'),\n            'tue' => array(4, 'سه شنبه'),\n            'wed' => array(5, 'چهارشنبه'),\n            'thu' => array(6, 'پنجشنبه'),\n            'fri' => array(7, 'جمعه')\n        );\n\n        $day = substr(strtolower($day), 0, 3);\n        $day = $days[$day];\n\n        return ($numeric) ? $day[0] : (($shorten) ? self::substr($day[1], 0, $len) : $day[1]);\n    }\n\n    /**\n     * Returns correct names for months\n     */\n    private static function getMonthNames($month, $shorten = false, $len = 3)\n    {\n        // Convert\n        $months = array(\n            'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'\n        );\n        $ret    = $months[$month - 1];\n\n        // Return\n        return ($shorten) ? self::substr($ret, 0, $len) : $ret;\n    }\n\n    /**\n     * Converts latin numbers to farsi script\n     */\n    private static function convertNumbers($matches)\n    {\n        $farsi_array   = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');\n        $english_array = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');\n\n        return str_replace($english_array, $farsi_array, $matches);\n    }\n\n    /**\n     * Division\n     */\n    private static function div($a, $b)\n    {\n        return (int) ($a / $b);\n    }\n\n    /**\n     * Substring helper\n     */\n    private static function substr($str, $start, $len)\n    {\n        if( function_exists('mb_substr') ){\n            return mb_substr($str, $start, $len, 'UTF-8');\n        }\n        else{\n            return substr($str, $start, $len * 2);\n        }\n    }\n\n    /**\n     * Gregorian to Jalali Conversion\n     * Copyright (C) 2000  Roozbeh Pournader and Mohammad Toossi\n     */\n    public static function toJalali($g_y, $g_m, $g_d)\n    {\n\n        $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\n        $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);\n\n        $gy = $g_y-1600;\n        $gm = $g_m-1;\n        $gd = $g_d-1;\n\n        $g_day_no = 365*$gy+self::div($gy+3, 4)-self::div($gy+99, 100)+self::div($gy+399, 400);\n\n        for ($i=0; $i < $gm; ++$i)\n            $g_day_no += $g_days_in_month[$i];\n        if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0)))\n            $g_day_no++;\n        $g_day_no += $gd;\n\n        $j_day_no = $g_day_no-79;\n\n        $j_np = self::div($j_day_no, 12053);\n        $j_day_no = $j_day_no % 12053;\n\n        $jy = 979+33*$j_np+4*self::div($j_day_no, 1461);\n\n        $j_day_no %= 1461;\n\n        if ($j_day_no >= 366) {\n            $jy += self::div($j_day_no-1, 365);\n            $j_day_no = ($j_day_no-1)%365;\n        }\n\n        for ($i = 0; $i < 11 && $j_day_no >= $j_days_in_month[$i]; ++$i)\n            $j_day_no -= $j_days_in_month[$i];\n        $jm = $i+1;\n        $jd = $j_day_no+1;\n\n        return array($jy, $jm, $jd);\n\n    }\n\n    /**\n     * Jalali to Gregorian Conversion\n     * Copyright (C) 2000  Roozbeh Pournader and Mohammad Toossi\n     *\n     */\n    public static function toGregorian($j_y, $j_m, $j_d)\n    {\n\n        $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\n        $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);\n\n        $jy = $j_y-979;\n        $jm = $j_m-1;\n        $jd = $j_d-1;\n\n        $j_day_no = 365*$jy + self::div($jy, 33)*8 + self::div($jy%33+3, 4);\n        for ($i=0; $i < $jm; ++$i)\n            $j_day_no += $j_days_in_month[$i];\n\n        $j_day_no += $jd;\n\n        $g_day_no = $j_day_no+79;\n\n        $gy = 1600 + 400*self::div($g_day_no, 146097);\n        $g_day_no = $g_day_no % 146097;\n\n        $leap = true;\n        if ($g_day_no >= 36525) {\n            $g_day_no--;\n            $gy += 100*self::div($g_day_no,  36524);\n            $g_day_no = $g_day_no % 36524;\n\n            if ($g_day_no >= 365)\n                $g_day_no++;\n            else\n                $leap = false;\n        }\n\n        $gy += 4*self::div($g_day_no, 1461);\n        $g_day_no %= 1461;\n\n        if ($g_day_no >= 366) {\n            $leap = false;\n\n            $g_day_no--;\n            $gy += self::div($g_day_no, 365);\n            $g_day_no = $g_day_no % 365;\n        }\n\n        for ($i = 0; $g_day_no >= $g_days_in_month[$i] + ($i == 1 && $leap); $i++)\n            $g_day_no -= $g_days_in_month[$i] + ($i == 1 && $leap);\n        $gm = $i+1;\n        $gd = $g_day_no+1;\n\n        return array($gy, $gm, $gd);\n\n    }\n\n}\n"
  },
  {
    "path": "phpunit.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<phpunit bootstrap=\"./Tests/bootstrap.php\" colors=\"true\">\n    <testsuites>\n        <testsuite name=\"jDateTime_Test\">\n            <directory>./Tests/</directory>\n        </testsuite>\n    </testsuites>\n\n    <filter>\n        <whitelist>\n            <directory>./</directory>\n            <exclude>\n                <directory>./Tests</directory>\n            </exclude>\n        </whitelist>\n    </filter>\n</phpunit>\n"
  }
]