fix method name
This commit is contained in:
1 parent
900525b087
commit
629213f566
4 files changed
+20
-19
No files matched your search
+4
-4
@@ -148,11 +148,11 @@ return Verta::getGregorian(1394,10,4); // [2015,12,25]
|
|||||||
</pre>
|
</pre>
|
||||||
<p>Verta to Datatime PHP, use the following command</p>
|
<p>Verta to Datatime PHP, use the following command</p>
|
||||||
<pre>
|
<pre>
|
||||||
$dt = verta()->DateTime();
|
$dt = verta()->datetime();
|
||||||
</pre>
|
</pre>
|
||||||
<p>Verta to Carbon, use the following command</p>
|
<p>Verta to Carbon, use the following command</p>
|
||||||
<pre>
|
<pre>
|
||||||
$c = Carbon::instance($v->DateTime());
|
$c = Carbon::instance($v->datetime());
|
||||||
</pre>
|
</pre>
|
||||||
<h3 id="property">Property</h3>
|
<h3 id="property">Property</h3>
|
||||||
<p>To get property, use the following command</p>
|
<p>To get property, use the following command</p>
|
||||||
@@ -326,8 +326,8 @@ return $v->endYear(); // 1396-12-29 23:59:59
|
|||||||
<p>To validate datetime, use the following command</p>
|
<p>To validate datetime, use the following command</p>
|
||||||
<pre>
|
<pre>
|
||||||
return Verta::isLeapYear(1394); // false
|
return Verta::isLeapYear(1394); // false
|
||||||
return Verta::isValideDate(1394, 12, 30); // false
|
return Verta::isValidDate(1394, 12, 30); // false
|
||||||
return Verta::isValideTime(15, 12, 30); // true
|
return Verta::isValidTime(15, 12, 30); // true
|
||||||
</pre>
|
</pre>
|
||||||
<p>To difference datetime together, use the following command</p>
|
<p>To difference datetime together, use the following command</p>
|
||||||
<pre>
|
<pre>
|
||||||
|
|||||||
+4
-4
@@ -149,11 +149,11 @@ return Verta::getGregorian(1394,10,4); // [2015,12,25]
|
|||||||
</pre>
|
</pre>
|
||||||
<p>برای تبدیل تاریخ از ورتا به تاریخ و زمان پی اچ پی، از دستور زیر استفاده کنید</p>
|
<p>برای تبدیل تاریخ از ورتا به تاریخ و زمان پی اچ پی، از دستور زیر استفاده کنید</p>
|
||||||
<pre>
|
<pre>
|
||||||
$dt = verta()->DateTime();
|
$dt = verta()->datetime();
|
||||||
</pre>
|
</pre>
|
||||||
<p>برای تبدیل تاریخ از ورتا به کربن، از دستور زیر استفاده کنید</p>
|
<p>برای تبدیل تاریخ از ورتا به کربن، از دستور زیر استفاده کنید</p>
|
||||||
<pre>
|
<pre>
|
||||||
$c = Carbon::instance($v->DateTime());
|
$c = Carbon::instance($v->datetime());
|
||||||
</pre>
|
</pre>
|
||||||
<h3 id="property">خصوصیات</h3>
|
<h3 id="property">خصوصیات</h3>
|
||||||
<p>برای دریافت مقادیر خصوصیات، از دستورات زیر استفاده کنید</p>
|
<p>برای دریافت مقادیر خصوصیات، از دستورات زیر استفاده کنید</p>
|
||||||
@@ -327,8 +327,8 @@ return $v->endYear(); // 1396-12-29 23:59:59
|
|||||||
<p>برای اعتبار سنجی تاریخ، از دستور زیر استفاده کنید</p>
|
<p>برای اعتبار سنجی تاریخ، از دستور زیر استفاده کنید</p>
|
||||||
<pre>
|
<pre>
|
||||||
return Verta::isLeapYear(1394); // false
|
return Verta::isLeapYear(1394); // false
|
||||||
return Verta::isValideDate(1394, 12, 30); // false
|
return Verta::isValidDate(1394, 12, 30); // false
|
||||||
return Verta::isValideTime(15, 12, 30); // true
|
return Verta::isValidTime(15, 12, 30); // true
|
||||||
</pre>
|
</pre>
|
||||||
<p>برای محاسبه اختلاف تاریخ ها با یکدیگر، از دستور زیر استفاده کنید</p>
|
<p>برای محاسبه اختلاف تاریخ ها با یکدیگر، از دستور زیر استفاده کنید</p>
|
||||||
<pre>
|
<pre>
|
||||||
|
|||||||
+8
-8
@@ -343,9 +343,9 @@ class Verta extends DateTime {
|
|||||||
/**
|
/**
|
||||||
* Create a DateTime instance from Verta
|
* Create a DateTime instance from Verta
|
||||||
*
|
*
|
||||||
* @return DateTime $datetime
|
* @return datetime $datetime
|
||||||
*/
|
*/
|
||||||
public function DateTime() {
|
public function datetime() {
|
||||||
return new DateTime(date('Y-m-d H:i:s.u', $this->getTimestamp()), $this->getTimeZone());
|
return new DateTime(date('Y-m-d H:i:s.u', $this->getTimestamp()), $this->getTimeZone());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,7 +392,7 @@ class Verta extends DateTime {
|
|||||||
$datetime = str_replace(self::$monthYear, range(1,12), $datetime);
|
$datetime = str_replace(self::$monthYear, range(1,12), $datetime);
|
||||||
|
|
||||||
$parse = date_parse_from_format($format, $datetime);
|
$parse = date_parse_from_format($format, $datetime);
|
||||||
if($parse['error_count'] == 0 && self::isValideDate($parse['year'], $parse['month'], $parse['day']) && self::isValideTime($parse['hour'], $parse['minute'], $parse['second'])){
|
if($parse['error_count'] == 0 && self::isValidDate($parse['year'], $parse['month'], $parse['day']) && self::isValidTime($parse['hour'], $parse['minute'], $parse['second'])){
|
||||||
list($year, $month, $day) = self::getGregorian($parse['year'], $parse['month'], $parse['day']);
|
list($year, $month, $day) = self::getGregorian($parse['year'], $parse['month'], $parse['day']);
|
||||||
list($hour,$minute, $second) = array($parse['hour'], $parse['minute'], $parse['second']);
|
list($hour,$minute, $second) = array($parse['hour'], $parse['minute'], $parse['second']);
|
||||||
|
|
||||||
@@ -520,7 +520,7 @@ class Verta extends DateTime {
|
|||||||
$minute = $minute === null ? intval($defaults['minute']) : $minute;
|
$minute = $minute === null ? intval($defaults['minute']) : $minute;
|
||||||
$second = $second === null ? intval($defaults['second']) : $second;
|
$second = $second === null ? intval($defaults['second']) : $second;
|
||||||
|
|
||||||
if (!checkdate($month, $day, $year) || !static::isValideTime($hour, $minute, $second)) {
|
if (!checkdate($month, $day, $year) || !static::isValidTime($hour, $minute, $second)) {
|
||||||
throw new \InvalidArgumentException('Unknown datetime');
|
throw new \InvalidArgumentException('Unknown datetime');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,7 +586,7 @@ class Verta extends DateTime {
|
|||||||
$minute = $minute === null ? intval($defaults['minute']) : $minute;
|
$minute = $minute === null ? intval($defaults['minute']) : $minute;
|
||||||
$second = $second === null ? intval($defaults['second']) : $second;
|
$second = $second === null ? intval($defaults['second']) : $second;
|
||||||
|
|
||||||
if (!static::isValideDate($year, $month, $day) || !static::isValideTime($hour, $minute, $second)) {
|
if (!static::isValidDate($year, $month, $day) || !static::isValidTime($hour, $minute, $second)) {
|
||||||
throw new \InvalidArgumentException('Unknown datetime');
|
throw new \InvalidArgumentException('Unknown datetime');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1354,7 +1354,7 @@ class Verta extends DateTime {
|
|||||||
*/
|
*/
|
||||||
public function formatGregorian($format) {
|
public function formatGregorian($format) {
|
||||||
|
|
||||||
return $this->DateTime()->format($format);
|
return $this->datetime()->format($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1472,7 +1472,7 @@ class Verta extends DateTime {
|
|||||||
* @param int $year
|
* @param int $year
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isValideDate($year, $month, $day) {
|
public static function isValidDate($year, $month, $day) {
|
||||||
$dayLastMonthJalali = static::isLeapYear($year) && ($month == 12) ? 30 : static::$daysMonthJalali[intval($month)-1];
|
$dayLastMonthJalali = static::isLeapYear($year) && ($month == 12) ? 30 : static::$daysMonthJalali[intval($month)-1];
|
||||||
return $year >= 1 && $year <= 32766
|
return $year >= 1 && $year <= 32766
|
||||||
&& $month >= 1 && $month <= 12
|
&& $month >= 1 && $month <= 12
|
||||||
@@ -1487,7 +1487,7 @@ class Verta extends DateTime {
|
|||||||
* @param int $second
|
* @param int $second
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isValideTime($hour, $minute, $second) {
|
public static function isValidTime($hour, $minute, $second) {
|
||||||
return $hour >= 0 && $hour <= 24
|
return $hour >= 0 && $hour <= 24
|
||||||
&& $minute >= 0 && $minute <= 59
|
&& $minute >= 0 && $minute <= 59
|
||||||
&& $second >= 0 && $second <= 59;
|
&& $second >= 0 && $second <= 59;
|
||||||
|
|||||||
+4
-3
@@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
if (! function_exists('verta')) {
|
if (! function_exists('verta')) {
|
||||||
/**
|
/**
|
||||||
* @param string $str
|
* @param null $datetime
|
||||||
|
* @param null $timezone
|
||||||
* @return \Hekmatinasse\Verta\Verta
|
* @return \Hekmatinasse\Verta\Verta
|
||||||
*/
|
*/
|
||||||
function verta($string = null, $timezone = null)
|
function verta($datetime = null, $timezone = null)
|
||||||
{
|
{
|
||||||
return new \Hekmatinasser\Verta\Verta($string, $timezone);
|
return new \Hekmatinasser\Verta\Verta($datetime, $timezone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user