From f4cbf76e52c56d386f2891909b756b6b57b573ff Mon Sep 17 00:00:00 2001 From: nasser Date: Sun, 3 Jul 2022 20:26:41 +0430 Subject: [PATCH] migrate to 8 --- composer.json | 8 +- docs/assert/logo.png | Bin 20064 -> 0 bytes docs/css/style.css | 214 --------- docs/en/index.html | 633 -------------------------- docs/index.html | 635 --------------------------- src/Lang/ar.php | 82 ---- src/Lang/az.php | 82 ---- src/Lang/en.php | 82 ---- src/Lang/fa.php | 82 ---- src/Lang/haz.php | 82 ---- src/Lang/ku.php | 82 ---- src/Lang/ps.php | 81 ---- src/Laravel/VertaServiceProvider.php | 1 - src/Traits/Accessor.php | 261 ----------- src/Traits/Boundaries.php | 160 ------- src/Traits/Comparison.php | 607 ------------------------- src/Traits/Creator.php | 421 ------------------ src/Traits/Date.php | 59 --- src/Traits/Difference.php | 100 ----- src/Traits/Formatting.php | 478 -------------------- src/Traits/Modification.php | 370 ---------------- src/Traits/Transformation.php | 89 ---- src/Traits/Translator.php | 102 ----- src/Verta.php | 7 +- src/VertaInterface.php | 41 -- src/helpers.php | 8 +- tests/AccessTest.php | 20 +- tests/ComparisionTest.php | 279 ------------ tests/ComparisonTest.php | 304 +++++++++++++ tests/CreatorTest.php | 64 +-- tests/FormatTest.php | 51 +-- tests/ModificationTest.php | 73 +-- 32 files changed, 417 insertions(+), 5141 deletions(-) delete mode 100644 docs/assert/logo.png delete mode 100644 docs/css/style.css delete mode 100644 docs/en/index.html delete mode 100644 docs/index.html delete mode 100644 src/Lang/ar.php delete mode 100644 src/Lang/az.php delete mode 100644 src/Lang/en.php delete mode 100644 src/Lang/fa.php delete mode 100644 src/Lang/haz.php delete mode 100644 src/Lang/ku.php delete mode 100644 src/Lang/ps.php delete mode 100644 src/Traits/Accessor.php delete mode 100644 src/Traits/Boundaries.php delete mode 100644 src/Traits/Comparison.php delete mode 100644 src/Traits/Creator.php delete mode 100644 src/Traits/Date.php delete mode 100644 src/Traits/Difference.php delete mode 100644 src/Traits/Formatting.php delete mode 100644 src/Traits/Modification.php delete mode 100644 src/Traits/Transformation.php delete mode 100644 src/Traits/Translator.php delete mode 100644 src/VertaInterface.php delete mode 100644 tests/ComparisionTest.php create mode 100644 tests/ComparisonTest.php diff --git a/composer.json b/composer.json index 1a7f9e6..94b6c5c 100755 --- a/composer.json +++ b/composer.json @@ -17,10 +17,10 @@ "Verta" ], "require": { - "php": "^7.3|^8.0", - "illuminate/support": "^6.0|^7.0|^8.0|^9.0", - "illuminate/validation": "^6.0|^7.0|^8.0|^9.0", - "hekmatinasser/notowo": "^1.0" + "php": "^8.0", + "illuminate/support": "^^8.0|^9.0", + "illuminate/validation": "^^8.0|^9.0", + "hekmatinasser/jalali": "^8.0" }, "require-dev": { "orchestra/testbench": "^4.18|^5.20|^6.24|^7.0" diff --git a/docs/assert/logo.png b/docs/assert/logo.png deleted file mode 100644 index a583b014273caa4d259760b40d5db18e0b2c4e14..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20064 zcmXtfb9kKJ^LDIlY^!N(+qO5h)7Vbh7;TKkb~d)z*tXNyPT%e4`~LpOb#0RKoafA( znS1WRMye=DBO?(YK|nwt%gRWoK|nwTM$-(e?fGT(Q$=v4qx>HhH)?3+CWHO5dd5$tWM@zjU zaS^97H0L-z4TgNzfJH3JJ)}}9{2Iv~iPybNM+YvQ#z3$={CU`A;)mO z)=l0;hS-=38(V0i-)$nEUy^fZb+a|6%w6MuJ0Yu4yzBJ8$nK{Kw_s(VafEd1&*X>qDDT8;lsAtJiL%yt2ZZcP5gf=3+y>L>~K561u zZt})9x)wbbMFPeANNJ!Kdd@L^Dh>f%8Fz}!c-l#X_i)M)V{{j_x}fct8&1Nv*5ZGm zPZGUagUq=8nd|JNQWber2~y z|C!e-9?zU0mKxOH_xIoG>P|k@<(7C$ z9^%2Lz(Bo53ZFApyNEq{ihI)=g$+RVa|=LCB8=#;QB-9ptb0WBUi?z5lb z0c^Xz_nP^)lk%kZdp}A7P`<87Y1ALqpEz=G&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CG;l>FntJ^Ugl6No^ony*&)j@|v~8{HVe&-PI640od`);q zVwaVCD{}^GHsx?V`9%(AW-jo)(UT=#$V1&&-8{2qhfj5v(w4{1N!O3Rk>XG?c?JEb3hX!7&t`-99Ejm{aR5mNbDu_k z^68tq#rr#}CB*kIIud*4@^t8@&d*!%x}iq7A!kjrkLxd)|0Ey~zmmIe84?#9H!HWr@sD$n!Fm1xJG&wN@UF9w{n3RL(W<%eVtJ77peFQ!niQ030-y A0{{R3 diff --git a/docs/css/style.css b/docs/css/style.css deleted file mode 100644 index 69db951..0000000 --- a/docs/css/style.css +++ /dev/null @@ -1,214 +0,0 @@ -* { - box-sizing: border-box; - outline: 0 -} - -*, -::after, -::before, -:after, -:before { - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale -} - -article, -footer, -header { - display: block -} - -html { - font-size: 100%; - -ms-text-size-adjust: 100%; - -webkit-text-size-adjust: 100%; -} - -body { - margin: 0; - font-family: 'Markazi Text', sans-serif; - font-size: 15px; - line-height: 27px; - color: #000 -} - -a:focus { - outline: thin dotted -} - -a:active, -a:hover { - outline: 0 -} - -p { - font-size: 20px; -} - -pre { - margin: 1em 0; - font-family: monospace, serif; - font-size: 1em; - white-space: pre-wrap; - word-wrap: break-word; - padding: 10px; - direction: ltr; - text-align: left; - color: #090910;; - background: #fbfbfd; -} - -ul { - padding: 0; - font-size: 20px; - margin: 1em 0; - list-style: none; - list-style-image: none -} - -a, -a:visited { - color: #666; - text-decoration: none -} - -h1 { - font-size: 30px; - text-transform: uppercase; - text-align: center; - margin-bottom: 25px; - position: relative; - padding: 0 0 20px 0 -} - -h2 { - font-size: 26px; - margin-bottom: 20px -} - -h3 { - font-size: 24px -} - -header#header { - background: #fbfbfd; - text-align: center; - line-height: 60px; - padding: 50px 30px; - margin: 0 0 30px 0; - border-bottom: 2px solid #ff6f6f; -} - -header#header h1 { - color: #ff6f6f; - font-family: sans; - font-weight: 700; - font-size: 70px; - line-height: 90px; -} - -header#header h1::after { - background: white; -} - -header#header h2 { - color: lightgray; -} - -.sidebar { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; -} - -.sticky { - position: -webkit-sticky; - position: sticky; - top: 10px; - padding: 0 15px; -} - -footer#footer { - background: #ddd; - color: #888; - padding: 30px 0; - margin-top: 30px -} - -@media (max-width:480px) { - header#header { - padding: 30px 15px - } - header#header h1 { - font-size: 44px; - line-height: 70px; - padding-bottom: 15px; - margin-bottom: 15px - } - header#header h2 { - font-size: 20px - } -} - -.container { - width: 100%; - padding-left: 15px; - padding-right: 15px; - margin-left: auto; - margin-right: auto; -} - -@media (min-width: 576px) { - .container { - max-width: 540px; - } -} - -@media (min-width: 768px) { - .container { - max-width: 720px; - } -} - -@media (min-width: 992px) { - .container { - max-width: 960px; - } -} - -@media (min-width: 1200px) { - .container { - max-width: 1140px; - } -} - -.row { - display: -ms-flexbox; - display: flex; - -ms-flex-wrap: wrap; - flex-wrap: wrap; - margin-left: -15px; - margin-right: -15px; -} - -.col-sm-3, .col-sm-6 { - position: relative; - width: 100%; - padding-left: 15px; - padding-right: 15px; -} - -@media (min-width: 576px) { - .col-sm-3 { - -ms-flex: 0 0 25%; - flex: 0 0 25%; - max-width: 25%; - } - .col-sm-9 { - -ms-flex: 0 0 75%; - flex: 0 0 75%; - max-width: 75%; - } -} \ No newline at end of file diff --git a/docs/en/index.html b/docs/en/index.html deleted file mode 100644 index 17de816..0000000 --- a/docs/en/index.html +++ /dev/null @@ -1,633 +0,0 @@ - - - - - Verta — Laravel plugin Jalali datetime - - - - - - - - - - Fork me on GitHub - - -
-
-
- -
-
-
-

Installation

-

Enter the following command to install Verta

-
$ composer require hekmatinasser/verta
-

You can add the package to your project by entering the following command

- -
// config/app.php
-'providers' => [
-    ...
-    Hekmatinasser\Verta\Laravel\VertaServiceProvider::class,
-],
-
-'alias' => [
-    ...
-    'Verta' => Hekmatinasser\Verta\Verta::class,
-]
-

Usage

-

Use the following command at the top of each file of the use Verta class

-
-use Verta;
-// or
-use Hekmatinasser\Verta\Verta;
-
-

Creator

-

To get the current datetime, use the following command

-
-$v = new Verta(); //1396-02-02 15:32:08
-$v = verta(); //1396-02-02 15:32:08
-
-

To get the current date and time, use the following command

-
-$v = Verta::now(); //1396-02-02 15:32:08
-$v = Verta::today(); //1396-03-02 00:00:00
-$v = Verta::tomorrow(); // 1396-03-03 00:00:00
-$v = Verta::yesterday(); // 1396-03-01 00:00:00
-
-

To get the current date and time similar datetime string, use the following command

-
-$v = new Verta('now'); // 1399-06-18 15:32:08
-$v = new Verta('-1 day'); //1399-06-17 15:07:04
-$v = new Verta('+1 month'); //1399-07-17 16:51:09
-$v = new Verta('next friday'); //1399-06-21 00:00:00
-$v = new Verta('last sunday'); //1399-06-16 00:00:00
-
- -

To convert your Gregorian datetime, use the following command

-
-$v = new Verta('2016-12-27 14:12:32');
-$v = Verta::instance('2016-12-25 11:12:36');
-$v = Facades\Verta::instance('2016-12-25 11:12:36');
-
-

To use the timestamp number, use the following command

-
-$v = new Verta(1333857600);
-
-

To use the Datetime class PHP, use the following command

-
-$dt = new \Datetime();
-return new Verta($dt); // 1395-12-09 15:05:56
-
-

To use the Carbon class, use the following command

-
-$c = \Carbon::now();
-return verta($c); // 1395-12-09 15:05:56
-// or
-\Illuminate\Support\Carbon::now()->toJalali(); // 1395-12-09 15:05:56
-// or with laravel helper
-now()->toJalali(); // 1395-12-09 15:05:56
-// or in models
-return $model->created_at->toJalali();
-
-

To use the jalali datetime as a string, use the following command

-
-$v = Verta::parse('1395-10-07 14:12:32');
-$v = Verta::parse('1396 مهر 17');
-$v =  Verta::parseFormat('Y n j','1396 مهر 17');
-
- -

If the date values are separate, use the following commands

-
-return Verta::create();  // 1395-12-14 11:17:01 equal now()
-return Verta::create(2016,12,25,15,20,15);  // 1395-10-05 15:20:15
-return Verta::createDate(2016,12,25); // 1395-10-05 21:35:49 set time now
-return Verta::createTime(15,51,5); // 1396-02-31 15:51:05 set date now
-
-// alias create functions
-return Verta::createGregorian(2016,12,25,15,20,15);  // 1395-10-05 15:20:15
-return Verta::createGregorianDate(2016,12,25); // 1395-10-05 21:35:49 set time now
-return Verta::createGregorianTime(15,51,5); // 1396-02-31 15:51:05 set date now
-
-

To use the timestamp numeric, use the following command

-
-return Verta::createTimestamp(1488614023); // 1395-12-14 11:23:43
-
-

If the date jalali values are separate, use the following commands

-
-// get Jalali datetime
-return Verta::createJalali(1394,12,29,15,51,5);  // 1394-12-29 15:51:05
-return Verta::createJalaliDate(1394,12,29); // 1394-12-29 11:18:29 set time now
-return Verta::createJalaliTime(15,51,5); // 1395-12-14 15:51:05 set date now
-
-

Transformations

-

Gregorian to Jalali date, use the following command

-
-return Verta::getJalali(2015,12,25); // [1394,10,4]
-
-

Jalali to Gregorian date, use the following command

-
-return Verta::getGregorian(1394,10,4); // [2015,12,25]
-
-

Verta to Datatime PHP, use the following command

-
-$dt = verta()->datetime();
-
-

Verta to Carbon, use the following command

-
-$c = Carbon::instance($v->datetime());
-// or
-$c = $v->toCarbon();
-
-

Property

-

To get property, use the following command

-
-$v = verta(); // 1396-03-14 14:18:23
-return $v->year; // 1396
-return $v->quarter // 1
-return $v->month; // 3
-return $v->day; // 14
-return $v->hour; // 14
-return $v->minute; // 18
-return $v->second; // 23
-return $v->micro; // 0
-return $v->dayOfWeek; // 1
-return $v->dayOfYear; // 107
-return $v->weekOfYear; // 16
-return $v->daysInMonth; // 31
-return $v->timestamp; // 1496557661
-return $v->timezone; // Asia/Tehran
-
-

To set property, use the following command

-
-$v = verta();
-$v->year = 1395;
-$v->month = 4; // set 13 for next year first month
-$v->day = 25;
-$v->hour = 16;
-$v->minute = 50;
-$v->second = 42;
-$v->timestamp = 1496557661;
-$v->timezone = 'Asia/Baku';
-
-

To set property with method, use the following command

-
-$v = $v->year(1395);
-$v = $v->month(4); // set 13 for next year first month
-$v = $v->day(25);
-$v = $v->hour(16);
-$v = $v->minute(50);
-$v = $v->second(42);
-$v = $v->timestamp(1496557661);
-$v = $v->timezone('Asia/Baku');
-
-

To set property together, use the following command

-
-$v = $v->setDateTime(1395, 4, 25, 16, 50, 42);
-$v = $v->setDateTime(1395, 4, 25, 16, 50, 42, 1569856);
-$v = $v->setDateJalali(1395, 4, 25);
-$v = $v->setTimeString('12:25:48');
-
-

Format

-

To output format, use the following command

-
-$v = verta();
-return $v->format('Y-n-j H:i'); // 1395-10-7 14:12
-return $v->format('%B %d، %Y'); // دی 07، 1395
-return $v->format('%Q %Y'); // زمستان 1395
-return $v; //1395-10-07 14:12:32
-
-

Read the PHP manual to create the format you want

-

- strftime - date -

-

To default output format, use the following command

-
-Verta::setStringformat('Y/n/j H:i:s');
-return verta(); // 1395/12/12 00:11:35
-
-

To reset output format, use the following command

-
-Verta::resetStringFormat();
-return verta(); // 1395-12-12 00:18:04
-
-

To display the datetime in standard formats, use the following command

-
-return $v->formatDatetime(); // 1395-12-10 23:37:26
-return $v->formatDate(); // 1395-12-10
-return $v->formatTime(); // 23:26:35
-return $v->formatJalaliDatetime(); // 1395/12/10 23:46:09
-return $v->formatJalaliDate(); // 1395/12/10
-
-

To output format Gregorian, use the following command

-
-return $v->formatGregorian('Y-m-d H:i:s'); // 2017-05-23 23:21:02
-
-

To display the date difference as a unit of time, use the following command

-

If you do set parameter, the difference is calculated with the current time

-
-return $v1->formatDifference($v2); // 12 ماه بعد
-return $v1->formatDifference($v3); // 1 سال قبل
-return $v1->addDays(25)->formatDifference(); // 4 هفته بعد
-return $v1->subDays(6)->formatDifference(); // 6 روز قبل
-return verta()->formatDifference(); // الان
-
-

To display numbers in alphabetical order, use the following command

-
-return $v->formatWord('Y'); // یک هزار و سیصد و نود و شش
-return $v->formatWord('l dS F'); // چهارشنبه بیست و نه ام شهریور
-return $v->formatWord('d F Y'); // بیست و نه شهریور یک هزار و سیصد و نود و شش
-return $v->formatWord('r'); // چهارشنبه یک هزار و سیصد و نود و شش, شش, بیست و نه, بیست و دو:چهل و نه:سی و هشت +04:30
-return $v->formatWord('d F ') . $v->year; // بیست و نه شهریور 1396
-
-

Modification

-

To add or sub datetime, use the following command

-
-$v = verta();
-return $v->addYear(); // 1396-10-07 14:12:32
-return $v->addYears(4); // 1399-10-07 14:12:32
-return $v->subYear(); // 1394-10-07 14:12:32
-return $v->subYears(2); // 1393-10-07 14:12:32
-
-
-return $v->addMonth(); // 1395-11-07 14:12:32
-return $v->addMonths(5); // 1396-03-07 14:12:32
-return $v->subMonth(); // 1395-09-07 14:12:32
-return $v->subMonths(2); // 1395-08-07 14:12:32
-
-
-return $v->addWeek(); // 1395-10-12 14:12:32
-return $v->addWeeks(3); // 1395-10-26 14:12:32
-return $v->subWeek(); // 1395-09-30 14:12:32
-return $v->subWeeks(2); // 1395-09-27 14:12:32
-
-
-return $v->addDay(); // 1395-10-08 14:12:32
-return $v->addDays(3); // 1395-10-11 14:12:32
-return $v->subDay(); // 1395-10-06 14:12:32
-return $v->subDays(2); // 1395-09-05 14:12:32
-
-
-return $v->addHour(); // 1395-10-07 15:12:32
-return $v->addHours(5); // 1395-10-07 19:12:32
-return $v->subHour(); // 1395-10-07 13:12:32
-return $v->subHours(2); // 1395-10-07 12:12:32
-
-
-return $v->addMinute(); // 1395-10-07 14:13:32
-return $v->addMinutes(3); // 1395-10-07 14:15:32
-return $v->subMinute(); // 1395-10-07 14:11:32
-return $v->subMinutes(2); // 1395-10-07 14:10:32
-
-
-return $v->addSecond(); // 1395-10-07 14:12:33
-return $v->addSeconds(3); // 1395-10-07 14:12:35
-return $v->subSecond(); // 1395-10-07 14:12:31
-return $v->subSeconds(2); // 1395-10-07 14:12:30
-
-

To get start or end datetime period, use the following command

-
-$v = verta(); // 1396-04-29 14:25:48
-return $v->startDay(); // 1396-04-29 00:00:00
-return $v->endDay(); // 1396-04-29 23:59:59
-
-
-return $v->startWeek(); // 1396 1396-04-24 00:00:00
-return $v->endWeek(); // 1396-04-30 23:59:59
-
-
-return $v->startMonth(); // 1396-04-01 00:00:00
-return $v->endMonth(); // 1396-04-31 00:00:00
-
-
-return $v->startQuarter(); // 1396-04-01 00:00:00
-return $v->endQuarter(); // 1396-06-31 23:59:59
-
-
-return $v->startYear(); // 1396-01-01 00:00:00
-return $v->endYear(); // 1396-12-29 23:59:59
-
-
-return $v->startHour(); // 1396-04-29 14:00:00
-return $v->endHour(); // 1396-04-29 14:59:59
-
-
-return $v->startMinute(); // 1396-04-29 14:25:00
-return $v->endMinute(); // 1396-04-29 14:25:59
-
-

Comparison

-

To validate datetime, use the following command

-
-return Verta::isLeapYear(1394); // false
-return Verta::isValidDate(1394, 12, 30); // false
-return Verta::isValidTime(15, 12, 30); // true
-
-

To difference datetime together, use the following command

-
-// diff objects together
-$v1 = verta(); // 1396-03-31 22:21:40
-$v2 = verta('2017-06-21 01:21:40'); // 1396-03-31 01:21:40
-$v3 = verta('2017-06-20'); // 1396-03-30 15:24:53
-
-return $v1->diffYears($v3); // -1
-return $v1->diffMonths($v2); // 11
-return $v2->diffMonths(); // -11 compare with now
-return $v1->diffWeeks($v2); // 51
-return $v1->diffDays($v3); // -372
-return $v3->diffMinutes(); // 536548
-return $v3->diffSeconds(); // 12261931
-
-

To compere datetime together, use the following command

-
-return $v1->eq(); // ture alias equalTo()
-return $v1->ne($v2); // true alias notEqualTo()
-return $v1->gt($v2); // true alias greaterThan()
-return $v1->gte($v2); // true alias greaterThanOrEqualTo()
-return $v1->lt($v2); // false alias lessThan()
-return $v1->lte($v2); // false alias lessThanOrEqualTo()
-return $v1->between($v2, $v3); // false
-
-

To compere datetime for closest, farthest, min or max together, use the following command

-
-return $v1->closest($v2, $v3); // return $v2 object
-return $v1->farthest($v2, $v3); // return $v3 object
-return $v1->minimum($v2); // return $v2
-return $v1->min($v2); // return $v2
-return $v1->maximum($v2); // return $v1
-return $v1->max($v2); // return $v1
-
-

To compere datetime now, use the following command

-
-return $v1->isWeekday(); // true
-return $v1->isWeekend(); // false
-return $v1->isYesterday(); // false
-return $v1->isToday(); // true
-return $v1->isTomorrow(); // false
-return $v1->isNextWeek(); // false
-return $v1->isLastWeek(); // false
-return $v1->isNextMonth(); // false
-return $v1->isLastMonth(); // false
-return $v1->isNextYear(); // false
-return $v1->isLastYear(); // false
-return $v1->isFuture(); // false
-return $v1->isPast(); // false
-
-return $v1->isCurrentYear(); // true
-return $v1->isSameAs('y', $v2); // true isSameYear()
-return $v1->isCurrentMonth(); // true
-return $v1->isSameMonth($v2); // true
-return $v1->isSameDay($v2); // true
-return $v1->isBirthday(); // true compare with today
-return $v1->isBirthday($v2); // true
-
-return $v1->isSaturday(); // false
-return $v1->isSunday(); // false
-return $v1->isMonday(); // false
-return $v1->isTuesday(); // false
-return $v1->isWednesday(); // false
-return $v1->isThursday(); // true
-return $v1->isFriday(); // false
-
-

Laravel Validator

-

You can validate form with Validator Laravel

-

You need to define error messages for jdate, ... rules in validation.php in lang folders.

-
-'jdate' => 'The :attribute is not valid Jalali date',
-'jdate_equal' => 'The :attribute is not equal Jalali date  :date',
-'jdate_not_equal' => 'The :attribute is\'nt not equal Jalali date  :date',
-'jdatetime' => 'The :attribute is not valid Jalali datetime',
-'jdatetime_equal' => 'The :attribute is not equal Jalali datetime :date',
-'jdatetime_not_equal' => 'The :attribute is\'nt not equal Jalali datetime :date',
-'jdate_after' => 'The :attribute must be a Jalali date after :date.',
-'jdate_after_equal' => 'The :attribute must be a Jalali date after or equal :date.',
-'jdatetime_after' => 'The :attribute must be a Jalali datetime after :date.',
-'jdatetime_after_equal' => 'The :attribute must be a Jalali datetime after or equal :date.',
-'jdate_before' => 'The :attribute must be a Jalali date before :date.',
-'jdate_before_equal' => 'The :attribute must be a Jalali date before or equal :date.',
-'jdatetime_before' => 'The :attribute must be a Jalali datetime before :date.',
-'jdatetime_before_equal' => 'The :attribute must be a Jalali datetime before or equal :date.',
-
-'attributes' => [
-    'start_date' => 'start date',
-    'expire_datetime' => 'expire datetime',
-],
-
-

Validation Rules

-

Determines if an input is a valid Jalali date with the specified format

-

The default format is Y/m/d

-
-'start_date' => 'jdate'
-'start_date' => 'jdate:Y/m/d'
-
-

Determines if an input is a valid Jalali date with the specified format and it is equal a given - date

-

The default format is Y/m/d

- -
-'start_date' => 'jdate_equal'
-'start_date' => 'jdate_equal:1388/01/01'
-'start_date' => 'jdate_equal:1388/01/01,Y/m/d'
-
- -

Determines if an input is a valid Jalali date with the specified format and it is not equal a - given date

-

The default format is Y/m/d

- -
-'start_date' => 'jdate_not_equal'
-'start_date' => 'jdate_not_equal:1388/01/01'
-'start_date' => 'jdate_not_equal:1388/01/01,Y/m/d'
-
-

Determines if an input is a valid Jalali datetime with the specified format

-

The default format is Y/m/d H:i:s

-
-'start_date' => 'jdatetime'
-'start_date' => 'jdatetime:Y/m/d H:i:s'
-
-

Determines if an input is a valid Jalali datetime with the specified format and it is equal a - given datetime

-

The default format is Y/m/d H:i:s

-
-'start_date' => 'jdatetime_equal'
-'start_date' => 'jdatetime_equal:1388/01/01 12:56:28'
-'start_date' => 'jdatetime_equal:1388/01/01 12:56:28,Y/m/d H:i:s'
-
-

Determines if an input is a valid Jalali datetime with the specified format and it is not equal a - given datetime

-

The default format is Y/m/d H:i:s

-
-'start_date' => 'jdatetime_not_equal'
-'start_date' => 'jdatetime_not_equal:1388/01/01 12:56:28'
-'start_date' => 'jdatetime_not_equal:1388/01/01 12:56:28,Y/m/d H:i:s'
-
- -

Determines if an input is a valid Jalali date with the specified format and it is after a given - date

-

The default date is now

-

The default format is Y/m/d

-
-'start_date' => 'jdate_after'
-'start_date' => 'jdate_after:1388/01/01'
-'start_date' => 'jdate_after:1388/01/01,Y/m/d'
-
-

Determines if an input is a valid Jalali datetime with the specified format and it is after or - equal a given datetime

-

The default date is now

-

The default format is Y/m/d

-
-'start_date' => 'jdate_after_equal'
-'start_date' => 'jdate_after_equal:1388/01/01'
-'start_date' => 'jdate_after_equal:1388/01/01,Y/m/d'
-
-

Determines if an input is a valid Jalali datetime with the specified format and it is after a - given datetime

-

The default date is now

-

The default format is Y/m/d H:i:s

-
-'start_date' => 'jdatetime_after'
-'start_date' => 'jdatetime_after:1388/01/01'
-'start_date' => 'jdatetime_after:1388/01/01,Y/m/d'
-
-

Determines if an input is a valid Jalali datetime with the specified format and it is after or - equal a given datetime

-

The default date is now

-

The default format is Y/m/d H:i:s

-
-'start_date' => 'jdatetime_after_equal'
-'start_date' => 'jdatetime_after_equal:1388/01/01'
-'start_date' => 'jdatetime_after_equal:1388/01/01,Y/m/d'
-
- -

Determines if an input is a valid Jalali date with the specified format and it is before a given - date

-

The default date is now

-

The default format is Y/m/d

-
-'start_date' => 'jdate_before'
-'start_date' => 'jdate_before:1388/01/01'
-'start_date' => 'jdate_before:1388/01/01,Y/m/d'
-
-

Determines if an input is a valid Jalali date with the specified format and it is before or equal - a given date

-

The default date is now

-

The default format is Y/m/d

-
-'start_date' => 'jdate_before_equal'
-'start_date' => 'jdate_before_equal:1388/01/01'
-'start_date' => 'jdate_before_equal:1388/01/01,Y/m/d'
-
-

Determines if an input is a valid Jalali datetime with the specified format and it is before a - given date-time

-

The default date is now

-

The default format is Y/m/d H:i:s

-
-'start_date' => 'jdatetime_before'
-'start_date' => 'jdatetime_before:1388/01/01'
-'start_date' => 'jdatetime_before:1388/01/01,Y/m/d'
-
-

Determines if an input is a valid Jalali datetime with the specified format and it is before or - equal a given datetime

-

The default date is now

-

The default format is Y/m/d H:i:s

-
-'start_date' => 'jdatetime_before_equal'
-'start_date' => 'jdatetime_before_equal:1388/01/01'
-'start_date' => 'jdatetime_before_equal:1388/01/01,Y/m/d'
-
-

Can combine the rules of the between the two boundaries

-
-$validate = Validator::make([
-    'start_date' => '1389/01/31',
-    'expire_datetime' => '1397/02/16 12:10:00',
-],
-[
-    'start_date' => 'required|jdate:Y/m/d|jdate_after:1388/01/01,Y/m/d|jdate_before:1390/01/01',
-    'expire_datetime' => 'required|jdatetime|jdatetime_after:1397/02/16 12:09:50,Y/m/d H:i:s|jdatetime_before:1397/02/16 12:11:00',
-]);
-
-if ($validate->fails()) {
-    dd($validate->messages()->toArray());
-}
-
-    //output
-array:2 [
-  "start_date" => array:1 [
-    0 => "The start date must be a Jalali date before 1390/01/01."
-  ]
-  "expire_datetime" => array:1 [
-    0 => "The expire datetime must be a Jalali datetime before 1397/02/16 12:10:00."
-  ]
-]
-
- - -

Traslation

-

You can show weekdays, months , messages in the languages available in Verta To view supported - languages, go to the folder langs

-

To set locale, use the following command

-
-Verta::setLocale('fa');
-
-

To get current locale, use the following command

-
-Verta::getLocale(); // fa
-
-

To reset locale to fa, use the following command

-
-Verta::resetLocale();
-
-
-
-
-
- -
-
- 2017-2021 © -
-
- - - diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 138f60d..0000000 --- a/docs/index.html +++ /dev/null @@ -1,635 +0,0 @@ - - - - - Verta — پکیج تاریخ شمسی در لاراول - - - - - - - - - - - Fork me on GitHub - - -
-
- -
-
-

نصب

-

برای نصب دستور زیر را وارد کنید

-
$ composer require hekmatinasser/verta
-

می توانید پکیج را درون پروژه خود اضافه کنید برای این کار دستور زیر را وارد کنید

- -
// config/app.php
-'providers' => [
-    ...
-    Hekmatinasser\Verta\Laravel\VertaServiceProvider::class,
-],
-
-'alias' => [
-    ...
-    'Verta' => Hekmatinasser\Verta\Verta::class,
-]
-

نحوه استفاده

-

در بالای هر فایل خود از کلاس ورتا استفاده میکند، از دستور زیر استفاده کنید

-
-use Verta;
-// or
-use Hekmatinasser\Verta\Verta;
-
-

ایجاد کردن

-

برای بدست آوردن تاریخ و زمان کنونی شمسی، از دستور زیر استفاده کنید

-
-$v = new Verta(); //1396-02-02 15:32:08
-$v = verta(); //1396-02-02 15:32:08
-
-

برای بدست آوردن تاریخ و زمان به نسبت اکنون، از دستور زیر استفاده کنید

-
-$v = Verta::now(); //1396-02-02 15:32:08
-$v = Verta::today(); //1396-03-02 00:00:00
-$v = Verta::tomorrow(); // 1396-03-03 00:00:00
-$v = Verta::yesterday(); // 1396-03-01 00:00:00
-
-

برای بدست آوردن تاریخ و زمان به نسبت اکنون مانند تاریخ زمان پی اچ پی به صورت رشته ، از دستور زیر - استفاده کنید

-
-$v = new Verta('now'); // 1399-06-18 15:32:08
-$v = new Verta('-1 day'); //1399-06-17 15:07:04
-$v = new Verta('+1 month'); //1399-07-17 16:51:09
-$v = new Verta('next friday'); //1399-06-21 00:00:00
-$v = new Verta('last sunday'); //1399-06-16 00:00:00
-
- -

برای تبدیل تاریخ میلادی خود به شمسی، از دستور زیر استفاده کنید

-
-$v = new Verta('2016-12-27 14:12:32');
-$v = Verta::instance('2016-12-25 11:12:36');
-$v = Facades\Verta::instance('2016-12-25 11:12:36');
-
-

برای استفاده از عدد تایم استمپ به شمسی، از دستور زیر استفاده کنید

-
-$v = new Verta(1333857600);
-
-

برای استفاده از کلاس تاریخ و زمان پی اچ پی به شمسی، از دستور زیر استفاده کنید

-
-$dt = new \Datetime();
-return new Verta($dt); // 1395-12-09 15:05:56
-
-

برای استفاده از کلاس کربن به شمسی، از دستور زیر استفاده کنید

-
-$c = \Carbon::now();
-return verta($c); // 1395-12-09 15:05:56
-// or
-\Illuminate\Support\Carbon::now()->toJalali(); // 1395-12-09 15:05:56
-// or with laravel helper
-now()->toJalali(); // 1395-12-09 15:05:56
-// or in models
-return $model->created_at->toJalali();
-
-

برای استفاده از تاریخ شمسی به صورت رشته، از دستور زیر استفاده کنید

-
-$v = Verta::parse('1395-10-07 14:12:32');
-$v = Verta::parse('1396 مهر 17');
-$v =  Verta::parseFormat('Y n j','1396 مهر 17');
-
- -

در صورتی مقادیر تاریخ میلادی به صورت جداگانه باشد، از دستورات زیر استفاده کنید

-
-return Verta::create();  // 1395-12-14 11:17:01 equal now()
-return Verta::create(2016,12,25,15,20,15);  // 1395-10-05 15:20:15
-return Verta::createDate(2016,12,25); // 1395-10-05 21:35:49 set time now
-return Verta::createTime(15,51,5); // 1396-02-31 15:51:05 set date now
-
-// alias create functions
-return Verta::createGregorian(2016,12,25,15,20,15);  // 1395-10-05 15:20:15
-return Verta::createGregorianDate(2016,12,25); // 1395-10-05 21:35:49 set time now
-return Verta::createGregorianTime(15,51,5); // 1396-02-31 15:51:05 set date now
-
-

برای استفاده از عدد تایم استمپ به شمسی، از دستور زیر استفاده کنید

-
-return Verta::createTimestamp(1488614023); // 1395-12-14 11:23:43
-
-

در صورتی مقادیر تاریخ شمسی به صورت جداگانه باشد، از دستورات زیر استفاده کنید

-
-// get Jalali datetime
-return Verta::createJalali(1394,12,29,15,51,5);  // 1394-12-29 15:51:05
-return Verta::createJalaliDate(1394,12,29); // 1394-12-29 11:18:29 set time now
-return Verta::createJalaliTime(15,51,5); // 1395-12-14 15:51:05 set date now
-
-

تبدیل تاریخ

-

برای تبدیل از میلادی به شمسی به صورت ساده، از دستور زیر استفاده کنید

-
-return Verta::getJalali(2015,12,25); // [1394,10,4]
-
-

برای تبدیل از شمسی به میلادی به صورت ساده، از دستور زیر استفاده کنید

-
-return Verta::getGregorian(1394,10,4); // [2015,12,25]
-
-

برای تبدیل تاریخ از ورتا به تاریخ و زمان پی اچ پی، از دستور زیر استفاده کنید

-
-$dt = verta()->datetime();
-
-

برای تبدیل تاریخ از ورتا به کربن، از دستور زیر استفاده کنید

-
-$c = Carbon::instance($v->datetime());
-// or
-$c = $v->toCarbon();
-
-

خصوصیات

-

برای دریافت مقادیر خصوصیات، از دستورات زیر استفاده کنید

-
-$v = verta(); // 1396-03-14 14:18:23
-return $v->year; // 1396
-return $v->quarter // 1
-return $v->month; // 3
-return $v->day; // 14
-return $v->hour; // 14
-return $v->minute; // 18
-return $v->second; // 23
-return $v->micro; // 0
-return $v->dayOfWeek; // 1
-return $v->dayOfYear; // 107
-return $v->weekOfYear; // 16
-return $v->daysInMonth; // 31
-return $v->timestamp; // 1496557661
-return $v->timezone; // Asia/Tehran
-
-

برای مقدار دهی خصوصیات، از دستورات زیر استفاده کنید

-
-$v = verta();
-$v->year = 1395;
-$v->month = 4; // عدد 13 برای ثبت سال آینده اولین ماه
-$v->day = 25;
-$v->hour = 16;
-$v->minute = 50;
-$v->second = 42;
-$v->timestamp = 1496557661;
-$v->timezone = 'Asia/Baku';
-
-

برای مقدار دهی خصوصیات با استفاده از تابع، از دستورات زیر استفاده کنید

-
-$v = $v->year(1395);
-$v = $v->month(4); // set 13 for next year first month
-$v = $v->day(25);
-$v = $v->hour(16);
-$v = $v->minute(50);
-$v = $v->second(42);
-$v = $v->timestamp(1496557661);
-$v = $v->timezone('Asia/Baku');
-
-

برای مقدار دهی خصوصیات با یکدیگر، از دستورات زیر استفاده کنید

-
-$v = $v->setDateTime(1395, 4, 25, 16, 50, 42);
-$v = $v->setDateTime(1395, 4, 25, 16, 50, 42, 1569856);
-$v = $v->setDateJalali(1395, 4, 25);
-$v = $v->setTimeString('12:25:48');
-
-

قالب نمایش

-

برای نمایش تاریخ به شمسی، از دستور زیر استفاده کنید

-
-$v = verta();
-return $v->format('Y-n-j H:i'); // 1395-10-7 14:12
-return $v->format('%B %d، %Y'); // دی 07، 1395
-return $v->format('%Q %Y'); // زمستان 1395
-return $v; //1395-10-07 14:12:32
-
-

برای ساخت فرمت نمایش مورد نظر خود راهنمای پی اچ پی را مطالعه کنید

-

- strftime - date -

-

برای تعیین فرمت خروجی پیش فرض، از دستور زیر استفاده کنید

-
-Verta::setStringformat('Y/n/j H:i:s');
-return verta(); // 1395/12/12 00:11:35
-
-

برای تنظیم مجددفرمت خروجی به حالت اولیه، از دستور زیر استفاده کنید

-
-Verta::resetStringFormat();
-return verta(); // 1395-12-12 00:18:04
-
-

برای نمایش تاریخ با فرمت های متعارف، از دستور زیر استفاده کنید

-
-return $v->formatDatetime(); // 1395-12-10 23:37:26
-return $v->formatDate(); // 1395-12-10
-return $v->formatTime(); // 23:26:35
-return $v->formatJalaliDatetime(); // 1395/12/10 23:46:09
-return $v->formatJalaliDate(); // 1395/12/10
-
-

برای نمایش تاریخ به صورت میلادی، از دستور زیر استفاده کنید

-
-return $v->formatGregorian('Y-m-d H:i:s'); // 2017-05-23 23:21:02
-
-

برای نمایش اختلاف تاریخ به صورت واحد زمانی، از دستور زیر استفاده کنید

-

درصورتی که تاریخ را وارد نکنید، اختلاف با زمان کنونی محاسبه می شود.

-
-return $v1->formatDifference($v2); // 12 ماه بعد
-return $v1->formatDifference($v3); // 1 سال قبل
-return $v1->addDays(25)->formatDifference(); // 4 هفته بعد
-return $v1->subDays(6)->formatDifference(); // 6 روز قبل
-return verta()->formatDifference(); // الان
-
-

برای نمایش اعداد به صورت حروف، از دستور زیر استفاده کنید

-
-return $v->formatWord('Y'); // یک هزار و سیصد و نود و شش
-return $v->formatWord('l dS F'); // چهارشنبه بیست و نه ام شهریور
-return $v->formatWord('d F Y'); // بیست و نه شهریور یک هزار و سیصد و نود و شش
-return $v->formatWord('r'); // چهارشنبه یک هزار و سیصد و نود و شش, شش, بیست و نه, بیست و دو:چهل و نه:سی و هشت +04:30
-return $v->formatWord('d F ') . $v->year; // بیست و نه شهریور 1396
-
-

تغییر دادن

-

برای اضافه یا کم کردن از تاریخ خود، از دستور زیر استفاده کنید

-
-$v = verta();
-return $v->addYear(); // 1396-10-07 14:12:32
-return $v->addYears(4); // 1399-10-07 14:12:32
-return $v->subYear(); // 1394-10-07 14:12:32
-return $v->subYears(2); // 1393-10-07 14:12:32
-
-
-return $v->addMonth(); // 1395-11-07 14:12:32
-return $v->addMonths(5); // 1396-03-07 14:12:32
-return $v->subMonth(); // 1395-09-07 14:12:32
-return $v->subMonths(2); // 1395-08-07 14:12:32
-
-
-return $v->addWeek(); // 1395-10-12 14:12:32
-return $v->addWeeks(3); // 1395-10-26 14:12:32
-return $v->subWeek(); // 1395-09-30 14:12:32
-return $v->subWeeks(2); // 1395-09-27 14:12:32
-
-
-return $v->addDay(); // 1395-10-08 14:12:32
-return $v->addDays(3); // 1395-10-11 14:12:32
-return $v->subDay(); // 1395-10-06 14:12:32
-return $v->subDays(2); // 1395-09-05 14:12:32
-
-
-return $v->addHour(); // 1395-10-07 15:12:32
-return $v->addHours(5); // 1395-10-07 19:12:32
-return $v->subHour(); // 1395-10-07 13:12:32
-return $v->subHours(2); // 1395-10-07 12:12:32
-
-
-return $v->addMinute(); // 1395-10-07 14:13:32
-return $v->addMinutes(3); // 1395-10-07 14:15:32
-return $v->subMinute(); // 1395-10-07 14:11:32
-return $v->subMinutes(2); // 1395-10-07 14:10:32
-
-
-return $v->addSecond(); // 1395-10-07 14:12:33
-return $v->addSeconds(3); // 1395-10-07 14:12:35
-return $v->subSecond(); // 1395-10-07 14:12:31
-return $v->subSeconds(2); // 1395-10-07 14:12:30
-
-

برای بدست آوردن تاریخ شروع و پایان هر بازه زمانی، از دستور زیر استفاده کنید

-
-$v = verta(); // 1396-04-29 14:25:48
-return $v->startDay(); // 1396-04-29 00:00:00
-return $v->endDay(); // 1396-04-29 23:59:59
-
-
-return $v->startWeek(); // 1396 1396-04-24 00:00:00
-return $v->endWeek(); // 1396-04-30 23:59:59
-
-
-return $v->startMonth(); // 1396-04-01 00:00:00
-return $v->endMonth(); // 1396-04-31 00:00:00
-
-
-return $v->startQuarter(); // 1396-04-01 00:00:00
-return $v->endQuarter(); // 1396-06-31 23:59:59
-
-
-return $v->startYear(); // 1396-01-01 00:00:00
-return $v->endYear(); // 1396-12-29 23:59:59
-
-
-return $v->startHour(); // 1396-04-29 14:00:00
-return $v->endHour(); // 1396-04-29 14:59:59
-
-
-return $v->startMinute(); // 1396-04-29 14:25:00
-return $v->endMinute(); // 1396-04-29 14:25:59
-
-

بررسی و مقایسه

-

برای اعتبار سنجی تاریخ، از دستور زیر استفاده کنید

-
-return Verta::isLeapYear(1394); // false
-return Verta::isValidDate(1394, 12, 30); // false
-return Verta::isValidTime(15, 12, 30); // true
-
-

برای محاسبه اختلاف تاریخ ها با یکدیگر، از دستور زیر استفاده کنید

-
-// diff objects together
-$v1 = verta(); // 1396-03-31 22:21:40
-$v2 = verta('2017-06-21 01:21:40'); // 1396-03-31 01:21:40
-$v3 = verta('2017-06-20'); // 1396-03-30 15:24:53
-
-return $v1->diffYears($v3); // -1
-return $v1->diffMonths($v2); // 11
-return $v2->diffMonths(); // -11 مقایسه با زمان کنونی
-return $v1->diffWeeks($v2); // 51
-return $v1->diffDays($v3); // -372
-return $v3->diffMinutes(); // 536548
-return $v3->diffSeconds(); // 12261931
-
-

برای مقایسه تاریخ ها با یکدیگر، از دستور زیر استفاده کنید

-
-return $v1->eq(); // ture alias equalTo()
-return $v1->ne($v2); // true alias notEqualTo()
-return $v1->gt($v2); // true alias greaterThan()
-return $v1->gte($v2); // true alias greaterThanOrEqualTo()
-return $v1->lt($v2); // false alias lessThan()
-return $v1->lte($v2); // false alias lessThanOrEqualTo()
-return $v1->between($v2, $v3); // false
-
-

برای بررسی تاریخ از لحاظ نزدیکتر یا دورتر بودن و یا کوچکتر و بزرگتر بودن، از دستور زیر استفاده - کنید

-
-return $v1->closest($v2, $v3); // return $v2 object
-return $v1->farthest($v2, $v3); // return $v3 object
-return $v1->minimum($v2); // return $v2
-return $v1->min($v2); // return $v2
-return $v1->maximum($v2); // return $v1
-return $v1->max($v2); // return $v1
-
-

برای بررسی تاریخ فعلی، از دستورات زیر استفاده کنید

-
-return $v1->isWeekday(); // true
-return $v1->isWeekend(); // false
-return $v1->isYesterday(); // false
-return $v1->isToday(); // true
-return $v1->isTomorrow(); // false
-return $v1->isNextWeek(); // false
-return $v1->isLastWeek(); // false
-return $v1->isNextMonth(); // false
-return $v1->isLastMonth(); // false
-return $v1->isNextYear(); // false
-return $v1->isLastYear(); // false
-return $v1->isFuture(); // false
-return $v1->isPast(); // false
-
-return $v1->isCurrentYear(); // true
-return $v1->isSameAs('y', $v2); // true isSameYear()
-return $v1->isCurrentMonth(); // true
-return $v1->isSameMonth($v2); // true
-return $v1->isSameDay($v2); // true
-return $v1->isBirthday(); // true compare with today
-return $v1->isBirthday($v2); // true
-
-return $v1->isSaturday(); // false
-return $v1->isSunday(); // false
-return $v1->isMonday(); // false
-return $v1->isTuesday(); // false
-return $v1->isWednesday(); // false
-return $v1->isThursday(); // true
-return $v1->isFriday(); // false
-
-

اعتبار سنجی

-

شما می توانید با اعتبار سنجی لاراول تاریخ های شمسی درون فرم های خود استفاده کنید

-

شما باید پیام های خطا برای اعتبار سنجی خود در در مسیر فایل های ترجمه خود اضافه کنید ارور های - ترجمه شده برای زبان های قابل پشتیبانی در زبان ها مراجعه کنید - قرار دارد .برای نمونه کد هایی که درون پکیج برای پیام خطا وجود دارد در فایل ترجمه خود قرار - دهیدبرای مثال در فایل ترجمه پیام خطا به آرایه عبارات زیر را اضافه کنید

-
-'jdate' => ':attribute تاریخ شمسی معتبر نمی باشد.',
-'jdate_equal' => ':attribute تاریخ شمسی برابر :date نمی باشد.',
-'jdate_not_equal' => ':attribute تاریخ شمسی نامساوی :date نمی باشد.',
-'jdatetime' => ':attribute تاریخ و زمان شمسی معتبر نمی باشد.',
-'jdatetime_equal' => ':attribute تاریخ و زمان شمسی مساوی :date نمی باشد.',
-'jdatetime_not_equal' => ':attribute تاریخ و زمان شمسی نامساوی :date نمی باشد.',
-'jdate_after' => ':attribute تاریخ شمسی باید بعد از :date باشد.',
-'jdate_after_equal' => ':attribute تاریخ شمسی باید بعد یا برابر از :date باشد.',
-'jdatetime_after' => ':attribute تاریخ و زمان شمسی باید بعد از :date باشد.',
-'jdatetime_after_equal' => ':attribute تاریخ و زمان شمسی باید بعد یا برابر از :date باشد.',
-'jdate_before' => ':attribute تاریخ شمسی باید قبل از :date باشد.',
-'jdate_before_equal' => ':attribute تاریخ شمسی باید قبل یا برابر از :date باشد.',
-'jdatetime_before' => ':attribute تاریخ و زمان شمسی باید قبل از :date باشد.',
-'jdatetime_before_equal' => ':attribute تاریخ و زمان شمسی باید قبل یا برابر از :date باشد.',
-
-'attributes' => [
-    'start_date' => 'تاریخ شروع',
-    'expire_datetime' => 'تاریخ انقضا',
-],
-
-

قوانین اعتبار سنجی

-

اگر تاریخ شمسی با فرمت معین درست باشد

-

فرمت پیش فرض Y/m/d می باشد

-
-'start_date' => 'jdate'
-'start_date' => 'jdate:Y/m/d'
-
-

اگر تاریخ شمسی با فرمت تعیین شده مساوی باشد

-

فرمت پیش فرض Y/m/d می باشد

- -
-'start_date' => 'jdate_equal'
-'start_date' => 'jdate_equal:1388/01/01'
-'start_date' => 'jdate_equal:1388/01/01,Y/m/d'
-
- -

اگر تاریخ شمسی با فرمت تعیین شده نامساوی باشد

-

فرمت پیش فرض Y/m/d می باشد

- -
-'start_date' => 'jdate_not_equal'
-'start_date' => 'jdate_not_equal:1388/01/01'
-'start_date' => 'jdate_not_equal:1388/01/01,Y/m/d'
-
-

اگر تاریخ و زمان شمسی با فرمت تعیین شده درست باشد

-

فرمت پیش فرض Y/m/d H:i:s می باشد

-
-'start_date' => 'jdatetime'
-'start_date' => 'jdatetime:Y/m/d H:i:s'
-
-

اگر تاریخ و زمان شمسی با فرمت تعیین شده مساوی باشد

-

فرمت پیش فرض Y/m/d H:i:s می باشد

-
-'start_date' => 'jdatetime_equal'
-'start_date' => 'jdatetime_equal:1388/01/01 12:56:28'
-'start_date' => 'jdatetime_equal:1388/01/01 12:56:28,Y/m/d H:i:s'
-
-

اگر تاریخ و زمان شمسی با فرمت تعیین شده نامساوی باشد

-

فرمت پیش فرض Y/m/d H:i:s می باشد

-
-'start_date' => 'jdatetime_not_equal'
-'start_date' => 'jdatetime_not_equal:1388/01/01 12:56:28'
-'start_date' => 'jdatetime_not_equal:1388/01/01 12:56:28,Y/m/d H:i:s'
-
- -

اگر تاریخ شمسی با فرمت تعیین شده درست باشد و بعد از تاریخ تعیین شده باشد

-

درصورتی که تاریخ وارد کنید تاریخ فعلی در نظر میگیرد

-

فرمت پیش فرض Y/m/d می باشد

-
-'start_date' => 'jdate_after'
-'start_date' => 'jdate_after:1388/01/01'
-'start_date' => 'jdate_after:1388/01/01,Y/m/d'
-
-

اگر تاریخ شمسی با فرمت تعیین شده درست باشد و بعد یا مساوی از تاریخ تعیین شده باشد

-

درصورتی که تاریخ وارد کنید تاریخ فعلی در نظر میگیرد

-

فرمت پیش فرض Y/m/d می باشد

-
-'start_date' => 'jdate_after_equal'
-'start_date' => 'jdate_after_equal:1388/01/01'
-'start_date' => 'jdate_after_equal:1388/01/01,Y/m/d'
-
-

اگر تاریخ و زمان شمسی با فرمت تعیین شده درست باشد و بعد از تاریخ تعیین شده باشد

-

درصورتی که تاریخ وارد کنید تاریخ فعلی در نظر میگیرد

-

فرمت پیش فرض Y/m/d H:i:s می باشد

-
-'start_date' => 'jdatetime_after'
-'start_date' => 'jdatetime_after:1388/01/01'
-'start_date' => 'jdatetime_after:1388/01/01,Y/m/d'
-
-

اگر تاریخ و زمان شمسی با فرمت تعیین شده درست باشد و بعد یا مساوی از تاریخ تعیین شده باشد

-

درصورتی که تاریخ وارد کنید تاریخ فعلی در نظر میگیرد

-

فرمت پیش فرض Y/m/d H:i:s می باشد

-
-'start_date' => 'jdatetime_after_equal'
-'start_date' => 'jdatetime_after_equal:1388/01/01'
-'start_date' => 'jdatetime_after_equal:1388/01/01,Y/m/d'
-
- -

اگر تاریخ شمسی با فرمت تعیین شده درست باشد و قبل از تاریخ تعیین شده باشد

-

درصورتی که تاریخ وارد کنید قبل از تاریخ فعلی باشد باشد

-

فرمت پیش فرض Y/m/d می باشد

-
-'start_date' => 'jdate_before'
-'start_date' => 'jdate_before:1388/01/01'
-'start_date' => 'jdate_before:1388/01/01,Y/m/d'
-
-

اگر تاریخ شمسی با فرمت تعیین شده درست باشد و قبل یا مساوی از تاریخ تعیین شده باشد

-

درصورتی که تاریخ وارد کنید قبل از تاریخ فعلی باشد باشد

-

فرمت پیش فرض Y/m/d می باشد

-
-'start_date' => 'jdate_before_equal'
-'start_date' => 'jdate_before_equal:1388/01/01'
-'start_date' => 'jdate_before_equal:1388/01/01,Y/m/d'
-
-

اگر تاریخ و زمان شمسی با فرمت تعیین شده درست باشد و قبل از تاریخ تعیین شده باشد

-

درصورتی که تاریخ وارد کنید قبل از تاریخ فعلی باشد باشد

-

فرمت پیش فرض Y/m/d H:i:s می باشد

-
-'start_date' => 'jdatetime_before'
-'start_date' => 'jdatetime_before:1388/01/01'
-'start_date' => 'jdatetime_before:1388/01/01,Y/m/d'
-
-

اگر تاریخ و زمان شمسی با فرمت تعیین شده درست باشد و قبل یا مساوی از تاریخ تعیین شده باشد

-

درصورتی که تاریخ وارد کنید قبل از تاریخ فعلی باشد باشد

-

فرمت پیش فرض Y/m/d H:i:s می باشد

-
-'start_date' => 'jdatetime_before_equal'
-'start_date' => 'jdatetime_before_equal:1388/01/01'
-'start_date' => 'jdatetime_before_equal:1388/01/01,Y/m/d'
-
-

میتوانید با ترکیب قوانین تاریخ را بین دو محدوده بررسی کنید

-
-$validate = Validator::make([
-    'start_date' => '1389/01/31',
-    'expire_datetime' => '1397/02/16 12:10:00',
-],
-[
-    'start_date' => 'required|jdate:Y/m/d|jdate_after:1388/01/01,Y/m/d|jdate_before:1390/01/01',
-    'expire_datetime' => 'required|jdatetime|jdatetime_after:1397/02/16 12:09:50,Y/m/d H:i:s|jdatetime_before:1397/02/16 12:11:00',
-]);
-
-if ($validate->fails()) {
-dd($validate->messages()->toArray());
-}
-
-//output
-array:2 [
-    "start_date" => array:1 [
-        0 => "تاریخ شروع تاریخ شمسی باید قبل از ۱۳۹۰/۰۱/۰۱ باشد."
-    ]
-    "expire_datetime" => array:1 [
-        0 => "تاریخ انقضا تاریخ و زمان شمسی باید قبل از ۱۳۹۷/۰۲/۱۶ ۱۲:۱۰:۰۰ باشد."
-    ]
-]
-
- -

زبان ها

-

شما میتوانید ایام و ماه ها و پیام را به زبان های موجود در ورتا نمایش دهید برای مشاهده زبان ها - پشتیبانی می شود به پوشه زیر مشاهده - زبان ها مراجعه کنید -

-

برای تعیین زبان پیام های از دستور زیر استفاده کنید

-
-Verta::setLocale('fa');
-
-

برای دریافت زبان جاری پیام های از دستور زیر استفاده کنید

-
-Verta::getLocale(); // fa
-
-

برای ریست کردن زبان به فارسی از دستور زیر استفاده کنید

-
-Verta::resetLocale();
-
-

برای افزودن زبان های دیگر نمونه فایل های موجود را برای ادغام با پروژه ارسال کنید

- -
-
-
-
- -
-
- 2017-2021 © -
- -
- - - diff --git a/src/Lang/ar.php b/src/Lang/ar.php deleted file mode 100644 index 07cb1d7..0000000 --- a/src/Lang/ar.php +++ /dev/null @@ -1,82 +0,0 @@ - [ - '0' => '۰', - '1' => '۱', - '2' => '۲', - '3' => '۳', - '4' => '٤', - '5' => '٥', - '6' => '٦', - '7' => '۷', - '8' => '۸', - '9' => '۹', - ], - 'year_months' => [ - '1' => 'حَمَل', - '2' => 'ثَور', - '3' => 'جَوزا', - '4' => 'سَرَطان', - '5' => 'اَسَد', - '6' => 'سُنبُله', - '7' => 'میزان', - '8' => 'عَقرَب', - '9' => 'قَوس', - '10' => 'جَدْی', - '11' => 'دَلو', - '12' => 'حوت', - ], - 'weekdays' => [ - '1' => 'السبت', - '2' => 'الأحد', - '3' => 'الاثنين', - '4' => 'يوم الثلاثاء', - '5' => 'الأربعاء', - '6' => 'يوم الخميس', - '7' => 'جمعة', - ], - 'date_units' => [ - 'second' => 'ثواني', - 'mintue' => 'الدقائق', - 'hour' => 'الساعة', - 'day' => 'يوم', - 'week' => 'أسبوع', - 'month' => 'شهر', - 'yaer' => 'سنة', - 'decade' => 'عشر سنوات', - 'century' => 'مئة عام', - ], - 'phrase' => [ - 'am' => 'ق ظ', - 'pm' => 'ب ظ', - 'ante_meridiem' => 'صباحي', - 'post_meridiem' => 'بعد الظهر', - 'th' => '', - 'ago' => 'قبل', - 'now' => 'الآن', - 'later' => 'التالي', - ], - 'validation' => [ - 'jdate' => ':attribute x ليس تاريخ جلالي صالحًا', - 'jdate_equal' => ':attribute لا يساوي تاريخ جلالي :date', - 'jdate_not_equal' => 'ال :attribute لا يساوي تاريخ جلالي :date', - 'jdatetime' => ':attribute غير صالح لتاريخ جلالي', - 'jdatetime_equal' => ':attribute ليس مساويًا لـ تاريخ جلالي :date', - 'jdatetime_not_equal' => ':attribute لا يساوي تاريخ جلالي :date', - 'jdate_after' => 'يجب أن يكون :attribute تاريخ جلالي بعد :date.', - 'jdate_after_equal' => 'يجب أن يكون :attribute هو تاريخ جلالي بعد :date أو يساوي.', - 'jdatetime_after' => 'يجب أن يكون :attribute عبارة عن تاريخ جلالي بعد :date.', - 'jdatetime_after_equal' => 'يجب أن يكون :attribute عبارة عن تاريخ جلالي بعد :date أو يساوي.', - 'jdate_before' => 'يجب أن يكون :attribute تاريخ جلالي قبل :date.', - 'jdate_before_equal' => 'يجب أن يكون :attribute تاريخ جلالي قبل :date أو يساوي.', - 'jdatetime_before' => 'يجب أن يكون :attribute هو تاريخ جلالي قبل :date.', - 'jdatetime_before_equal' => 'يجب أن يكون :attribute هو تاريخ جلالي قبل أو يساوي :date.', - ], - 'quarters' => [ - '1' => 'ربيع', - '2' => 'الصيف', - '3' => 'الخريف', - '4' => 'شتاء', - ], -]; diff --git a/src/Lang/az.php b/src/Lang/az.php deleted file mode 100644 index 9050577..0000000 --- a/src/Lang/az.php +++ /dev/null @@ -1,82 +0,0 @@ - [ - '0' => '۰', - '1' => '۱', - '2' => '۲', - '3' => '۳', - '4' => '۴', - '5' => '۵', - '6' => '۶', - '7' => '۷', - '8' => '۸', - '9' => '۹', - ], - 'year_months' => [ - '1' => 'آغلارگولر', - '2' => 'گولن', - '3' => 'قیزاران', - '4' => 'قورا پیشیرن', - '5' => 'قویروق دوغان', - '6' => 'زومار', - '7' => 'خزل', - '8' => 'قیروو', - '9' => 'آذر', - '10' => 'چیلله', - '11' => 'دوندوران', - '12' => 'بایرام', - ], - 'weekdays' => [ - '1' => 'شنبه', - '2' => 'یکشنبه', - '3' => 'دوشنبه', - '4' => 'سه شنبه', - '5' => 'چهارشنبه', - '6' => 'پنج شنبه', - '7' => 'جمعه', - ], - 'date_units' => [ - 'second' => 'ثانیه', - 'mintue' => 'دقیقه', - 'hour' => 'ساعت', - 'day' => 'روز', - 'week' => 'هفته', - 'month' => 'ماه', - 'yaer' => 'سال', - 'decade' => 'دهه', - 'century' => 'قرن', - ], - 'phrase' => [ - 'am' => 'ق ظ', - 'pm' => 'ب ظ', - 'ante_meridiem' => 'قبل از ظهر', - 'post_meridiem' => 'بعد از ظهر', - 'th' => 'ام', - 'ago' => 'قبل', - 'now' => 'الان', - 'later' => 'بعد', - ], - 'validation' => [ - 'jdate' => ':attribute' . ' تاریخ شمسی معتبر نمی باشد.', - 'jdate_equal' => ':attribute' . ' تاریخ شمسی برابر ' . ':date' . ' نمی باشد.', - 'jdate_not_equal' => ':attribute' . ' تاریخ شمسی نامساوی ' . ':date' . ' نمی باشد.', - 'jdatetime' => ':attribute' . ' تاریخ و زمان شمسی معتبر نمی باشد.', - 'jdatetime_equal' => ':attribute' . ' تاریخ و زمان شمسی مساوی ' . ':date' . ' نمی باشد.', - 'jdatetime_not_equal' => ':attribute' . ' تاریخ و زمان شمسی نامساوی ' . ':date' . ' نمی باشد.', - 'jdate_after' => ':attribute' . ' تاریخ شمسی باید بعد از ' . ':date' . ' باشد.', - 'jdate_after_equal' => ':attribute' . ' تاریخ شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', - 'jdatetime_after' => ':attribute' . ' تاریخ و زمان شمسی باید بعد از ' . ':date' . ' باشد.', - 'jdatetime_after_equal' => ':attribute' . ' تاریخ و زمان شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', - 'jdate_before' => ':attribute' . ' تاریخ شمسی باید قبل از ' . ':date' . ' باشد.', - 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', - 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', - 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', - ], - 'quarters' => [ - '1' => 'بهار', - '2' => 'تابستان', - '3' => 'پاییز', - '4' => 'زمستان', - ], -]; diff --git a/src/Lang/en.php b/src/Lang/en.php deleted file mode 100644 index 8066c8c..0000000 --- a/src/Lang/en.php +++ /dev/null @@ -1,82 +0,0 @@ - [ - '0' => '0', - '1' => '1', - '2' => '2', - '3' => '3', - '4' => '4', - '5' => '5', - '6' => '6', - '7' => '7', - '8' => '8', - '9' => '9', - ], - 'year_months' => [ - '1' => 'farvardin', - '2' => 'ordibehesht', - '3' => 'khordad', - '4' => 'tir', - '5' => 'mordad', - '6' => 'shahrivar', - '7' => 'mehr', - '8' => 'aban', - '9' => 'azar', - '10' => 'dey', - '11' => 'bahman', - '12' => 'esfand', - ], - 'weekdays' => [ - '1' => 'saturday', - '2' => 'sunday', - '3' => 'monday', - '4' => 'tuesday', - '5' => 'wednesday', - '6' => 'thursday', - '7' => 'friday', - ], - 'date_units' => [ - 'second' => 'second', - 'mintue' => 'mintue', - 'hour' => 'hour', - 'day' => 'day', - 'week' => 'week', - 'month' => 'month', - 'yaer' => 'yaer', - 'decade' => 'decade', - 'century' => 'century', - ], - 'phrase' => [ - 'am' => 'am', - 'pm' => 'pm', - 'ante_meridiem' => 'ante meridiem', - 'post_meridiem' => 'post meridiem', - 'th' => 'th', - 'ago' => 'ago', - 'now' => 'now', - 'later' => 'later', - ], - 'validation' => [ - 'jdate' => 'The :attribute is not valid Jalali date', - 'jdate_equal' => 'The :attribute is not equal Jalali date :date', - 'jdate_not_equal' => 'The :attribute is\'nt not equal Jalali date :date', - 'jdatetime' => 'The :attribute is not valid Jalali datetime', - 'jdatetime_equal' => 'The :attribute is not equal Jalali datetime :date', - 'jdatetime_not_equal' => 'The :attribute is\'nt not equal Jalali datetime :date', - 'jdate_after' => 'The :attribute must be a Jalali date after :date.', - 'jdate_after_equal' => 'The :attribute must be a Jalali date after or equal :date.', - 'jdatetime_after' => 'The :attribute must be a Jalali datetime after :date.', - 'jdatetime_after_equal' => 'The :attribute must be a Jalali datetime after or equal :date.', - 'jdate_before' => 'The :attribute must be a Jalali date before :date.', - 'jdate_before_equal' => 'The :attribute must be a Jalali date before or equal :date.', - 'jdatetime_before' => 'The :attribute must be a Jalali datetime before :date.', - 'jdatetime_before_equal' => 'The :attribute must be a Jalali datetime before or equal :date.', - ], - 'quarters' => [ - '1' => 'spring', - '2' => 'summer', - '3' => 'autumn', - '4' => 'winter', - ], -]; diff --git a/src/Lang/fa.php b/src/Lang/fa.php deleted file mode 100644 index 31a92da..0000000 --- a/src/Lang/fa.php +++ /dev/null @@ -1,82 +0,0 @@ - [ - '0' => '۰', - '1' => '۱', - '2' => '۲', - '3' => '۳', - '4' => '۴', - '5' => '۵', - '6' => '۶', - '7' => '۷', - '8' => '۸', - '9' => '۹', - ], - 'year_months' => [ - '1' => 'فروردین', - '2' => 'اردیبهشت', - '3' => 'خرداد', - '4' => 'تیر', - '5' => 'مرداد', - '6' => 'شهریور', - '7' => 'مهر', - '8' => 'آبان', - '9' => 'آذر', - '10' => 'دی', - '11' => 'بهمن', - '12' => 'اسفند', - ], - 'weekdays' => [ - '1' => 'شنبه', - '2' => 'یکشنبه', - '3' => 'دوشنبه', - '4' => 'سه شنبه', - '5' => 'چهارشنبه', - '6' => 'پنج شنبه', - '7' => 'جمعه', - ], - 'date_units' => [ - 'second' => 'ثانیه', - 'mintue' => 'دقیقه', - 'hour' => 'ساعت', - 'day' => 'روز', - 'week' => 'هفته', - 'month' => 'ماه', - 'yaer' => 'سال', - 'decade' => 'دهه', - 'century' => 'قرن', - ], - 'phrase' => [ - 'am' => 'ق ظ', - 'pm' => 'ب ظ', - 'ante_meridiem' => 'قبل از ظهر', - 'post_meridiem' => 'بعد از ظهر', - 'th' => 'ام', - 'ago' => 'قبل', - 'now' => 'الان', - 'later' => 'بعد', - ], - 'validation' => [ - 'jdate' => ':attribute' . ' تاریخ شمسی معتبر نمی باشد.', - 'jdate_equal' => ':attribute' . ' تاریخ شمسی برابر ' . ':date' . ' نمی باشد.', - 'jdate_not_equal' => ':attribute' . ' تاریخ شمسی نامساوی ' . ':date' . ' نمی باشد.', - 'jdatetime' => ':attribute' . ' تاریخ و زمان شمسی معتبر نمی باشد.', - 'jdatetime_equal' => ':attribute' . ' تاریخ و زمان شمسی مساوی ' . ':date' . ' نمی باشد.', - 'jdatetime_not_equal' => ':attribute' . ' تاریخ و زمان شمسی نامساوی ' . ':date' . ' نمی باشد.', - 'jdate_after' => ':attribute' . ' تاریخ شمسی باید بعد از ' . ':date' . ' باشد.', - 'jdate_after_equal' => ':attribute' . ' تاریخ شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', - 'jdatetime_after' => ':attribute' . ' تاریخ و زمان شمسی باید بعد از ' . ':date' . ' باشد.', - 'jdatetime_after_equal' => ':attribute' . ' تاریخ و زمان شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', - 'jdate_before' => ':attribute' . ' تاریخ شمسی باید قبل از ' . ':date' . ' باشد.', - 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', - 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', - 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', - ], - 'quarters' => [ - '1' => 'بهار', - '2' => 'تابستان', - '3' => 'پاییز', - '4' => 'زمستان', - ], -]; diff --git a/src/Lang/haz.php b/src/Lang/haz.php deleted file mode 100644 index b6c015d..0000000 --- a/src/Lang/haz.php +++ /dev/null @@ -1,82 +0,0 @@ - [ - '0' => '۰', - '1' => '۱', - '2' => '۲', - '3' => '۳', - '4' => '۴', - '5' => '۵', - '6' => '۶', - '7' => '۷', - '8' => '۸', - '9' => '۹', - ], - 'year_months' => [ - '1' => 'اورال', - '2' => 'اید', - '3' => 'بررید', - '4' => 'سرتایستو', - '5' => 'چیله تایستو', - '6' => 'آخیر تایستو', - '7' => 'تخم ریز', - '8' => 'برگ ریز', - '9' => 'چیله زمستو', - '10' => 'بامو', - '11' => 'سیاه بار', - '12' => 'نجیر', - ], - 'weekdays' => [ - '1' => 'شنبه', - '2' => 'یکشنبه', - '3' => 'دوشنبه', - '4' => 'سه شنبه', - '5' => 'چهارشنبه', - '6' => 'پنج شنبه', - '7' => 'جمعه', - ], - 'date_units' => [ - 'second' => 'ثانیه', - 'mintue' => 'دقیقه', - 'hour' => 'ساعت', - 'day' => 'روز', - 'week' => 'هفته', - 'month' => 'ماه', - 'yaer' => 'سال', - 'decade' => 'دهه', - 'century' => 'قرن', - ], - 'phrase' => [ - 'am' => 'ق ظ', - 'pm' => 'ب ظ', - 'ante_meridiem' => 'قبل از ظهر', - 'post_meridiem' => 'بعد از ظهر', - 'th' => 'ام', - 'ago' => 'قبل', - 'now' => 'الان', - 'later' => 'بعد', - ], - 'validation' => [ - 'jdate' => ':attribute' . ' تاریخ شمسی معتبر نمی باشد.', - 'jdate_equal' => ':attribute' . ' تاریخ شمسی برابر ' . ':date' . ' نمی باشد.', - 'jdate_not_equal' => ':attribute' . ' تاریخ شمسی نامساوی ' . ':date' . ' نمی باشد.', - 'jdatetime' => ':attribute' . ' تاریخ و زمان شمسی معتبر نمی باشد.', - 'jdatetime_equal' => ':attribute' . ' تاریخ و زمان شمسی مساوی ' . ':date' . ' نمی باشد.', - 'jdatetime_not_equal' => ':attribute' . ' تاریخ و زمان شمسی نامساوی ' . ':date' . ' نمی باشد.', - 'jdate_after' => ':attribute' . ' تاریخ شمسی باید بعد از ' . ':date' . ' باشد.', - 'jdate_after_equal' => ':attribute' . ' تاریخ شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', - 'jdatetime_after' => ':attribute' . ' تاریخ و زمان شمسی باید بعد از ' . ':date' . ' باشد.', - 'jdatetime_after_equal' => ':attribute' . ' تاریخ و زمان شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', - 'jdate_before' => ':attribute' . ' تاریخ شمسی باید قبل از ' . ':date' . ' باشد.', - 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', - 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', - 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', - ], - 'quarters' => [ - '1' => 'بهار', - '2' => 'تابستان', - '3' => 'پاییز', - '4' => 'زمستان', - ], -]; diff --git a/src/Lang/ku.php b/src/Lang/ku.php deleted file mode 100644 index 49c713f..0000000 --- a/src/Lang/ku.php +++ /dev/null @@ -1,82 +0,0 @@ - [ - '0' => '۰', - '1' => '۱', - '2' => '۲', - '3' => '۳', - '4' => '۴', - '5' => '۵', - '6' => '۶', - '7' => '۷', - '8' => '۸', - '9' => '۹', - ], - 'year_months' => [ - '1' => 'خاکه‌لێوه', - '2' => 'گوڵان', - '3' => 'جۆزەردان', - '4' => 'پووشپەڕ', - '5' => 'گەلاوێژ', - '6' => 'خەرمانان', - '7' => 'ڕەزبەر', - '8' => 'خەزەڵوەر', - '9' => 'سەرماوەز', - '10' => 'بەفرانبار', - '11' => 'ڕێبەندان', - '12' => 'رەشەمە', - ], - 'weekdays' => [ - '1' => 'شه ممه', - '2' => 'یه کشه ممه', - '3' => 'دوو شه ممه', - '4' => 'سی شه ممه', - '5' => 'چوار شه ممه', - '6' => 'په ن شه ممم', - '7' => 'هه ینی', - ], - 'date_units' => [ - 'second' => 'ثانیه', - 'mintue' => 'دقیقه', - 'hour' => 'ساعت', - 'day' => 'روز', - 'week' => 'هفته', - 'month' => 'ماه', - 'yaer' => 'سال', - 'decade' => 'دهه', - 'century' => 'قرن', - ], - 'phrase' => [ - 'am' => 'ق ظ', - 'pm' => 'ب ظ', - 'ante_meridiem' => 'قبل از ظهر', - 'post_meridiem' => 'بعد از ظهر', - 'th' => 'ام', - 'ago' => 'قبل', - 'now' => 'الان', - 'later' => 'بعد', - ], - 'validation' => [ - 'jdate' => ':attribute' . ' تاریخ شمسی معتبر نمی باشد.', - 'jdate_equal' => ':attribute' . ' تاریخ شمسی برابر ' . ':date' . ' نمی باشد.', - 'jdate_not_equal' => ':attribute' . ' تاریخ شمسی نامساوی ' . ':date' . ' نمی باشد.', - 'jdatetime' => ':attribute' . ' تاریخ و زمان شمسی معتبر نمی باشد.', - 'jdatetime_equal' => ':attribute' . ' تاریخ و زمان شمسی مساوی ' . ':date' . ' نمی باشد.', - 'jdatetime_not_equal' => ':attribute' . ' تاریخ و زمان شمسی نامساوی ' . ':date' . ' نمی باشد.', - 'jdate_after' => ':attribute' . ' تاریخ شمسی باید بعد از ' . ':date' . ' باشد.', - 'jdate_after_equal' => ':attribute' . ' تاریخ شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', - 'jdatetime_after' => ':attribute' . ' تاریخ و زمان شمسی باید بعد از ' . ':date' . ' باشد.', - 'jdatetime_after_equal' => ':attribute' . ' تاریخ و زمان شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', - 'jdate_before' => ':attribute' . ' تاریخ شمسی باید قبل از ' . ':date' . ' باشد.', - 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', - 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', - 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', - ], - 'quarters' => [ - '1' => 'بهار', - '2' => 'تابستان', - '3' => 'پاییز', - '4' => 'زمستان', - ], -]; diff --git a/src/Lang/ps.php b/src/Lang/ps.php deleted file mode 100644 index 2639790..0000000 --- a/src/Lang/ps.php +++ /dev/null @@ -1,81 +0,0 @@ - [ - '0' => '۰', - '1' => '۱', - '2' => '۲', - '3' => '۳', - '4' => '۴', - '5' => '۵', - '6' => '۶', - '7' => '۷', - '8' => '۸', - '9' => '۹', - ], - 'year_months' => [ - '1' => 'وری', - '2' => 'غویی', - '3' => 'غبرګولی', - '4' => 'چنګاښ', - '5' => 'زمری', - '6' => 'وږی', - '7' => 'تله', - '8' => 'لړم', - '9' => 'لیندۍ', - '10' => 'مرغومی', - '11' => 'سلواغه', - '12' => 'کب', - ], - 'weekdays' => [ - '1' => 'شنبې', - '2' => 'یکشنبه', - '3' => 'دوشنبه', - '4' => 'سې شنبه', - '5' => 'چهارشنبه', - '6' => 'پنج شنبه', - '7' => 'جمعه', - ], - 'date_units' => [ - 'second' => 'ثانیه', - 'mintue' => 'دقیقه', - 'hour' => 'ساعت', - 'day' => 'روز', - 'week' => 'هفته', - 'month' => 'ماه', - 'yaer' => 'سال', - 'century' => 'قرن', - ], - 'phrase' => [ - 'am' => 'ق ظ', - 'pm' => 'ب ظ', - 'ante_meridiem' => 'قبل از ظهر', - 'post_meridiem' => 'بعد از ظهر', - 'th' => 'ام', - 'ago' => 'قبل', - 'now' => 'الان', - 'later' => 'بعد', - ], - 'validation' => [ - 'jdate' => ':attribute' . ' تاریخ شمسی معتبر نمی باشد.', - 'jdate_equal' => ':attribute' . ' تاریخ شمسی برابر ' . ':date' . ' نمی باشد.', - 'jdate_not_equal' => ':attribute' . ' تاریخ شمسی نامساوی ' . ':date' . ' نمی باشد.', - 'jdatetime' => ':attribute' . ' تاریخ و زمان شمسی معتبر نمی باشد.', - 'jdatetime_equal' => ':attribute' . ' تاریخ و زمان شمسی مساوی ' . ':date' . ' نمی باشد.', - 'jdatetime_not_equal' => ':attribute' . ' تاریخ و زمان شمسی نامساوی ' . ':date' . ' نمی باشد.', - 'jdate_after' => ':attribute' . ' تاریخ شمسی باید بعد از ' . ':date' . ' باشد.', - 'jdate_after_equal' => ':attribute' . ' تاریخ شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', - 'jdatetime_after' => ':attribute' . ' تاریخ و زمان شمسی باید بعد از ' . ':date' . ' باشد.', - 'jdatetime_after_equal' => ':attribute' . ' تاریخ و زمان شمسی باید بعد یا برابر از ' . ':date' . ' باشد.', - 'jdate_before' => ':attribute' . ' تاریخ شمسی باید قبل از ' . ':date' . ' باشد.', - 'jdate_before_equal' => ':attribute' . ' تاریخ شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', - 'jdatetime_before' => ':attribute' . ' تاریخ و زمان شمسی باید قبل از ' . ':date' . ' باشد.', - 'jdatetime_before_equal' => ':attribute' . ' تاریخ و زمان شمسی باید قبل یا برابر از ' . ':date' . ' باشد.', - ], - 'quarters' => [ - '1' => 'بهار', - '2' => 'تابستان', - '3' => 'پاییز', - '4' => 'زمستان', - ], -]; diff --git a/src/Laravel/VertaServiceProvider.php b/src/Laravel/VertaServiceProvider.php index a38dfe7..21665a0 100644 --- a/src/Laravel/VertaServiceProvider.php +++ b/src/Laravel/VertaServiceProvider.php @@ -111,7 +111,6 @@ class VertaServiceProvider extends ServiceProvider foreach ($this->rules as $name => $methods) { if (array_key_exists('extend', $methods) || array_key_exists('replacer', $methods)) { Validator::extend($name, $className . $methods['extend']); - Validator::replacer($name, $className . $methods['replacer']); } } diff --git a/src/Traits/Accessor.php b/src/Traits/Accessor.php deleted file mode 100644 index 44de992..0000000 --- a/src/Traits/Accessor.php +++ /dev/null @@ -1,261 +0,0 @@ - 'Y', - 'month' => 'n', - 'day' => 'j', - 'hour' => 'G', - 'minute' => 'i', - 'second' => 's', - 'micro' => 'u', - 'dayOfWeek' => 'w', - 'dayOfYear' => 'z', - 'weekOfYear' => 'W', - 'daysInMonth' => 't', - 'timestamp' => 'U', - ]; - - if (array_key_exists($name, $formats)) { - return (int) $this->format($formats[$name]); - } elseif ($name === 'quarter') { - return (int) ceil($this->month / static::MONTHS_PER_QUARTER); - } elseif ($name === 'timezone') { - return $this->getTimezone()->getName(); - } - - throw new InvalidArgumentException(sprintf("Unknown getter '%s'", $name)); - } - - /** - * Check if an attribute exists on the object - * - * @param string $name - * @return bool - */ - public function __isset($name) - { - try { - $this->__get($name); - } catch (InvalidArgumentException $e) { - return false; - } - - return true; - } - - /** - * Set a part of the Verta object - * - * @param string $name - * @param \DateTimeZone|int|string $value - * @throws \InvalidArgumentException - */ - public function __set($name, $value) - { - switch ($name) { - case 'year': - case 'month': - case 'day': - case 'hour': - case 'minute': - case 'second': - list($year, $month, $day, $hour, $minute, $second) = explode('-', $this->format('Y-n-j-G-i-s')); - $$name = $value; - $this->setDateTime($year, $month, $day, $hour, $minute, $second); - - break; - - case 'timestamp': - $this->setTimestamp($value); - - break; - - case 'timezone': - case 'tz': - $this->setTimezone(new DateTimeZone($value)); - - break; - - default: - throw new InvalidArgumentException(sprintf("Unknown setter '%s'", $name)); - } - } - - /** - * Set the instance's year - * - * @param int $value - * @return static - */ - public function year($value) - { - $this->year = $value; - - return $this; - } - - /** - * Set the instance's month - * - * @param int $value - * @return static - */ - public function month($value) - { - $this->month = $value; - - return $this; - } - - /** - * Set the instance's day - * - * @param int $value - * @return static - */ - public function day($value) - { - $this->day = $value; - - return $this; - } - - /** - * Set the instance's hour - * - * @param int $value - * @return static - */ - public function hour($value) - { - $this->hour = $value; - - return $this; - } - - /** - * Set the instance's minute - * - * @param int $value - * @return static - */ - public function minute($value) - { - $this->minute = $value; - - return $this; - } - - /** - * Set the instance's second - * - * @param int $value - * @return static - */ - public function second($value) - { - $this->second = $value; - - return $this; - } - - /** - * Set the instance's timestamp - * - * @param int $value - * @return static - */ - public function timestamp($value) - { - return parent::setTimestamp($value); - } - - /** - * Alias for setTimezone() - * - * @param \DateTimeZone|string $value - * - * @return static - */ - public function timezone($value) - { - return parent::setTimezone(new DateTimeZone($value)); - } - - /** - * Set the date and time all together - * - * @param int $year - * @param int $month - * @param int $day - * @param int $hour - * @param int $minute - * @param int $second - * @param int $microseconds - * - * @return Verta - */ - public function setDateTime($year, $month, $day, $hour, $minute, $second = 0, $microseconds = 0) - { - return $this->setDateJalali($year, $month, $day)->setTime($hour, $minute, $second, $microseconds); - } - - /** - * Sets the current date of the DateTime object to a different date. - * Calls modify as a workaround for a php bug - * - * @param int $year - * @param int $month - * @param int $day - * - * @return Verta - */ - public function setDateJalali($year, $month, $day): Verta - { - if (static::isValidDate($year, $month, $day)) { - list($year, $month, $day) = self::getGregorian($year, $month, $day); - parent::setDate($year, $month, $day); - } - - return $this; - } - - /** - * Set the time by time string - * - * @param string $time - * @return Verta - * @throws \InvalidArgumentException - */ - public function setTimeString($time): Verta - { - $time = explode(':', $time); - - $hour = $time[0]; - $minute = $time[1] ?? 0; - $second = $time[2] ?? 0; - - if (static::isValidTime($hour, $minute, $second)) { - parent::setTime($hour, $minute, $second, 0); - } - - return $this; - } -} diff --git a/src/Traits/Boundaries.php b/src/Traits/Boundaries.php deleted file mode 100644 index 4f3d402..0000000 --- a/src/Traits/Boundaries.php +++ /dev/null @@ -1,160 +0,0 @@ -setTime($this->hour, $this->minute, 0); - } - - /** - * Resets the time to 23:59:59 - * - * @return static - */ - public function endMinute() - { - return $this->setTime($this->hour, $this->minute, 59); - } - - /** - * Resets the time to 00:00:00 - * - * @return static - */ - public function startHour() - { - return $this->setTime($this->hour, 0, 0); - } - - /** - * Resets the time to 23:59:59 - * - * @return static - */ - public function endHour() - { - return $this->setTime($this->hour, 59, 59); - } - - /** - * Resets the time to 00:00:00 - * - * @return static - */ - public function startDay() - { - return $this->setTime(0, 0, 0); - } - - /** - * Resets the time to 23:59:59 - * - * @return static - */ - public function endDay() - { - return $this->setTime(23, 59, 59); - } - - /** - * Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00 - * - * @return static - */ - public function startWeek() - { - while ($this->dayOfWeek !== static::$weekStartsAt) { - $this->subDay(); - } - - return $this->startDay(); - } - - /** - * Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59 - * - * @return static - */ - public function endWeek() - { - while ($this->dayOfWeek !== static::$weekEndsAt) { - $this->addDay(); - } - - return $this->endDay(); - } - - /** - * Resets the date to the first day of the month and the time to 00:00:00 - * - * @return static - */ - public function startMonth() - { - return $this->setDateTime($this->year, $this->month, 1, 0, 0, 0); - } - - /** - * Resets the date to end of the month and time to 23:59:59 - * - * @return static - */ - public function endMonth() - { - return $this->setDateTime($this->year, $this->month, $this->daysInMonth, 23, 59, 59); - } - - /** - * Resets the date to the first day of the quarter and the time to 00:00:00 - * - * @return static - */ - public function startQuarter() - { - $month = ($this->quarter - 1) * static::MONTHS_PER_QUARTER + 1; - - return $this->setDateTime($this->year, $month, 1, 0, 0, 0); - } - - /** - * Resets the date to end of the quarter and time to 23:59:59 - * - * @return static - */ - public function endQuarter() - { - $month = $this->quarter * static::MONTHS_PER_QUARTER; - - return $this->setDateJalali($this->year, $month, 1)->endMonth(); - } - - /** - * Resets the date to the first day of the year and the time to 00:00:00 - * - * @return static - */ - public function startYear() - { - return $this->setDateTime($this->year, 1, 1, 0, 0, 0); - } - - /** - * Resets the date to end of the year and time to 23:59:59 - * - * @return static - */ - public function endYear() - { - $day = $this->format('L') ? 30 : 29; - - return $this->setDateTime($this->year, 12, $day, 23, 59, 59); - } -} diff --git a/src/Traits/Comparison.php b/src/Traits/Comparison.php deleted file mode 100644 index f0a5081..0000000 --- a/src/Traits/Comparison.php +++ /dev/null @@ -1,607 +0,0 @@ - 32766) { - return false; - } - if ($month < 1 || $month > 12) { - return false; - } - $dayLastMonthJalali = static::isLeapYear($year) && ($month == 12) ? 30 : static::$daysMonthJalali[intval($month) - 1]; - if ($day < 1 || $day > $dayLastMonthJalali) { - return false; - } - - return true; - } - - /** - * validate a time - * - * @param int $hour - * @param int $minute - * @param int $second - * @return bool - */ - public static function isValidTime($hour, $minute, $second) - { - return $hour >= 0 && $hour <= 23 - && $minute >= 0 && $minute <= 59 - && $second >= 0 && $second <= 59; - } - - /** - * Determines if the instance is equal to another - * - * @param Verta $v - * - * @return bool - */ - public function eq(Verta $v = null) - { - return $this == ($v ?: new static()); - } - - /** - * Determines if the instance is equal to another - * - * @param Verta $v - * - * @see eq() - * - * @return bool - */ - public function equalTo(Verta $v = null) - { - return $this->eq($v); - } - - /** - * Determines if the instance is not equal to another - * - * @param Verta $v - * - * @return bool - */ - public function ne(Verta $v = null) - { - return ! $this->eq($v); - } - - /** - * Determines if the instance is not equal to another - * - * @param Verta $v - * - * @see ne() - * - * @return bool - */ - public function notEqualTo(Verta $v = null) - { - return $this->ne($v); - } - - /** - * Determines if the instance is greater (after) than another - * - * @param Verta $v - * - * @return bool - */ - public function gt(Verta $v = null) - { - return $this > ($v ?: new static()); - } - - /** - * Determines if the instance is greater (after) than another - * - * @param Verta $v - * - * @see gt() - * - * @return bool - */ - public function greaterThan(Verta $v = null) - { - return $this->gt($v); - } - - /** - * Determines if the instance is greater (after) than or equal to another - * - * @param Verta $v - * - * @return bool - */ - public function gte(Verta $v = null) - { - return $this >= ($v ?: new static()); - } - - /** - * Determines if the instance is greater (after) than or equal to another - * - * @param Verta $v - * - * @see gte() - * - * @return bool - */ - public function greaterThanOrEqualTo(Verta $v = null) - { - return $this->gte($v); - } - - /** - * Determines if the instance is less (before) than another - * - * @param Verta $v - * - * @return bool - */ - public function lt(Verta $v = null) - { - return $this < ($v ?: new static()); - } - - /** - * Determines if the instance is less (before) than another - * - * @param Verta $v - * - * @see lt() - * - * @return bool - */ - public function lessThan(Verta $v = null) - { - return $this->lt($v); - } - - /** - * Determines if the instance is less (before) or equal to another - * - * @param Verta $v - * - * @return bool - */ - public function lte(Verta $v = null) - { - return $this <= ($v ?: new static()); - } - - /** - * Determines if the instance is less (before) or equal to another - * - * @param Verta $v - * - * @see lte() - * - * @return bool - */ - public function lessThanOrEqualTo(Verta $v = null) - { - return $this->lte($v); - } - - /** - * Determines if the instance is between two others - * - * @param Verta $v1 - * @param Verta $v2 - * @param bool $equal Indicates if a > and < comparison should be used or <= or >= - * - * @return bool - */ - public function between(Verta $v1, Verta $v2, $equal = true) - { - if ($v1->gt($v2)) { - $temp = $v1; - $v1 = $v2; - $v2 = $temp; - } - - if ($equal) { - return $this->gte($v1) && $this->lte($v2); - } - - return $this->gt($v1) && $this->lt($v2); - } - - /** - * Get the closest date from the instance. - * - * @param Verta $v1 - * @param Verta $v2 - * - * @return static - */ - public function closest(Verta $v1, Verta $v2) - { - return $this->diffSeconds($v1) < $this->diffSeconds($v2) ? $v1 : $v2; - } - - /** - * Get the farthest date from the instance. - * - * @param Verta $v1 - * @param Verta $v2 - * - * @return static - */ - public function farthest(Verta $v1, Verta $v2) - { - return $this->diffSeconds($v1) > $this->diffSeconds($v2) ? $v1 : $v2; - } - - /** - * Get the minimum instance between a given instance (default now) and the current instance. - * - * @param Verta|null $v - * - * @return static - */ - public function min(Verta $v = null) - { - $v = $v ?: static::now($this->getTimezone()); - - return $this->lt($v) ? $this : $v; - } - - /** - * Get the minimum instance between a given instance (default now) and the current instance. - * - * @param Verta|null $v - * - * @see min() - * - * @return static - */ - public function minimum(Verta $v = null) - { - return $this->min($v); - } - - /** - * Get the maximum instance between a given instance (default now) and the current instance. - * - * @param Verta|null $v - * - * @return static - */ - public function max(Verta $v = null) - { - $v = $v ?: static::now($this->getTimezone()); - - return $this->gt($v) ? $this : $v; - } - - /** - * Get the maximum instance between a given instance (default now) and the current instance. - * - * @param Verta|null $v - * - * @see max() - * - * @return static - */ - public function maximum(Verta $v = null) - { - return $this->max($v); - } - - /** - * Determines if the instance is a weekday - * - * @return bool - */ - public function isWeekday() - { - return ! $this->isWeekend(); - } - - /** - * Determines if the instance is a weekend day - * - * @return bool - */ - public function isWeekend() - { - return in_array($this->dayOfWeek, static::$weekendDays); - } - - /** - * Determines if the instance is yesterday - * - * @return bool - */ - public function isYesterday() - { - return $this->formatDate() === static::yesterday($this->getTimezone())->formatDate(); - } - - /** - * Determines if the instance is today - * - * @return bool - */ - public function isToday() - { - return $this->formatDate() === static::now($this->getTimezone())->formatDate(); - } - - /** - * Determines if the instance is tomorrow - * - * @return bool - */ - public function isTomorrow() - { - return $this->formatDate() === static::tomorrow($this->getTimezone())->formatDate(); - } - - /** - * Determines if the instance is within the next week - * - * @return bool - */ - public function isNextWeek(): bool - { - return $this->weekOfYear === static::now($this->getTimezone())->addWeek()->weekOfYear; - } - - /** - * Determines if the instance is within the last week - * - * @return bool - */ - public function isLastWeek() - { - return $this->weekOfYear === static::now($this->getTimezone())->subWeek()->weekOfYear; - } - - /** - * Determines if the instance is within the next month - * - * @return bool - */ - public function isNextMonth() - { - return $this->format('Y-m') === static::now($this->getTimezone())->addMonth()->format('Y-m'); - } - - /** - * Determines if the instance is within the last month - * - * @return bool - */ - public function isLastMonth() - { - return $this->format('Y-m') === static::now($this->getTimezone())->subMonth()->format('Y-m'); - } - - /** - * Determines if the instance is within next year - * - * @return bool - */ - public function isNextYear() - { - return $this->year === static::now($this->getTimezone())->addYear()->year; - } - - /** - * Determines if the instance is within the previous year - * - * @return bool - */ - public function isLastYear() - { - return $this->year === static::now($this->getTimezone())->subYear()->year; - } - - /** - * Determines if the instance is in the future, ie. greater (after) than now - * - * @return bool - */ - public function isFuture() - { - return $this->gt(static::now($this->getTimezone())); - } - - /** - * Determines if the instance is in the past, ie. less (before) than now - * - * @return bool - */ - public function isPast() - { - return $this->lt(static::now($this->getTimezone())); - } - - /** - * Compares the formatted values of the two dates. - * - * @param string $format The date formats to compare. - * @param Verta|null $v The instance to compare with or null to use current day. - * - * @return bool - */ - public function isSameAs($format, Verta $v = null) - { - $v = $v ?: static::now($this->getTimezone()); - - return $this->format($format) === $v->format($format); - } - - /** - * Determines if the instance is in the current year - * - * @return bool - */ - public function isCurrentYear() - { - return $this->isSameYear(); - } - - /** - * Checks if the passed in date is in the same year as the instance year. - * - * @param Verta|null $v The instance to compare with or null to use current day. - * - * @return bool - */ - public function isSameYear(Verta $v = null) - { - return $this->isSameAs('Y', $v); - } - - /** - * Determines if the instance is in the current month - * - * @return bool - */ - public function isCurrentMonth() - { - return $this->isSameMonth(); - } - - /** - * Checks if the passed in date is in the same month as the instance month (and year if needed). - * $this->assertFalse($datetime->isCurrentMonth()); - - * @param Verta|null $v The instance to compare with or null to use current day. - * @param bool $ofSameYear Check if it is the same month in the same year. - * - * @return bool - */ - public function isSameMonth(Verta $v = null, $ofSameYear = false) - { - $format = $ofSameYear ? 'Y-m' : 'm'; - - return $this->isSameAs($format, $v); - } - - /** - * Checks if the passed in date is the same day as the instance current day. - * - * @param Verta $v - * - * @return bool - */ - public function isSameDay(Verta $v) - { - return $this->formatDate() === $v->formatDate(); - } - - /** - * Check if its the birthday. Compares the date/month values of the two dates. - * - * @param Verta|null $dt The instance to compare with or null to use current day. - * - * @return bool - */ - public function isBirthday(Verta $v = null) - { - return $this->isSameAs('md', $v); - } - - /** - * Checks if this day is a Saturday. - * - * @return bool - */ - public function isSaturday() - { - return $this->dayOfWeek === static::SATURDAY; - } - - /** - * Checks if this day is a Sunday. - * - * @return bool - */ - public function isSunday() - { - return $this->dayOfWeek === static::SUNDAY; - } - - /** - * Checks if this day is a Monday. - * - * @return bool - */ - public function isMonday() - { - return $this->dayOfWeek === static::MONDAY; - } - - /** - * Checks if this day is a Tuesday. - * - * @return bool - */ - public function isTuesday() - { - return $this->dayOfWeek === static::TUESDAY; - } - - /** - * Checks if this day is a Wednesday. - * - * @return bool - */ - public function isWednesday() - { - return $this->dayOfWeek === static::WEDNESDAY; - } - - /** - * Checks if this day is a Thursday. - * - * @return bool - */ - public function isThursday() - { - return $this->dayOfWeek === static::THURSDAY; - } - - /** - * Checks if this day is a Friday. - * - * @return bool - */ - public function isFriday() - { - return $this->dayOfWeek === static::FRIDAY; - } -} diff --git a/src/Traits/Creator.php b/src/Traits/Creator.php deleted file mode 100644 index 07502e2..0000000 --- a/src/Traits/Creator.php +++ /dev/null @@ -1,421 +0,0 @@ -getTimestamp()}"; - } elseif (is_int($datetime)) { - $dt = "@$datetime"; - } - - try { - if ($datetime instanceof DateTime) { - parent::__construct($dt); - parent::setTimezone($datetime->getTimezone()); - } else { - parent::__construct($dt, static::createTimeZone($timezone)); - } - self::loadMessages(); - } catch (Exception $exception) { - throw new InvalidArgumentException(sprintf("Unknown datetime '%s'", $datetime)); - } - } - - /** - * Create a Verta now datetime - * - * - * @param null $timezone - * @return static - */ - public static function now($timezone = null) - { - return new static(null, $timezone); - } - - /** - * Create a Verta instance for today. - * - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function today($timezone = null) - { - return (new static(null, $timezone))->startDay(); - } - - /** - * Create a Verta instance for tomorrow. - * - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function tomorrow($timezone = null) - { - return (new static(null, $timezone))->addDay()->startDay(); - } - - /** - * Create a Verta instance for yesterday. - * - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function yesterday($timezone = null) - { - return (new static(null, $timezone))->subDay()->startDay(); - } - - /** - * Create a Verta instance from a DateTime one - * - * @param $datetime [optional] - * @param \DateTimeZone|string|null $timezone [optional] - * - * @return static - */ - public static function instance($datetime = null, $timezone = null) - { - return new static($datetime, $timezone); - } - - /** - * Get a copy of the instance. - * - * @return static - */ - public function copy() - { - return clone $this; - } - - /** - * Get a copy of the instance. - * - * @return static - */ - public function clone() - { - return clone $this; - } - - /** - * Create a DateTime instance from Verta - * - * @return datetime $datetime - */ - public function datetime() - { - $dt = new DateTime(date('Y-m-d H:i:s', $this->getTimestamp())); - $dt->setTimezone($this->getTimezone()); - - return $dt; - } - - /** - * Create a Carbon instance from Verta - * - * @return Carbon - */ - public function toCarbon() - { - return Carbon::instance($this->datetime()); - } - - /** - * Create a Verta instance from a DateTime one - * - * @param $datetime [optional] - * @param bool $timezone [optional] - * - * @return static - */ - public static function parse($datetime, $timezone = null) - { - self::loadMessages(); - $names = array_map(function ($value) { - return " $value "; - }, array_values(self::$messages['year_months'])); - $values = array_map(function ($value) { - return "-$value-"; - }, range(1, 12)); - - $formatted = str_replace($names, $values, $datetime); - $formatted = str_replace(array_values(self::$messages['year_months']), range(1, 12), $formatted); - $parse = date_parse($formatted); - if ($parse['error_count'] > 0 || ! self::isValidDate($parse['year'], $parse['month'], $parse['day']) || ! self::isValidTime($parse['hour'], $parse['minute'], $parse['second'])) { - throw new InvalidArgumentException(sprintf("Unknown datetime '%s'", $datetime)); - } - - list($year, $month, $day) = self::getGregorian($parse['year'], $parse['month'], $parse['day']); - list($hour, $minute, $second) = [$parse['hour'], $parse['minute'], $parse['second']]; - - $datetime = sprintf('%04s-%02s-%02s %02s:%02s:%02s', $year, $month, $day, $hour, $minute, $second); - - return new static($datetime, $timezone); - } - - /** - * Create a Verta instance from a DateTime one - * - * @param string $format - * @param string $datetime [optional] - * @param bool $timezone [optional] - * @return static - */ - public static function parseFormat($format, $datetime, $timezone = null) - { - self::loadMessages(); - $formatted = str_replace(array_values(self::$messages['year_months']), range(1, 12), $datetime); - - $parse = date_parse_from_format($format, $formatted); - if ($parse['error_count'] > 0 || ! self::isValidDate($parse['year'], $parse['month'], $parse['day']) || ! self::isValidTime($parse['hour'], $parse['minute'], $parse['second'])) { - throw new InvalidArgumentException(sprintf("Unknown datetime '%s'", $datetime)); - } - list($year, $month, $day) = self::getGregorian($parse['year'], $parse['month'], $parse['day']); - list($hour, $minute, $second) = [$parse['hour'], $parse['minute'], $parse['second']]; - - $datetime = sprintf('%04s-%02s-%02s %02s:%02s:%02s', $year, $month, $day, $hour, $minute, $second); - - return new static($datetime, $timezone); - } - - /** - * Create a new Verta instance from a specific date and time gregorain. - * - * If any of feild are set to null their now() values will - * be used. - * - * @param int|null $year - * @param int|null $month - * @param int|null $day - * @param int|null $hour - * @param int|null $minute - * @param int|null $second - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function create($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null) - { - return static::createGregorian($year, $month, $day, $hour, $minute, $second, $timezone); - } - - /** - * Create a Verta from just a date gregorian. - * - * @param int|null $year - * @param int|null $month - * @param int|null $day - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function createDate($year = null, $month = null, $day = null, $timezone = null) - { - return static::create($year, $month, $day, null, null, null, $timezone); - } - - /** - * Create a Verta instance from just a time gregorian. - * - * @param int|null $hour - * @param int|null $minute - * @param int|null $second - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function createTime($hour = null, $minute = null, $second = null, $timezone = null) - { - return static::create(null, null, null, $hour, $minute, $second, $timezone); - } - - /** - * Create a Verta instance from a timestamp. - * - * @param int $timestamp - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function createTimestamp($timestamp, $timezone = null) - { - return static::instance($timestamp, $timezone); - } - - /** - * @param null $timezone - * @return DateTimeZone|string|null - */ - protected static function createTimeZone($timezone = null) - { - if ($timezone === null) { - return new DateTimeZone(date_default_timezone_get()); - } elseif ($timezone instanceof DateTimeZone) { - return $timezone; - } else { - $tz = @timezone_open(strval($timezone)); - if ($tz === false) { - throw new InvalidArgumentException(sprintf("Unknown timezone '%s'", $tz)); - } - - return $tz; - } - } - - /** - * Create a new Verta instance from a specific date and time gregorain. - * - * If any of feild are set to null their now() values will - * be used. - * - * @param int|null $year - * @param int|null $month - * @param int|null $day - * @param int|null $hour - * @param int|null $minute - * @param int|null $second - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function createGregorian($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null) - { - $now = (new DateTime())->format('Y-n-j-G-i-s'); - $defaults = array_combine(['year', 'month', 'day', 'hour', 'minute', 'second'], explode('-', $now)); - - $year = $year ?? intval($defaults['year']); - $month = $month ?? intval($defaults['month']); - $day = $day ?? intval($defaults['day']); - $hour = $hour ?? intval($defaults['hour']); - $minute = $minute ?? intval($defaults['minute']); - $second = $second ?? intval($defaults['second']); - - if (! checkdate($month, $day, $year) || ! static::isValidTime($hour, $minute, $second)) { - throw new \InvalidArgumentException('Unknown datetime'); - } - - return new static(sprintf('%s-%s-%s %s:%s:%s', $year, $month, $day, $hour, $minute, $second), $timezone); - } - - /** - * Create a Verta from just a date gregorian. - * - * @param int|null $year - * @param int|null $month - * @param int|null $day - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function createGregorianDate($year = null, $month = null, $day = null, $timezone = null) - { - return static::createGregorian($year, $month, $day, null, null, null, $timezone); - } - - /** - * Create a Verta instance from just a time gregorian. - * - * @param int|null $hour - * @param int|null $minute - * @param int|null $second - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function createGregorianTime($hour = null, $minute = null, $second = null, $timezone = null) - { - return static::createGregorian(null, null, null, $hour, $minute, $second, $timezone); - } - - /** - * Create a new Verta instance from a specific date and time. - * - * If any of feild are set to null their now() values will - * be used. - * - * @param int|null $year - * @param int|null $month - * @param int|null $day - * @param int|null $hour - * @param int|null $minute - * @param int|null $second - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function createJalali($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null) - { - $now = (new static())->format('Y-n-j-G-i-s'); - $defaults = array_combine(['year', 'month', 'day', 'hour', 'minute', 'second'], explode('-', $now)); - - $year = $year ?? intval($defaults['year']); - $month = $month ?? intval($defaults['month']); - $day = $day ?? intval($defaults['day']); - $hour = $hour ?? intval($defaults['hour']); - $minute = $minute ?? intval($defaults['minute']); - $second = $second ?? intval($defaults['second']); - - if (! static::isValidDate($year, $month, $day) || ! static::isValidTime($hour, $minute, $second)) { - throw new \InvalidArgumentException('Unknown datetime'); - } - - return static::parse(sprintf('%s-%s-%s %s:%s:%s', $year, $month, $day, $hour, $minute, $second)); - } - - /** - * Create a Verta from just a date. - * - * @param int|null $year - * @param int|null $month - * @param int|null $day - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function createJalaliDate($year = null, $month = null, $day = null, $timezone = null) - { - return static::createJalali($year, $month, $day, null, null, null, $timezone); - } - - /** - * Create a Verta instance from just a time. - * - * @param int|null $hour - * @param int|null $minute - * @param int|null $second - * @param \DateTimeZone|string|null $timezone - * - * @return static - */ - public static function createJalaliTime($hour = null, $minute = null, $second = null, $timezone = null) - { - return static::createJalali(null, null, null, $hour, $minute, $second, $timezone); - } -} diff --git a/src/Traits/Date.php b/src/Traits/Date.php deleted file mode 100644 index dc58d09..0000000 --- a/src/Traits/Date.php +++ /dev/null @@ -1,59 +0,0 @@ -getTimezone()); - - return (int) $this->diff($v->datetime())->format('%r%y'); - } - - /** - * Get the difference in months - * - * @param Verta|null $v - * - * @return int - */ - public function diffMonths(Verta $v = null) - { - $v = $v ?: static::now($this->getTimezone()); - - return $this->diffYears($v) * static::MONTHS_PER_YEAR + (int) $this->diff($v->datetime())->format('%r%m'); - } - - /** - * Get the difference in weeks - * - * @param Verta|null $v - * - * @return int - */ - public function diffWeeks(Verta $v = null) - { - return (int) ($this->diffDays($v) / static::DAYS_PER_WEEK); - } - - /** - * Get the difference in days - * - * @param Verta|null $v - * - * @return int - */ - public function diffDays(Verta $v = null) - { - $v = $v ?: static::now($this->getTimezone()); - - return (int) $this->diff($v->datetime())->format('%r%a'); - } - - /** - * Get the difference in hours - * - * @param Verta|null $v - * - * @return int - */ - public function diffHours(Verta $v = null) - { - return (int) ($this->diffSeconds($v) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR); - } - - /** - * Get the difference in minutes - * - * @param Verta|null $v - * - * @return int - */ - public function diffMinutes(Verta $v = null) - { - return (int) ($this->diffSeconds($v) / static::SECONDS_PER_MINUTE); - } - - /** - * Get the difference in seconds - * - * @param Verta|null $v - * - * @return int - */ - public function diffSeconds(Verta $v = null) - { - $v = $v ?: static::now($this->getTimezone()); - - return $v->getTimestamp() - $this->getTimestamp(); - } -} diff --git a/src/Traits/Formatting.php b/src/Traits/Formatting.php deleted file mode 100644 index 40718a7..0000000 --- a/src/Traits/Formatting.php +++ /dev/null @@ -1,478 +0,0 @@ -format(static::$stringFormat); - } - - /** - * The format of the outputted date string (jalali equivalent of php date() function) - * - * @param string $format for example 'Y-m-d H:i:s' - * @return string - */ - protected function date(string $format): string - { - $timestamp = $this->getTimestamp(); - - list($gYear, $gMonth, $gDay, $gWeek) = explode('-', parent::format('Y-m-d-w')); - list($pYear, $pMonth, $pDay) = static::getJalali($gYear, $gMonth, $gDay); - - $pWeek = $gWeek + 1; - - if ($pWeek >= 7) { - $pWeek = 0; - } - - $lengh = strlen($format); - $index = 0; - $result = ''; - - while ($index < $lengh) { - $char = $format[$index]; - if ($char == '\\') { - $result .= $format[++$index]; - $index++; - - continue; - } - $result .= $this->characterFormat($char, $timestamp, $pYear, $pMonth, $pDay, $pWeek); - - $index++; - } - - return $result; - } - - /** - * The format of the outputted date charactre (jalali equivalent of php date() function) - * - * @param string $char - * @param int $timestamp - * @param int $pYear - * @param int $pMonth - * @param int $pDay - * @param int $pWeek - * @return string - */ - private function characterFormat($char, $timestamp, $pYear, $pMonth, $pDay, $pWeek) - { - switch ($char) { - # Day - case 'd': - return sprintf('%02s', $pDay); - - case 'D': - return substr(self::$messages['weekdays'][$pWeek + 1], 0, 2); - - case 'j': - return $pDay; - - case 'l': - return self::$messages['weekdays'][$pWeek + 1]; - - case 'N': - return $pWeek + 1; - - case 'w': - return $pWeek; - - case 'z': - return $this->daysYear($pMonth, $pDay); - - case 'S': - return static::$messages['phrase']['th']; - - # Week - case 'W': - return $this->dayOfWeek(); - - # Month - case 'F': - return self::$messages['year_months'][$pMonth]; - - case 'm': - return sprintf('%02s', $pMonth); - - case 'M': - return substr(self::$messages['year_months'][$pMonth], 0, 6); - - case 'n': - return $pMonth; - - case 't': - return static::isLeapYear($pYear) && ($pMonth == 12) ? 30 : static::$daysMonthJalali[ intval($pMonth) - 1 ]; - # Quarter - case 'Q': - case 'q': - return self::$messages['quarters'][$this->quarter]; - # Years - case 'L': - return intval($this->isLeapYear($pYear)); - - case 'Y': - case 'o': - return $pYear; - - case 'y': - return substr($pYear, 2); - - # Time - case 'a': - return static::$messages['phrase'][parent::format('a')]; - - case 'A': - return static::$messages['pharse'][parent::format('a') == 'am' ? 'ante_meridiem' : 'post_meridiem']; - - case 'B': - case 'g': - case 'G': - case 'h': - case 'H': - case 's': - case 'u': - case 'i': - # Timezone - case 'e': - case 'I': - case 'O': - case 'P': - case 'T': - case 'Z': - return parent::format($char); - - # Full Date/Time - case 'c': - return ($pYear . '-' . $pMonth . '-' . $pDay . ' ' . parent::format('H:i:s P')); - - case 'r': - return (substr(self::$messages['weekdays'][$pWeek], 0, 2) . '، ' . $pDay . ' ' . substr(self::$messages['year_months'][$pMonth], 0, 6) . ' ' . $pYear . ' ' . parent::format('H:i:s P')); - - case 'U': - return $timestamp; - - default: - return $char; - } - } - - /** - * The format of the outputted date string (jalali equivalent of php date() function) - * - * @param string $format for example 'Y-m-d H:i:s' - * @return string - */ - protected function dateWord($format) - { - $timestamp = $this->getTimestamp(); - - list($gYear, $gMonth, $gDay, $gWeek) = explode('-', parent::format('Y-m-d-w')); - list($pYear, $pMonth, $pDay) = static::getJalali($gYear, $gMonth, $gDay); - - $pWeek = $gWeek + 1; - - if ($pWeek >= 7) { - $pWeek = 0; - } - - $lengh = strlen($format); - $index = 0; - $result = ''; - - while ($index < $lengh) { - $char = $format[$index]; - if ($char == '\\') { - $result .= $format[++$index]; - $index++; - - continue; - } - $output = $this->characterFormat($char, $timestamp, $pYear, $pMonth, $pDay, $pWeek); - if (is_numeric($output)) { - $output = (string) new Notowo($output, static::getLocale() == 'en' ? 'en' : 'fa'); - } - $result .= $output; - - $index++; - } - - return $result; - } - - /** - * return day number from first day of year - * - * @param int $month - * @param int $day - * @return type - * @since 5.0.0 - */ - protected function daysYear($month, $day) - { - $days = 0; - for ($i = 1; $i < $month; $i++) { - $days += static::$daysMonthJalali[$i - 1]; - } - - return ($days + $day); - } - - /** - * return week number from first of year - * - * @param int $month - * @param int $day - * @return type - * @since 5.0.0 - */ - protected function dayOfWeek() - { - $offset = $this->clone()->startYear()->format('w'); - $days = $this->format('z'); - - return ceil(($days + $offset) / 7); - } - - /** - * The format of the outputted date string (jalali equivalent of php strftime() function) - * - * @param $format - * @return string - */ - protected function strftime($format) - { - $strftime_date = [ - "%a" => "D", - "%A" => "l", - "%d" => "d", - "%e" => "j", - "%j" => "z", - "%u" => "N", - "%w" => "w", - "%U" => "W", - "%V" => "W", - "%W" => "W", - "%b" => "M", - "%B" => "F", - "%h" => "M", - "%m" => "m", - "%C" => "y", - "%g" => "y", - "%G" => "y", - "%y" => "y", - "%Y" => "Y", - "%H" => "H", - "%I" => "h", - "%l" => "g", - "%M" => "i", - "%p" => "A", - "%P" => "a", - "%r" => "h:i:s A", - "%R" => "H:i", - "%S" => "s", - "%T" => "H:i:s", - "%X" => "h:i:s", - "%z" => "H", - "%Z" => "H", - "%c" => "D j M H:i:s", - "%D" => "d/m/y", - "%F" => "Y-m-d", - "%s" => "U", - "%x" => "d/m/y", - "%n" => "\n", - "%t" => "\t", - "%%" => "%", - "%Q" => "q", - "%q" => "q", - ]; - - return str_replace(array_keys($strftime_date), array_values($strftime_date), $format); - } - - /** - * The format of the outputted date string (jalali equivalent of php strftime() function) - * - * @param string $format - * @return string - */ - #[ReturnTypeWillChange] - public function format($format) - { - return $this->date($this->strftime($format)); - } - - /** - * The format of the outputted date string (gregorian) - * - * @param string $format - * @return string - */ - public function formatGregorian(string $format): string - { - return $this->datetime()->format($format); - } - - /** - * Format the instance as date - * - * @return string - */ - public function formatDatetime(): string - { - return $this->format('Y-m-d H:i:s'); - } - - /** - * Format the instance as date - * - * @return string - */ - public function formatDate() - { - return $this->format('Y-m-d'); - } - - /** - * Format the instance as time - * - * @return string - */ - public function formatTime() - { - return $this->format('H:i:s'); - } - - /** - * Format the instance as date - * - * @return string - */ - public function formatJalaliDatetime() - { - return $this->format('Y/n/j H:i:s'); - } - - /** - * Format the instance as date - * - * @return string - */ - public function formatJalaliDate() - { - return $this->format('Y/n/j'); - } - - /** - * get difference in all - * - * @param Verta|null $v - * - * @return string - */ - public function formatDifference(Verta $v = null) - { - $units = [ - static::SECONDS_PER_MINUTE, - static::MINUTES_PER_HOUR, - static::HOURS_PER_DAY, - static::DAYS_PER_WEEK, - static::WEEKS_PER_MONTH, - static::MONTHS_PER_YEAR, - static::YEARS_PER_DECADE, - static::DECADE_PER_CENTURY, - ]; - $difference = $this->diffSeconds($v); - $absolute = static::$messages['phrase'][$difference < 0 ? 'later' : 'ago']; - - $difference = abs($difference); - - for ($unit = 0; $difference >= $units[$unit] and $unit < count($units) - 1; $unit++) { - $difference /= $units[$unit]; - } - $difference = intval(round($difference)); - - if ($difference === 0) { - return static::$messages['phrase']['now']; - } - - return sprintf('%s %s %s', $difference, array_values(static::$messages['date_units'])[$unit], $absolute); - } - - public function formatWord($format) - { - return $this->dateWord($this->strftime($format)); - } - - /** - * Convert english numbers to persian numbers - * - * @param string $string - * @return string - */ - public static function enToFaNumbers($string) - { - $en = static::getMessages('en'); - $fa = static::getMessages('fa'); - - return str_replace(array_values($en['numbers']), array_values($fa['numbers']), $string); - } - - /** - * Convert english numbers to persian numbers - * - * @param string $string - * @return string - */ - public static function faToEnNumbers($string) - { - $fa = static::getMessages('fa'); - $en = static::getMessages('en'); - - return str_replace(array_values($fa['numbers']), array_values($en['numbers']), $string); - } - - /** - * Convert english numbers to persian numbers - * - * @param string $string - * @return string - */ - public static function arToEnNumbers($string) - { - $ar = static::getMessages('ar'); - $en = static::getMessages('en'); - - return str_replace(array_values($ar['numbers']), array_values($en['numbers']), $string); - } -} diff --git a/src/Traits/Modification.php b/src/Traits/Modification.php deleted file mode 100644 index 7ad60db..0000000 --- a/src/Traits/Modification.php +++ /dev/null @@ -1,370 +0,0 @@ -year($this->year + $value); - } - - /** - * Add a year to the instance - * - * @param int $value - * - * @return static - */ - public function addYear($value = 1) - { - return $this->addYears($value); - } - - /** - * Remove years from the instance. - * - * @param int $value - * - * @return static - */ - public function subYears($value) - { - return $this->addYears(-1 * $value); - } - - /** - * Remove a year from the instance - * - * @param int $value - * - * @return static - */ - public function subYear($value = 1) - { - return $this->subYears($value); - } - - /** - * Add months to the instance. Positive $value travels forward while - * negative $value travels into the past. - * - * @param int $value - * - * @return static - */ - public function addMonths($value) - { - list($year, $month, $day, $hour, $minute, $second) = explode('-', $this->format('Y-m-d-H-i-s')); - $month += $value; - if ($month > 12) { - $year += intval($month / 12); - $month = $month % 12; - } elseif ($month < 1) { - $year += intval($month / 12) - 1; - $month = 12 + ($month % 12); - } - if ($month == 0) { - $year--; - $month = 12; - } - if (($month > 6 && $month < 12 && $day == 31)) { - $day--; - } else { - if ($month == 12 && ($day == 30 || $day == 31)) { - $day = self::isLeapYear($year) ? 30 : 29; - } - } - - return self::createJalali($year, $month, $day, $hour, $minute, $second, $this->getTimeZone()); - } - - /** - * Add a month to the instance - * - * @param int $value - * - * @return static - */ - public function addMonth($value = 1) - { - return $this->addMonths($value); - } - - /** - * Remove a month from the instance - * - * @param int $value - * - * @return static - */ - public function subMonth($value = 1) - { - return $this->subMonths($value); - } - - /** - * Remove months from the instance - * - * @param int $value - * - * @return static - */ - public function subMonths($value) - { - return $this->addMonths(-1 * $value); - } - - /** - * Add days to the instance. Positive $value travels forward while - * negative $value travels into the past. - * - * @param int $value - * - * @return static - */ - public function addDays($value) - { - return $this->modify((int) $value.' day'); - } - - /** - * Add a day to the instance - * - * @param int $value - * - * @return static - */ - public function addDay($value = 1) - { - return $this->addDays($value); - } - - /** - * Remove a day from the instance - * - * @param int $value - * - * @return static - */ - public function subDay($value = 1) - { - return $this->subDays($value); - } - - /** - * Remove days from the instance - * - * @param int $value - * - * @return static - */ - public function subDays($value) - { - return $this->addDays(-1 * $value); - } - - /** - * Add weeks to the instance. Positive $value travels forward while - * negative $value travels into the past. - * - * @param int $value - * - * @return static - */ - public function addWeeks($value) - { - return $this->modify((int) $value.' week'); - } - - /** - * Add a week to the instance - * - * @param int $value - * - * @return static - */ - public function addWeek($value = 1) - { - return $this->addWeeks($value); - } - - /** - * Remove a week from the instance - * - * @param int $value - * - * @return static - */ - public function subWeek($value = 1) - { - return $this->subWeeks($value); - } - - /** - * Remove weeks to the instance - * - * @param int $value - * - * @return static - */ - public function subWeeks($value) - { - return $this->addWeeks(-1 * $value); - } - - /** - * Add hours to the instance. Positive $value travels forward while - * negative $value travels into the past. - * - * @param int $value - * - * @return static - */ - public function addHours($value) - { - return $this->modify((int) $value.' hour'); - } - - /** - * Add an hour to the instance - * - * @param int $value - * - * @return static - */ - public function addHour($value = 1) - { - return $this->addHours($value); - } - - /** - * Remove an hour from the instance - * - * @param int $value - * - * @return static - */ - public function subHour($value = 1) - { - return $this->subHours($value); - } - - /** - * Remove hours from the instance - * - * @param int $value - * - * @return static - */ - public function subHours($value) - { - return $this->addHours(-1 * $value); - } - - /** - * Add minutes to the instance. Positive $value travels forward while - * negative $value travels into the past. - * - * @param int $value - * - * @return static - */ - public function addMinutes($value) - { - return $this->modify((int) $value.' minute'); - } - - /** - * Add a minute to the instance - * - * @param int $value - * - * @return static - */ - public function addMinute($value = 1) - { - return $this->addMinutes($value); - } - - /** - * Remove a minute from the instance - * - * @param int $value - * - * @return static - */ - public function subMinute($value = 1) - { - return $this->subMinutes($value); - } - - /** - * Remove minutes from the instance - * - * @param int $value - * - * @return static - */ - public function subMinutes($value) - { - return $this->addMinutes(-1 * $value); - } - - /** - * Add seconds to the instance. Positive $value travels forward while - * negative $value travels into the past. - * - * @param int $value - * - * @return static - */ - public function addSeconds($value) - { - return $this->modify((int) $value.' second'); - } - - /** - * Add a second to the instance - * - * @param int $value - * - * @return static - */ - public function addSecond($value = 1) - { - return $this->addSeconds($value); - } - - /** - * Remove a second from the instance - * - * @param int $value - * - * @return static - */ - public function subSecond($value = 1) - { - return $this->subSeconds($value); - } - - /** - * Remove seconds from the instance - * - * @param int $value - * - * @return static - */ - public function subSeconds($value) - { - return $this->addSeconds(-1 * $value); - } -} diff --git a/src/Traits/Transformation.php b/src/Traits/Transformation.php deleted file mode 100644 index ffd2707..0000000 --- a/src/Traits/Transformation.php +++ /dev/null @@ -1,89 +0,0 @@ - 1 && (($gy % 4 == 0 && $gy % 100 != 0) || ($gy % 400 == 0))) { - # leap and after Feb - $g_day_no++; - } - $g_day_no += $g_d - 1; - $j_day_no = $g_day_no - 79; - $j_np = intval($j_day_no / 12053); # 12053 = (365 * 33 + 32 / 4) - $j_day_no = $j_day_no % 12053; - $jy = (979 + 33 * $j_np + 4 * intval($j_day_no / 1461)); # 1461 = (365 * 4 + 4 / 4) - $j_day_no %= 1461; - if ($j_day_no >= 366) { - $jy += intval(($j_day_no - 1) / 365); - $j_day_no = ($j_day_no - 1) % 365; - } - for ($i = 0; ($i < 11 && $j_day_no >= static::$daysMonthJalali[$i]); ++$i) { - $j_day_no -= static::$daysMonthJalali[$i]; - } - - return [$jy, $i + 1, $j_day_no + 1]; - } - - /** - * jalali to gregorian convertion - * - * @param int $j_y - * @param int $j_m - * @param int $j_d - * @return array - */ - public static function getGregorian($j_y, $j_m, $j_d) - { - $jy = $j_y - 979; - $jm = $j_m - 1; - $j_day_no = (365 * $jy + intval($jy / 33) * 8 + intval(($jy % 33 + 3) / 4)); - for ($i = 0; $i < $jm; ++$i) { - $j_day_no += static::$daysMonthJalali[$i]; - } - $j_day_no += $j_d - 1; - $g_day_no = $j_day_no + 79; - $gy = (1600 + 400 * intval($g_day_no / 146097)); # 146097 = (365 * 400 + 400 / 4 - 400 / 100 + 400 / 400) - $g_day_no = $g_day_no % 146097; - $leap = 1; - if ($g_day_no >= 36525) { # 36525 = (365 * 100 + 100 / 4) - $g_day_no--; - $gy += (100 * intval($g_day_no / 36524)); # 36524 = (365 * 100 + 100 / 4 - 100 / 100) - $g_day_no = $g_day_no % 36524; - if ($g_day_no >= 365) { - $g_day_no++; - } else { - $leap = 0; - } - } - $gy += (4 * intval($g_day_no / 1461)); # 1461 = (365 * 4 + 4 / 4) - $g_day_no %= 1461; - if ($g_day_no >= 366) { - $leap = 0; - $g_day_no--; - $gy += intval($g_day_no / 365); - $g_day_no = ($g_day_no % 365); - } - for ($i = 0; $g_day_no >= (static::$daysMonthGregorian[$i] + ($i == 1 && $leap)); $i++) { - $g_day_no -= (static::$daysMonthGregorian[$i] + ($i == 1 && $leap)); - } - - return [$gy, $i + 1, $g_day_no + 1]; - } -} diff --git a/src/Traits/Translator.php b/src/Traits/Translator.php deleted file mode 100644 index f01b68f..0000000 --- a/src/Traits/Translator.php +++ /dev/null @@ -1,102 +0,0 @@ -assertEquals(1397, $datetime->year); $this->assertEquals(10, $datetime->month); @@ -29,7 +29,7 @@ class AccessTest extends TestCase public function testSetProperty() { - $datetime = new Verta('2019-01-01 17:20:35', 'Asia/Tehran'); + $datetime = Jalali::parse('1399-01-01 17:20:35', 'Asia/Tehran'); $datetime->year = 1398; $this->assertEquals(1398, $datetime->year); @@ -52,13 +52,13 @@ class AccessTest extends TestCase $datetime->timestamp = 1546382684; $this->assertEquals(1546382684, $datetime->timestamp); - $datetime->tz = 'UTC'; + $datetime->timezone = 'UTC'; $this->assertEquals('UTC', $datetime->timezone); } public function testSetMethods() { - $datetime = Verta::parse('1399-05-12 12:36:32'); + $datetime = Jalali::parse('1399-05-12 12:36:32'); $datetime->year(1395); $this->assertEquals(1395, $datetime->year); @@ -87,7 +87,7 @@ class AccessTest extends TestCase public function testSetDateTime() { - $datetime = verta()->setDateTime(1397, 10, 11, 10, 20, 11); + $datetime = jalali()->setDateTime(1397, 10, 11, 10, 20, 11); $this->assertEquals(1397, $datetime->year); $this->assertEquals(10, $datetime->month); @@ -99,7 +99,7 @@ class AccessTest extends TestCase public function testSetDate() { - $datetime = verta()->setDateJalali(1397, 10, 11); + $datetime = jalali()->setDateJalali(1397, 10, 11); $this->assertEquals(1397, $datetime->year); $this->assertEquals(10, $datetime->month); @@ -108,7 +108,7 @@ class AccessTest extends TestCase public function testSetTime() { - $datetime = verta()->setTime(10, 20, 11); + $datetime = jalali()->setTime(10, 20, 11); $this->assertEquals(10, $datetime->hour); $this->assertEquals(20, $datetime->minute); @@ -117,7 +117,7 @@ class AccessTest extends TestCase public function testSetTimeString() { - $datetime = verta()->setTimeString('10:20:11'); + $datetime = jalali()->setTimeString('10:20:11'); $this->assertEquals(10, $datetime->hour); $this->assertEquals(20, $datetime->minute); diff --git a/tests/ComparisionTest.php b/tests/ComparisionTest.php deleted file mode 100644 index c5a406a..0000000 --- a/tests/ComparisionTest.php +++ /dev/null @@ -1,279 +0,0 @@ -assertTrue($result); - - $result = Verta::isValidDate(-1365, 12, 15); - $this->assertFalse($result); - - $result = Verta::isValidDate(1365, 13, 15); - $this->assertFalse($result); - - $result = Verta::isValidDate(1365, 12, 32); - $this->assertFalse($result); - } - - public function testValidTime() - { - $result = Verta::isValidTime(13, 12, 15); - $this->assertTrue($result); - - $result = Verta::isValidTime(25, 12, 15); - $this->assertFalse($result); - - $result = Verta::isValidTime(14, 65, 15); - $this->assertFalse($result); - - $result = Verta::isValidTime(14, 12, 66); - $this->assertFalse($result); - } - - public function testDiffYears() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->diffYears(Verta::parse('1398-10-10 21:30:50')); - $this->assertEquals(0, $result); - - $result = $datetime->diffYears(Verta::parse('1395-10-10 21:30:50')); - $this->assertEquals(-3, $result); - - $result = $datetime->diffYears(Verta::parse('1399-10-11 21:30:50')); - $this->assertEquals(1, $result); - } - - public function testDiffMonths() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - $result = $datetime->diffMonths($datetime); - - $this->assertEquals(0, $result); - - $result = $datetime->diffMonths(Verta::parse('1399-12-15 21:30:50')); - $this->assertEquals(14, $result); - - $result = $datetime->diffMonths(Verta::parse('1397-08-10 21:30:50')); - $this->assertEquals(-13, $result); - } - - public function testDiffDays() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->diffDays(Verta::parse('1398-10-10 21:30:50')); - $this->assertEquals(0, $result); - - $result = $datetime->diffDays(Verta::parse('1398-10-15 21:30:50')); - $this->assertEquals(5, $result); - - $result = $datetime->diffDays(Verta::parse('1398-10-01 21:30:50')); - $this->assertEquals(-9, $result); - } - - public function testDiffHours() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->diffHours(Verta::parse('1398-10-10 21:30:50')); - $this->assertEquals(0, $result); - - $result = $datetime->diffHours(Verta::parse('1398-10-10 23:30:50')); - $this->assertEquals(2, $result); - - $result = $datetime->diffHours(Verta::parse('1398-10-10 20:30:50')); - $this->assertEquals(-1, $result); - } - - public function testDiffMinutes() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->diffMinutes(Verta::parse('1398-10-10 21:30:50')); - $this->assertEquals(0, $result); - - $result = $datetime->diffMinutes(Verta::parse('1398-10-10 21:40:50')); - $this->assertEquals(10, $result); - - $result = $datetime->diffMinutes(Verta::parse('1398-10-10 20:30:50')); - $this->assertEquals(-60, $result); - } - - public function testDiffSeconds() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->diffSeconds(Verta::parse('1398-10-10 21:30:50')); - $this->assertEquals(0, $result); - - $result = $datetime->diffSeconds(Verta::parse('1398-10-10 21:30:53')); - $this->assertEquals(3, $result); - - - $result = $datetime->diffSeconds(Verta::parse('1398-10-10 21:30:45')); - $this->assertEquals(-5, $result); - } - - public function testEqualTo() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->eq(Verta::parse('1398-10-10 21:30:50')); - $this->assertTrue($result); - - $result = $datetime->eq(Verta::parse('1398-10-10 21:30:51')); - $this->assertFalse($result); - } - - public function testGreaterThan() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->gt(Verta::parse('1398-10-10 21:30:50')); - $this->assertFalse($result); - - $result = $datetime->gt(Verta::parse('1398-10-10 21:30:49')); - $this->assertTrue($result); - } - - public function testGreaterThanOrEqualTo() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->gte(Verta::parse('1398-10-10 21:30:50')); - $this->assertTrue($result); - - $result = $datetime->gte(Verta::parse('1398-10-10 21:30:49')); - $this->assertTrue($result); - - $result = $datetime->gte(Verta::parse('1398-10-10 21:30:51')); - $this->assertFalse($result); - } - - public function testLessThan() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->lt(Verta::parse('1398-10-10 21:30:50')); - $this->assertFalse($result); - - $result = $datetime->lt(Verta::parse('1398-10-10 21:30:51')); - $this->assertTrue($result); - } - - public function testLessThanOrEqualTo() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->lte(Verta::parse('1398-10-10 21:30:50')); - $this->assertTrue($result); - - $result = $datetime->lte(Verta::parse('1398-10-10 21:30:51')); - $this->assertTrue($result); - - - $result = $datetime->lte(Verta::parse('1398-10-10 21:30:49')); - $this->assertFalse($result); - } - - public function testBetween() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->between(Verta::parse('1398-10-10 21:30:50'), Verta::parse('1398-10-11 21:30:50')); - $this->assertTrue($result); - - $result = $datetime->between(Verta::parse('1398-10-10 21:30:50'), Verta::parse('1398-10-11 21:30:50'), false); - $this->assertFalse($result); - - $result = $datetime->between(Verta::parse('1398-10-13 21:30:50'), Verta::parse('1398-10-09 21:30:50')); - $this->assertTrue($result); - } - - public function testClosest() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->closest(Verta::parse('1398-10-10 21:30:01'), Verta::parse('1398-10-11 21:30:50')); - $this->assertEquals($result, Verta::parse('1398-10-10 21:30:01')); - - $result = $datetime->closest(Verta::parse('1398-11-10 21:30:50'), Verta::parse('1398-10-11 21:30:50')); - $this->assertEquals($result, Verta::parse('1398-10-11 21:30:50')); - } - - public function testFarthest() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->farthest(Verta::parse('1398-10-10 21:30:01'), Verta::parse('1398-10-11 21:30:50')); - $this->assertEquals($result, Verta::parse('1398-10-11 21:30:50')); - - $result = $datetime->farthest(Verta::parse('1398-11-10 21:30:50'), Verta::parse('1398-10-11 21:30:50')); - $this->assertEquals($result, Verta::parse('1398-11-10 21:30:50')); - } - - public function testMin() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->min(Verta::parse('1398-10-10 21:30:01')); - $this->assertEquals($result, Verta::parse('1398-10-10 21:30:01')); - - $result = $datetime->min(Verta::parse('1398-10-10 21:30:55')); - $this->assertEquals($result, Verta::parse('1398-10-10 21:30:50')); - } - - public function testMax() - { - $datetime = Verta::parse('1398-10-10 21:30:50'); - - $result = $datetime->max(Verta::parse('1398-10-10 21:30:01')); - $this->assertEquals($result, Verta::parse('1398-10-10 21:30:50')); - - $result = $datetime->max(Verta::parse('1398-10-10 21:30:55')); - $this->assertEquals($result, Verta::parse('1398-10-10 21:30:55')); - } - - public function testIs() - { - $datetime = Verta::parse('1397-10-10 21:30:50'); - $target = Verta::parse('1398-10-10 21:30:01'); - -// Verta::setTestNow('1397-10-10 21:30:50'); - - $this->assertTrue($datetime->isWeekday()); - $this->assertFalse($datetime->isWeekend()); - $this->assertFalse($datetime->isYesterday()); - $this->assertFalse($datetime->isToday()); - $this->assertFalse($datetime->isTomorrow()); - $this->assertFalse($datetime->isNextWeek()); - $this->assertFalse($datetime->isLastWeek()); - $this->assertFalse($datetime->isNextMonth()); - $this->assertFalse($datetime->isLastMonth()); - $this->assertFalse($datetime->isNextYear()); - $this->assertFalse($datetime->isLastYear()); - $this->assertFalse($datetime->isFuture()); - $this->assertTrue($datetime->isPast()); - $this->assertTrue($datetime->isSameAs('m-d', $target)); - $this->assertFalse($datetime->isSameAs('Y-m-d')); - $this->assertFalse($datetime->isCurrentYear()); - $this->assertFalse($datetime->isSameYear($target)); - $this->assertFalse($datetime->isSameDay($target)); - $this->assertTrue($datetime->isBirthday($target)); - $this->assertFalse($datetime->isSaturday()); - $this->assertFalse($datetime->isSunday()); - $this->assertTrue($datetime->isMonday()); - $this->assertFalse($datetime->isTuesday()); - $this->assertFalse($datetime->isWednesday()); - $this->assertFalse($datetime->isThursday()); - $this->assertFalse($datetime->isFriday()); - } -} diff --git a/tests/ComparisonTest.php b/tests/ComparisonTest.php new file mode 100644 index 0000000..320c34e --- /dev/null +++ b/tests/ComparisonTest.php @@ -0,0 +1,304 @@ +assertTrue($result); + + $result = Jalali::isValidDate(-1365, 12, 15); + $this->assertFalse($result); + + $result = Jalali::isValidDate(1365, 13, 15); + $this->assertFalse($result); + + $result = Jalali::isValidDate(1365, 12, 32); + $this->assertFalse($result); + } + + public function testValidTime() + { + $result = Jalali::isValidTime(13, 12, 15); + $this->assertTrue($result); + + $result = Jalali::isValidTime(25, 12, 15); + $this->assertFalse($result); + + $result = Jalali::isValidTime(14, 65, 15); + $this->assertFalse($result); + + $result = Jalali::isValidTime(14, 12, 66); + $this->assertFalse($result); + } + + public function testDiffYears() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->diffYears(Jalali::parse('1398-10-10 21:30:50')); + $this->assertEquals(0, $result); + + $result = $datetime->diffYears(Jalali::parse('1395-10-10 21:30:50')); + $this->assertEquals(-3, $result); + + $result = $datetime->diffYears(Jalali::parse('1399-10-11 21:30:50')); + $this->assertEquals(1, $result); + } + + public function testDiffMonths() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + $result = $datetime->diffMonths($datetime); + + $this->assertEquals(0, $result); + + $result = $datetime->diffMonths(Jalali::parse('1399-12-15 21:30:50')); + $this->assertEquals(14, $result); + + $result = $datetime->diffMonths(Jalali::parse('1397-08-10 21:30:50')); + $this->assertEquals(-13, $result); + } + + public function testDiffDays() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->diffDays(Jalali::parse('1398-10-10 21:30:50')); + $this->assertEquals(0, $result); + + $result = $datetime->diffDays(Jalali::parse('1398-10-15 21:30:50')); + $this->assertEquals(5, $result); + + $result = $datetime->diffDays(Jalali::parse('1398-10-01 21:30:50')); + $this->assertEquals(-9, $result); + } + + public function testDiffWeeks() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->diffWeeks(Jalali::parse('1398-10-10 21:30:50')); + $this->assertEquals(0, $result); + + $result = $datetime->diffWeeks(Jalali::parse('1398-11-15 21:30:50')); + $this->assertEquals(5, $result); + + $result = $datetime->diffWeeks(Jalali::parse('1398-10-01 21:30:50')); + $this->assertEquals(-1, $result); + } + + public function testDiffHours() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->diffHours(Jalali::parse('1398-10-10 21:30:50')); + $this->assertEquals(0, $result); + + $result = $datetime->diffHours(Jalali::parse('1398-10-10 23:30:50')); + $this->assertEquals(2, $result); + + $result = $datetime->diffHours(Jalali::parse('1398-10-10 20:30:50')); + $this->assertEquals(-1, $result); + } + + public function testDiffMinutes() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->diffMinutes(Jalali::parse('1398-10-10 21:30:50')); + $this->assertEquals(0, $result); + + $result = $datetime->diffMinutes(Jalali::parse('1398-10-10 21:40:50')); + $this->assertEquals(10, $result); + + $result = $datetime->diffMinutes(Jalali::parse('1398-10-10 20:30:50')); + $this->assertEquals(-60, $result); + } + + public function testDiffSeconds() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->diffSeconds(Jalali::parse('1398-10-10 21:30:50')); + $this->assertEquals(0, $result); + + $result = $datetime->diffSeconds(Jalali::parse('1398-10-10 21:30:53')); + $this->assertEquals(3, $result); + + + $result = $datetime->diffSeconds(Jalali::parse('1398-10-10 21:30:45')); + $this->assertEquals(-5, $result); + } + + public function testEqualTo() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->eq(Jalali::parse('1398-10-10 21:30:50')); + $this->assertTrue($result); + + $result = $datetime->eq(Jalali::parse('1398-10-10 21:30:51')); + $this->assertFalse($result); + } + + public function testNotEqualTo() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->ne(Jalali::parse('1398-10-10 21:30:50')); + $this->assertFalse($result); + + $result = $datetime->notEqualTo(Jalali::parse('1398-10-10 21:30:51')); + $this->assertTrue($result); + } + + public function testGreaterThan() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->gt(Jalali::parse('1398-10-10 21:30:50')); + $this->assertFalse($result); + + $result = $datetime->greaterThanOrEqualTo(Jalali::parse('1398-10-10 21:30:49')); + $this->assertTrue($result); + } + + public function testGreaterThanOrEqualTo() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->gte(Jalali::parse('1398-10-10 21:30:50')); + $this->assertTrue($result); + + $result = $datetime->gte(Jalali::parse('1398-10-10 21:30:49')); + $this->assertTrue($result); + + $result = $datetime->gte(Jalali::parse('1398-10-10 21:30:51')); + $this->assertFalse($result); + } + + public function testLessThan() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->lt(Jalali::parse('1398-10-10 21:30:50')); + $this->assertFalse($result); + + $result = $datetime->lt(Jalali::parse('1398-10-10 21:30:51')); + $this->assertTrue($result); + } + + public function testLessThanOrEqualTo() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->lte(Jalali::parse('1398-10-10 21:30:50')); + $this->assertTrue($result); + + $result = $datetime->lessThanOrEqualTo(Jalali::parse('1398-10-10 21:30:51')); + $this->assertTrue($result); + + + $result = $datetime->lte(Jalali::parse('1398-10-10 21:30:49')); + $this->assertFalse($result); + } + + public function testBetween() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->between(Jalali::parse('1398-10-10 21:30:50'), Jalali::parse('1398-10-11 21:30:50')); + $this->assertTrue($result); + + $result = $datetime->between(Jalali::parse('1398-10-10 21:30:50'), Jalali::parse('1398-10-11 21:30:50'), false); + $this->assertFalse($result); + + $result = $datetime->between(Jalali::parse('1398-10-13 21:30:50'), Jalali::parse('1398-10-09 21:30:50')); + $this->assertTrue($result); + } + + public function testClosest() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->closest(Jalali::parse('1398-10-10 21:30:01'), Jalali::parse('1398-10-11 21:30:50')); + $this->assertEquals($result, Jalali::parse('1398-10-10 21:30:01')); + + $result = $datetime->closest(Jalali::parse('1398-11-10 21:30:50'), Jalali::parse('1398-10-11 21:30:50')); + $this->assertEquals($result, Jalali::parse('1398-10-11 21:30:50')); + } + + public function testFarthest() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->farthest(Jalali::parse('1398-10-10 21:30:01'), Jalali::parse('1398-10-11 21:30:50')); + $this->assertEquals($result, Jalali::parse('1398-10-11 21:30:50')); + + $result = $datetime->farthest(Jalali::parse('1398-11-10 21:30:50'), Jalali::parse('1398-10-11 21:30:50')); + $this->assertEquals($result, Jalali::parse('1398-11-10 21:30:50')); + } + + public function testMin() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->min(Jalali::parse('1398-10-10 21:30:01')); + $this->assertEquals($result, Jalali::parse('1398-10-10 21:30:01')); + + $result = $datetime->min(Jalali::parse('1398-10-10 21:30:55')); + $this->assertEquals($result, Jalali::parse('1398-10-10 21:30:50')); + } + + public function testMax() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->max(Jalali::parse('1398-10-10 21:30:01')); + $this->assertEquals($result, Jalali::parse('1398-10-10 21:30:50')); + + $result = $datetime->max(Jalali::parse('1398-10-10 21:30:55')); + $this->assertEquals($result, Jalali::parse('1398-10-10 21:30:55')); + } + + public function testIs() + { + $datetime = Jalali::parse('1397-10-10 21:30:50'); + $target = Jalali::parse('1398-10-10 21:30:01'); + +// Jalali::setTestNow('1397-10-10 21:30:50'); + + $this->assertTrue($datetime->isWeekday()); + $this->assertFalse($datetime->isWeekend()); + $this->assertFalse($datetime->isYesterday()); + $this->assertFalse($datetime->isToday()); + $this->assertFalse($datetime->isTomorrow()); + $this->assertFalse($datetime->isNextWeek()); + $this->assertFalse($datetime->isLastWeek()); + $this->assertFalse($datetime->isNextMonth()); + $this->assertFalse($datetime->isLastMonth()); + $this->assertFalse($datetime->isNextYear()); + $this->assertFalse($datetime->isLastYear()); + $this->assertFalse($datetime->isFuture()); + $this->assertTrue($datetime->isPast()); + $this->assertTrue($datetime->isSameAs('m-d', $target)); + $this->assertFalse($datetime->isSameAs('Y-m-d')); + $this->assertFalse($datetime->isCurrentYear()); + $this->assertFalse($datetime->isSameYear($target)); + $this->assertFalse($datetime->isSameDay($target)); + $this->assertTrue($datetime->isBirthday($target)); + $this->assertFalse($datetime->isSaturday()); + $this->assertFalse($datetime->isSunday()); + $this->assertTrue($datetime->isMonday()); + $this->assertFalse($datetime->isTuesday()); + $this->assertFalse($datetime->isWednesday()); + $this->assertFalse($datetime->isThursday()); + $this->assertFalse($datetime->isFriday()); + } +} diff --git a/tests/CreatorTest.php b/tests/CreatorTest.php index 726c1d0..6f54d0d 100644 --- a/tests/CreatorTest.php +++ b/tests/CreatorTest.php @@ -1,11 +1,10 @@ getTimestamp(); - $actual = Verta::now()->getTimestamp(); + $actual = Jalali::now()->getTimestamp(); $this->assertEquals($expected, $actual); } @@ -21,7 +20,7 @@ class CreatorTest extends TestCase public function testHelper() { $expected = (new DateTime())->getTimestamp(); - $actual = verta()->getTimestamp(); + $actual = Jalali()->getTimestamp(); $this->assertEquals($expected, $actual); } @@ -29,7 +28,7 @@ class CreatorTest extends TestCase public function testYesterday() { $expected = (new DateTime("-1 days"))->format('Y-m-d 00:00:00'); - $actual = (string)Verta::yesterday()->formatGregorian('Y-m-d H:i:s'); + $actual = (string)Jalali::yesterday()->formatGregorian('Y-m-d H:i:s'); $this->assertEquals($expected, $actual); } @@ -37,7 +36,7 @@ class CreatorTest extends TestCase public function testToday() { $expected = (new DateTime())->format('Y-m-d 00:00:00'); - $actual = (string)Verta::today()->formatGregorian('Y-m-d H:i:s'); + $actual = (string)Jalali::today()->formatGregorian('Y-m-d H:i:s'); $this->assertEquals($expected, $actual); } @@ -45,25 +44,18 @@ class CreatorTest extends TestCase public function testTomorrow() { $expected = (new DateTime("+1 days"))->format('Y-m-d 00:00:00'); - $actual = (string)Verta::tomorrow()->formatGregorian('Y-m-d H:i:s'); + $actual = (string)Jalali::tomorrow()->formatGregorian('Y-m-d H:i:s'); $this->assertEquals($expected, $actual); } public function testInstance() { - $datetime = (string) new Verta('2019-01-01 10:20:11'); + $datetime = (string) new Jalali('2019-01-01 10:20:11'); $this->assertEquals('1397-10-11 10:20:11', $datetime); - $datetime = (string) Verta::instance('2019-01-01 10:20:11'); - $this->assertEquals('1397-10-11 10:20:11', $datetime); - - $app = ['verta' => new Verta()]; - VertaFacade::setFacadeApplication($app); - - $datetime = (string) VertaFacade::instance('2019-01-01 10:20:11'); - + $datetime = (string) Jalali::instance('2019-01-01 10:20:11'); $this->assertEquals('1397-10-11 10:20:11', $datetime); } @@ -71,43 +63,35 @@ class CreatorTest extends TestCase { $now = new DateTime('now', new DateTimeZone('Asia/Tehran')); - $datetime = new Verta($now); + $datetime = new Jalali($now, 'Asia/Tehran'); $this->assertEquals($now->getTimezone()->getName(), $datetime->getTimezone()->getName()); - $this->assertEquals($now->format('Y-m-d H:i:s'), $datetime->datetime()->format('Y-m-d H:i:s')); } public function testDatetime() { - $datetime = verta('2019-01-01 10:20:11')->datetime()->format('Y-m-d H:i:s'); - - $this->assertEquals('2019-01-01 10:20:11', $datetime); - } - - public function testToCarbon() - { - $datetime = verta('2019-01-01 10:20:11')->toCarbon()->format('Y-m-d H:i:s'); + $datetime = jalali('2019-01-01 10:20:11')->datetime()->format('Y-m-d H:i:s'); $this->assertEquals('2019-01-01 10:20:11', $datetime); } public function testParse() { - $datetime = Verta::parse('1397 دی 11 10:20:11')->formatGregorian('Y-m-d H:i:s'); + $datetime = Jalali::parse('1397 دی 11 10:20:11')->formatGregorian('Y-m-d H:i:s'); $this->assertEquals('2019-01-01 10:20:11', $datetime); } public function testParseFormat() { - $datetime = Verta::parseFormat('Y-m-d H:i:s', '1397-10-11 10:20:11')->formatGregorian('Y-m-d H:i:s'); + $datetime = Jalali::parseFormat('Y-m-d H:i:s', '1397-10-11 10:20:11')->formatGregorian('Y-m-d H:i:s'); $this->assertEquals('2019-01-01 10:20:11', $datetime); } public function testCreate() { - $datetime = Verta::create(2019, 1, 1, 10, 20, 11)->format('Y-m-d H:i:s'); + $datetime = Jalali::create(2019, 1, 1, 10, 20, 11)->format('Y-m-d H:i:s'); $this->assertEquals('1397-10-11 10:20:11', $datetime); } @@ -115,7 +99,7 @@ class CreatorTest extends TestCase public function testCreateDate() { $time = (new DateTime())->format("H:i:s"); - $datetime = Verta::createDate(2019, 1, 1)->format('Y-m-d H:i:s'); + $datetime = Jalali::createDate(2019, 1, 1)->format('Y-m-d H:i:s'); $this->assertEquals("1397-10-11 {$time}", $datetime); } @@ -123,21 +107,21 @@ class CreatorTest extends TestCase public function testCreateTime() { $date = (new DateTime())->format("Y-m-d"); - $datetime = Verta::createTime(15, 19, 51)->formatGregorian('Y-m-d H:i:s'); + $datetime = Jalali::createTime(15, 19, 51)->formatGregorian('Y-m-d H:i:s'); $this->assertEquals("{$date} 15:19:51", $datetime); } public function testCreateTimestamp() { - $datetime = Verta::createTimestamp(1583501791)->format('Y-m-d H:i:s'); + $datetime = Jalali::createTimestamp(1583501791)->format('Y-m-d H:i:s'); $this->assertEquals("1398-12-16 13:36:31", $datetime); } public function testCreateGregorian() { - $datetime = Verta::create(2019, 1, 1, 10, 20, 11)->format('Y-m-d H:i:s'); + $datetime = Jalali::create(2019, 1, 1, 10, 20, 11)->format('Y-m-d H:i:s'); $this->assertEquals('1397-10-11 10:20:11', $datetime); } @@ -145,7 +129,7 @@ class CreatorTest extends TestCase public function testCreateGregorianDate() { $time = (new DateTime())->format("H:i:s"); - $datetime = Verta::createGregorianDate(2019, 1, 1)->format('Y-m-d H:i:s'); + $datetime = Jalali::createGregorianDate(2019, 1, 1)->format('Y-m-d H:i:s'); $this->assertEquals("1397-10-11 {$time}", $datetime); } @@ -153,14 +137,14 @@ class CreatorTest extends TestCase public function testCreateGregorianTime() { $date = (new DateTime())->format("Y-m-d"); - $datetime = Verta::createGregorianTime(15, 19, 51)->formatGregorian('Y-m-d H:i:s'); + $datetime = Jalali::createGregorianTime(15, 19, 51)->formatGregorian('Y-m-d H:i:s'); $this->assertEquals("{$date} 15:19:51", $datetime); } public function testCreateJalali() { - $datetime = Verta::createJalali(1397, 10, 11, 10, 20, 11)->format('Y-m-d H:i:s'); + $datetime = Jalali::createJalali(1397, 10, 11, 10, 20, 11)->format('Y-m-d H:i:s'); $this->assertEquals('1397-10-11 10:20:11', $datetime); } @@ -168,15 +152,15 @@ class CreatorTest extends TestCase public function testCreateJalaliDate() { $time = (new DateTime())->format("H:i:s"); - $datetime = Verta::createJalaliDate(1397, 10, 11)->format('Y-m-d H:i:s'); + $datetime = Jalali::createJalaliDate(1397, 10, 11)->format('Y-m-d H:i:s'); $this->assertEquals("1397-10-11 {$time}", $datetime); } public function testCreateJalaliTime() { - $date = verta()->format("Y-m-d"); - $datetime = Verta::createJalaliTime(15, 19, 51)->format('Y-m-d H:i:s'); + $date = jalali()->format("Y-m-d"); + $datetime = Jalali::createJalaliTime(15, 19, 51)->format('Y-m-d H:i:s'); $this->assertEquals("{$date} 15:19:51", $datetime); } diff --git a/tests/FormatTest.php b/tests/FormatTest.php index b945f58..7e8e3ad 100644 --- a/tests/FormatTest.php +++ b/tests/FormatTest.php @@ -1,111 +1,111 @@ assertEquals('1398-10-10-22-30-50', $datetime); - Verta::resetStringFormat(); - $datetime = (string) Verta::parse('1398-10-10 22:30:50'); + Jalali::resetFormat(); + $datetime = (string) Jalali::parse('1398-10-10 22:30:50'); $this->assertEquals('1398-10-10 22:30:50', $datetime); } public function testFormat() { - $datetime = Verta::parse('1398-10-10 21:30:50')->format('y-n-j-g-i-s'); + $datetime = Jalali::parse('1398-10-10 21:30:50')->format('y-n-j-g-i-s'); $this->assertEquals('98-10-10-9-30-50', $datetime); } public function testFormatGregorian() { - $datetime = Verta::parse('1398-10-10 21:30:50')->formatGregorian('o n j g i s'); + $datetime = Jalali::parse('1398-10-10 21:30:50')->formatGregorian('o n j g i s'); $this->assertEquals('2020 12 31 9 30 50', $datetime); } public function testFormatDatetime() { - $datetime = Verta::parse('1398-10-10 21:30:50')->formatDatetime(); + $datetime = Jalali::parse('1398-10-10 21:30:50')->formatDatetime(); $this->assertEquals('1398-10-10 21:30:50', $datetime); } public function testFormatDate() { - $datetime = Verta::parse('1398-10-10 21:30:50')->formatDate(); + $datetime = Jalali::parse('1398-10-10 21:30:50')->formatDate(); $this->assertEquals('1398-10-10', $datetime); } public function testFormatTime() { - $datetime = Verta::parse('1398-10-10 21:30:50')->formatTime(); + $datetime = Jalali::parse('1398-10-10 21:30:50')->formatTime(); $this->assertEquals('21:30:50', $datetime); } public function testFormatJalaliDatetime() { - $datetime = Verta::parse('1398-10-10 21:30:50')->formatJalaliDatetime(); + $datetime = Jalali::parse('1398-10-10 21:30:50')->formatJalaliDatetime(); $this->assertEquals('1398/10/10 21:30:50', $datetime); } public function testFormatJalaliDate() { - $datetime = Verta::parse('1398-10-10 21:30:50')->formatJalaliDate(); + $datetime = Jalali::parse('1398-10-10 21:30:50')->formatJalaliDate(); $this->assertEquals('1398/10/10', $datetime); } public function testFormatDifference() { - Verta::setLocale('fa'); - $target = Verta::parse('1398-10-10 21:30:50'); + Jalali::setLocale('fa'); + $target = Jalali::parse('1398-10-10 21:30:50'); - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); $difference = $target->formatDifference($datetime); $this->assertEquals('الان', $difference); - $datetime = Verta::parse('1398-10-10 21:30:45'); + $datetime = Jalali::parse('1398-10-10 21:30:45'); $difference = $target->formatDifference($datetime); $this->assertEquals('5 ثانیه بعد', $difference); - $datetime = Verta::parse('1398-10-10 21:31:58'); + $datetime = Jalali::parse('1398-10-10 21:31:58'); $difference = $target->formatDifference($datetime); $this->assertEquals('1 دقیقه قبل', $difference); - $datetime = Verta::parse('1398-10-10 20:30:35'); + $datetime = Jalali::parse('1398-10-10 20:30:35'); $difference = $target->formatDifference($datetime); $this->assertEquals('1 ساعت بعد', $difference); - $datetime = Verta::parse('1398-10-11 21:32:35'); + $datetime = Jalali::parse('1398-10-11 21:32:35'); $difference = $target->formatDifference($datetime); $this->assertEquals('1 روز قبل', $difference); - $datetime = Verta::parse('1398-11-11 21:32:35'); + $datetime = Jalali::parse('1398-11-11 21:32:35'); $difference = $target->formatDifference($datetime); $this->assertEquals('1 ماه قبل', $difference); - $datetime = Verta::parse('1397-09-11 21:32:35'); + $datetime = Jalali::parse('1397-09-11 21:32:35'); $difference = $target->formatDifference($datetime); $this->assertEquals('1 سال بعد', $difference); @@ -113,15 +113,16 @@ class FormatTest extends TestCase public function testFormatWord() { - $datetime = Verta::parse('1398-10-11 21:32:35')->formatWord('l d S F'); + $datetime = Jalali::parse('1398-10-11 21:32:35')->formatWord('l d S F'); $this->assertEquals('چهارشنبه یازده ام دی', $datetime); } public function testFormatQuarter() { - $datetime = Verta::parse('1398-10-10 21:30:50')->formatWord('q'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); - $this->assertEquals('زمستان', $datetime); + $this->assertEquals('زمستان', $datetime->format('Q')); + $this->assertEquals(4, $datetime->format('q')); } } diff --git a/tests/ModificationTest.php b/tests/ModificationTest.php index 684873e..b88373b 100644 --- a/tests/ModificationTest.php +++ b/tests/ModificationTest.php @@ -1,15 +1,15 @@ addYears(2); @@ -18,7 +18,7 @@ class ModificationTest extends TestCase public function testSubYears() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); $datetime->subYears(3); @@ -27,7 +27,7 @@ class ModificationTest extends TestCase public function testAddMonths() { - $datetime = Verta::parse('1398-10-30 21:30:50'); + $datetime = Jalali::parse('1398-10-30 21:30:50'); $result = $datetime->addMonths(2)->format('Y-m-d H:i:s'); @@ -36,7 +36,7 @@ class ModificationTest extends TestCase public function testSubMonths() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); $result = $datetime->subMonths(3)->format('Y-m-d H:i:s'); @@ -45,7 +45,7 @@ class ModificationTest extends TestCase public function testAddWeeks() { - $datetime = Verta::parse('1398-10-30 21:30:50'); + $datetime = Jalali::parse('1398-10-30 21:30:50'); $result = $datetime->addWeeks(2)->format('Y-m-d H:i:s'); @@ -54,7 +54,7 @@ class ModificationTest extends TestCase public function testSubWeeks() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); $result = $datetime->subWeeks(3)->format('Y-m-d H:i:s'); @@ -63,7 +63,7 @@ class ModificationTest extends TestCase public function testAddDays() { - $datetime = Verta::parse('1398-10-30 21:30:50'); + $datetime = Jalali::parse('1398-10-30 21:30:50'); $result = $datetime->addDays(20)->format('Y-m-d H:i:s'); @@ -72,7 +72,7 @@ class ModificationTest extends TestCase public function testSubDays() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); $result = $datetime->subDays(7)->format('Y-m-d H:i:s'); @@ -81,25 +81,25 @@ class ModificationTest extends TestCase public function testAddHours() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); - $result = $datetime->addHour(6)->format('Y-m-d H:i:s'); + $result = $datetime->addHour()->format('Y-m-d H:i:s'); - $this->assertEquals('1398-10-11 03:30:50', $result); + $this->assertEquals('1398-10-10 22:30:50', $result); } public function testSubHours() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); - $result = $datetime->subHour(30)->format('Y-m-d H:i:s'); + $result = $datetime->subHour()->format('Y-m-d H:i:s'); - $this->assertEquals('1398-10-09 15:30:50', $result); + $this->assertEquals('1398-10-10 20:30:50', $result); } public function testAddMinutes() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); $result = $datetime->addMinutes(6)->format('Y-m-d H:i:s'); @@ -108,16 +108,16 @@ class ModificationTest extends TestCase public function testSubMinutes() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); - $result = $datetime->subMinute(30)->format('Y-m-d H:i:s'); + $result = $datetime->subMinute()->format('Y-m-d H:i:s'); - $this->assertEquals('1398-10-10 21:00:50', $result); + $this->assertEquals('1398-10-10 21:29:50', $result); } public function testAddSeconds() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); $result = $datetime->addSeconds(16)->format('Y-m-d H:i:s'); @@ -126,16 +126,25 @@ class ModificationTest extends TestCase public function testSubSeconds() { - $datetime = Verta::parse('1398-10-10 21:30:20'); + $datetime = Jalali::parse('1398-10-10 21:30:20'); $result = $datetime->subSeconds(30)->format('Y-m-d H:i:s'); $this->assertEquals('1398-10-10 21:29:50', $result); } + public function testStartMinute() + { + $datetime = Jalali::parse('1398-10-10 21:30:50'); + + $result = $datetime->startMinute()->format('Y-m-d H:i:s'); + + $this->assertEquals('1398-10-10 21:30:00', $result); + } + public function testStartDay() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); $result = $datetime->startDay()->format('Y-m-d H:i:s'); @@ -144,7 +153,7 @@ class ModificationTest extends TestCase public function testEndDay() { - $datetime = Verta::parse('1398-10-10 21:30:20'); + $datetime = Jalali::parse('1398-10-10 21:30:20'); $result = $datetime->endDay()->format('Y-m-d H:i:s'); @@ -153,7 +162,7 @@ class ModificationTest extends TestCase public function testStartWeek() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); $result = $datetime->startWeek()->format('Y-m-d H:i:s'); @@ -162,7 +171,7 @@ class ModificationTest extends TestCase public function testEndWeek() { - $datetime = Verta::parse('1398-10-10 21:30:20'); + $datetime = Jalali::parse('1398-10-10 21:30:20'); $result = $datetime->endWeek()->format('Y-m-d H:i:s'); @@ -171,7 +180,7 @@ class ModificationTest extends TestCase public function testStartMonth() { - $datetime = Verta::parse('1398-10-10 21:30:50'); + $datetime = Jalali::parse('1398-10-10 21:30:50'); $result = $datetime->startMonth()->format('Y-m-d H:i:s'); @@ -180,7 +189,7 @@ class ModificationTest extends TestCase public function testEndMonth() { - $datetime = Verta::parse('1398-10-10 21:30:20'); + $datetime = Jalali::parse('1398-10-10 21:30:20'); $result = $datetime->endMonth()->format('Y-m-d H:i:s'); @@ -189,7 +198,7 @@ class ModificationTest extends TestCase public function testStartQuarter() { - $datetime = Verta::parse('1398-11-10 21:30:50'); + $datetime = Jalali::parse('1398-11-10 21:30:50'); $result = $datetime->startQuarter()->format('Y-m-d H:i:s'); @@ -198,7 +207,7 @@ class ModificationTest extends TestCase public function testEndQuarter() { - $datetime = Verta::parse('1398-10-10 21:30:20'); + $datetime = Jalali::parse('1398-10-10 21:30:20'); $result = $datetime->endQuarter()->format('Y-m-d H:i:s'); @@ -207,7 +216,7 @@ class ModificationTest extends TestCase public function testStartYear() { - $datetime = Verta::parse('1398-11-10 21:30:50'); + $datetime = Jalali::parse('1398-11-10 21:30:50'); $result = $datetime->startYear()->format('Y-m-d H:i:s'); @@ -216,7 +225,7 @@ class ModificationTest extends TestCase public function testEndYear() { - $datetime = Verta::parse('1398-10-15 21:30:20'); + $datetime = Jalali::parse('1398-10-15 21:30:20'); $result = $datetime->endYear()->format('Y-m-d H:i:s');