vsg24/jdatetimeplus

PHP 编写的 Jalali (Shamsi) 日期时间类,支持高于 2038 年的年份。于 2016 年更新。

v1.0.0 2016-07-06 18:25 UTC

This package is auto-updated.

Last update: 2024-09-13 23:41:35 UTC


README

PHP 类,用于将公历日期转换为贾利历日期,反之亦然。支持 2038 年之后的日期。
贾利历,也称为波斯历或伊斯兰日历,是伊朗的日历系统。

关于此类

jDateTimePlus 1.0.0 基于 jDateTime 2.2.0

此包基于 Sallar Kaboli 的 jDateTime 的分支。在这个分支中,我用基于 jdf 2.60 的新方法替换了贾利历到公历以及反之亦然的方法。还用一个新的方法替换了 mktime 方法,因为旧版本给出了错误的结果。我还修复了一些 phpdocs 并引入了新方法。此包最好与更高的抽象级别一起使用,例如 EasyDateTime

PHP 的默认 date 函数不支持高于 2038 年的年份,因此 PHP5 中引入了 DateTime 类来解决此问题并提供更复杂的日期方法。伊朗用户一直使用旧的 jdate 函数将公历日期转换为贾利历等价日期,这完全基于旧的 php date 函数,因此已经过时。

要求

与 jDateTime 不同,jDateTimePlus 需要 PHP >= 5.4

安装

使用 Composer

您可以使用 composer 安装此包。将此包添加到您的 composer.json

"require": {
	"vsg24/jdatetimeplus": "dev-master"
}

或者如果您更喜欢命令行,请将目录更改为项目根目录并

php composer.phar require "vsg24/jdatetimeplus":"dev-master"

手动安装

获取包源代码的副本。您可以通过以下两种方式完成此操作

  1. 下载源代码的 ZIP 版本并将其解压到所需位置
  2. 运行 git clone https://github.com/VSG24/jDateTimePlus.git 来克隆此存储库

获取源代码副本后,只需在需要使用的地方包含 jdatetime.class.php 即可。

require_once 'path/to/source/jdatetimeplus.class.php';

示例

请参阅 examples.phpexample-static.php 以获取工作示例。

贡献者

许可证

jDateTimePlus 由 Vahid Amiri Motlagh 创建并发布,采用 MIT 许可证

版权 (C) 2016 Vahid Amiri Motlagh

“jdf 2.60”包中的原始贾利历到公历(反之亦然)方法:版权 (C) 2015,Reza Gholampanahi http://jdf.scr.ir

The MIT License (MIT)

Copyright (C) 2016 Vahid Amiri Motlagh

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.

资源