chore: restore vendor directory dependencies

This commit is contained in:
2026-07-15 13:22:22 +07:00
parent 3203c6e129
commit 15b4ec091c
4844 changed files with 612121 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Samsung Electronics Co., Ltd. akhilesh.k@samsung.com
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'DD/MM/YYYY',
],
'months' => ['Janueri', 'Februeri', 'Mas', 'Epril', 'Me', 'Jun', 'Julai', 'Ogas', 'Septemba', 'Oktoba', 'Novemba', 'Desemba'],
'months_short' => ['Jan', 'Feb', 'Mas', 'Epr', 'Me', 'Jun', 'Jul', 'Oga', 'Sep', 'Okt', 'Nov', 'Des'],
'weekdays' => ['Sande', 'Mande', 'Tunde', 'Trinde', 'Fonde', 'Fraide', 'Sarere'],
'weekdays_short' => ['San', 'Man', 'Tun', 'Tri', 'Fon', 'Fra', 'Sar'],
'weekdays_min' => ['San', 'Man', 'Tun', 'Tri', 'Fon', 'Fra', 'Sar'],
'first_day_of_week' => 0,
'day_of_first_week_of_year' => 1,
'meridiem' => ['biknait', 'apinun'],
'year' => 'yia :count',
'y' => 'yia :count',
'a_year' => 'yia :count',
'month' => ':count mun',
'm' => ':count mun',
'a_month' => ':count mun',
'week' => ':count wik',
'w' => ':count wik',
'a_week' => ':count wik',
'day' => ':count de',
'd' => ':count de',
'a_day' => ':count de',
'hour' => ':count aua',
'h' => ':count aua',
'a_hour' => ':count aua',
'minute' => ':count minit',
'min' => ':count minit',
'a_minute' => ':count minit',
'second' => ':count namba tu',
's' => ':count namba tu',
'a_second' => ':count namba tu',
]);
+121
View File
@@ -0,0 +1,121 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Josh Soref
* - Alan Agius
* - Erhan Gundogan
* - François B
* - JD Isaacks
* - Murat Yüksel
* - Baran Şengül
* - Selami (selamialtin)
* - TeomanBey
*/
return [
'year' => ':count yıl',
'a_year' => '{1}bir yıl|]1,Inf[:count yıl',
'y' => ':county',
'month' => ':count ay',
'a_month' => '{1}bir ay|]1,Inf[:count ay',
'm' => ':countay',
'week' => ':count hafta',
'a_week' => '{1}bir hafta|]1,Inf[:count hafta',
'w' => ':counth',
'day' => ':count gün',
'a_day' => '{1}bir gün|]1,Inf[:count gün',
'd' => ':countg',
'hour' => ':count saat',
'a_hour' => '{1}bir saat|]1,Inf[:count saat',
'h' => ':countsa',
'minute' => ':count dakika',
'a_minute' => '{1}bir dakika|]1,Inf[:count dakika',
'min' => ':countdk',
'second' => ':count saniye',
'a_second' => '{1}birkaç saniye|]1,Inf[:count saniye',
's' => ':countsn',
'ago' => ':time önce',
'from_now' => ':time sonra',
'after' => ':time sonra',
'before' => ':time önce',
'diff_now' => 'şimdi',
'diff_today' => 'bugün',
'diff_today_regexp' => 'bugün(?:\\s+saat)?',
'diff_yesterday' => 'dün',
'diff_tomorrow' => 'yarın',
'diff_tomorrow_regexp' => 'yarın(?:\\s+saat)?',
'diff_before_yesterday' => 'evvelsi gün',
'diff_after_tomorrow' => 'öbür gün',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD.MM.YYYY',
'LL' => 'D MMMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'dddd, D MMMM YYYY HH:mm',
],
'calendar' => [
'sameDay' => '[bugün saat] LT',
'nextDay' => '[yarın saat] LT',
'nextWeek' => '[gelecek] dddd [saat] LT',
'lastDay' => '[dün] LT',
'lastWeek' => '[geçen] dddd [saat] LT',
'sameElse' => 'L',
],
'ordinal' => static function ($number, $period) {
switch ($period) {
case 'd':
case 'D':
case 'Do':
case 'DD':
return $number;
default:
if ($number === 0) { // special case for zero
return "$number'ıncı";
}
static $suffixes = [
1 => '\'inci',
5 => '\'inci',
8 => '\'inci',
70 => '\'inci',
80 => '\'inci',
2 => '\'nci',
7 => '\'nci',
20 => '\'nci',
50 => '\'nci',
3 => '\'üncü',
4 => '\'üncü',
100 => '\'üncü',
6 => '\'ncı',
9 => '\'uncu',
10 => '\'uncu',
30 => '\'uncu',
60 => '\'ıncı',
90 => '\'ıncı',
];
$lastDigit = $number % 10;
return $number.($suffixes[$lastDigit] ?? $suffixes[$number % 100 - $lastDigit] ?? $suffixes[$number >= 100 ? 100 : -1] ?? '');
}
},
'meridiem' => ['ÖÖ', 'ÖS', 'öö', 'ös'],
'months' => ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'],
'months_short' => ['Oca', 'Şub', 'Mar', 'Nis', 'May', 'Haz', 'Tem', 'Ağu', 'Eyl', 'Eki', 'Kas', 'Ara'],
'weekdays' => ['Pazar', 'Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'],
'weekdays_short' => ['Paz', 'Pts', 'Sal', 'Çar', 'Per', 'Cum', 'Cts'],
'weekdays_min' => ['Pz', 'Pt', 'Sa', 'Ça', 'Pe', 'Cu', 'Ct'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 1,
'list' => [', ', ' ve '],
];
+23
View File
@@ -0,0 +1,23 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/tr.php', [
'weekdays_short' => ['Paz', 'Pzt', 'Sal', 'Çar', 'Per', 'Cum', 'Cmt'],
'weekdays_min' => ['Pa', 'Pt', 'Sa', 'Ça', 'Pe', 'Cu', 'Ct'],
'formats' => [
'LT' => 'h:mm a',
'LTS' => 'h:mm:ss a',
'L' => 'D.MM.YYYY',
'LL' => 'D MMM YYYY',
'LLL' => 'D MMMM YYYY h:mm a',
'LLLL' => 'D MMMM YYYY dddd h:mm a',
],
]);
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/tr.php';
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/ts_ZA.php';
+55
View File
@@ -0,0 +1,55 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Zuza Software Foundation (Translate.org.za) Dwayne Bailey dwayne@translate.org.za
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'DD/MM/YYYY',
],
'months' => ['Sunguti', 'Nyenyenyani', 'Nyenyankulu', 'Dzivamisoko', 'Mudyaxihi', 'Khotavuxika', 'Mawuwani', 'Mhawuri', 'Ndzhati', 'Nhlangula', 'Hukuri', 'N\'wendzamhala'],
'months_short' => ['Sun', 'Yan', 'Kul', 'Dzi', 'Mud', 'Kho', 'Maw', 'Mha', 'Ndz', 'Nhl', 'Huk', 'N\'w'],
'weekdays' => ['Sonto', 'Musumbhunuku', 'Ravumbirhi', 'Ravunharhu', 'Ravumune', 'Ravuntlhanu', 'Mugqivela'],
'weekdays_short' => ['Son', 'Mus', 'Bir', 'Har', 'Ne', 'Tlh', 'Mug'],
'weekdays_min' => ['Son', 'Mus', 'Bir', 'Har', 'Ne', 'Tlh', 'Mug'],
'first_day_of_week' => 0,
'day_of_first_week_of_year' => 1,
'year' => 'malembe ya :count',
'y' => 'malembe ya :count',
'a_year' => 'malembe ya :count',
'month' => 'tinhweti ta :count',
'm' => 'tinhweti ta :count',
'a_month' => 'tinhweti ta :count',
'week' => 'mavhiki ya :count',
'w' => 'mavhiki ya :count',
'a_week' => 'mavhiki ya :count',
'day' => 'masiku :count',
'd' => 'masiku :count',
'a_day' => 'masiku :count',
'hour' => 'tiawara ta :count',
'h' => 'tiawara ta :count',
'a_hour' => 'tiawara ta :count',
'minute' => 'timinete ta :count',
'min' => 'timinete ta :count',
'a_minute' => 'timinete ta :count',
'second' => 'tisekoni ta :count',
's' => 'tisekoni ta :count',
'a_second' => 'tisekoni ta :count',
]);
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/tt_RU.php';
+39
View File
@@ -0,0 +1,39 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Rinat Norkin Pablo Saratxaga, Rinat Norkin pablo@mandrakesoft.com, rinat@taif.ru
*/
return [
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD.MM.YYYY',
'LL' => 'D MMMM YYYY',
'LLL' => 'DD MMM, HH:mm',
'LLLL' => 'DD MMMM YYYY, HH:mm',
],
'months' => ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'],
'months_short' => ['янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек'],
'weekdays' => ['якшәмбе', 'дышәмбе', 'сишәмбе', 'чәршәәмбе', 'пәнҗешмбе', 'җомга', 'шимбә'],
'weekdays_short' => ['якш', 'дыш', 'сиш', 'чәрш', 'пәнҗ', 'җом', 'шим'],
'weekdays_min' => ['якш', 'дыш', 'сиш', 'чәрш', 'пәнҗ', 'җом', 'шим'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 1,
'year' => ':count ел',
'month' => ':count ай',
'week' => ':count атна',
'day' => ':count көн',
'hour' => ':count сәгать',
'minute' => ':count минут',
'second' => ':count секунд',
];
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Reshat Sabiq tatar.iqtelif.i18n@gmail.com
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'DD.MM.YYYY',
],
'months' => ['Ğınwar', 'Fiwral\'', 'Mart', 'April', 'May', 'Yün', 'Yül', 'Awgust', 'Sintebír', 'Üktebír', 'Noyebír', 'Dikebír'],
'months_short' => ['Ğın', 'Fiw', 'Mar', 'Apr', 'May', 'Yün', 'Yül', 'Awg', 'Sin', 'Ükt', 'Noy', 'Dik'],
'weekdays' => ['Yekşembí', 'Düşembí', 'Sişembí', 'Çerşembí', 'Pencíşembí', 'Comğa', 'Şimbe'],
'weekdays_short' => ['Yek', 'Düş', 'Siş', 'Çer', 'Pen', 'Com', 'Şim'],
'weekdays_min' => ['Yek', 'Düş', 'Siş', 'Çer', 'Pen', 'Com', 'Şim'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 1,
'meridiem' => ['ÖA', 'ÖS'],
]);
+14
View File
@@ -0,0 +1,14 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/ses.php', [
'meridiem' => ['Subbaahi', 'Zaarikay b'],
]);
+65
View File
@@ -0,0 +1,65 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return [
'year' => '[0,1]:count ar|:count ars',
'y' => '[0,1]:count ar|:count ars',
'month' => '[0,1]:count mes|:count mesen',
'm' => '[0,1]:count mes|:count mesen',
'week' => '[0,1]:count seifetziua|:count seifetziuas',
'w' => '[0,1]:count seifetziua|:count seifetziuas',
'day' => '[0,1]:count ziua|:count ziuas',
'd' => '[0,1]:count ziua|:count ziuas',
'hour' => '[0,1]:count þora|:count þoras',
'h' => '[0,1]:count þora|:count þoras',
'minute' => '[0,1]:count míut|:count míuts',
'min' => '[0,1]:count míut|:count míuts',
'second' => ':count secunds',
's' => ':count secunds',
'ago' => 'ja :time',
'from_now' => 'osprei :time',
'diff_yesterday' => 'ieiri',
'diff_yesterday_regexp' => 'ieiri(?:\\s+à)?',
'diff_today' => 'oxhi',
'diff_today_regexp' => 'oxhi(?:\\s+à)?',
'diff_tomorrow' => 'demà',
'diff_tomorrow_regexp' => 'demà(?:\\s+à)?',
'formats' => [
'LT' => 'HH.mm',
'LTS' => 'HH.mm.ss',
'L' => 'DD.MM.YYYY',
'LL' => 'D. MMMM [dallas] YYYY',
'LLL' => 'D. MMMM [dallas] YYYY HH.mm',
'LLLL' => 'dddd, [li] D. MMMM [dallas] YYYY HH.mm',
],
'calendar' => [
'sameDay' => '[oxhi à] LT',
'nextDay' => '[demà à] LT',
'nextWeek' => 'dddd [à] LT',
'lastDay' => '[ieiri à] LT',
'lastWeek' => '[sür el] dddd [lasteu à] LT',
'sameElse' => 'L',
],
'meridiem' => ["D'A", "D'O"],
'months' => ['Januar', 'Fevraglh', 'Març', 'Avrïu', 'Mai', 'Gün', 'Julia', 'Guscht', 'Setemvar', 'Listopäts', 'Noemvar', 'Zecemvar'],
'months_short' => ['Jan', 'Fev', 'Mar', 'Avr', 'Mai', 'Gün', 'Jul', 'Gus', 'Set', 'Lis', 'Noe', 'Zec'],
'weekdays' => ['Súladi', 'Lúneçi', 'Maitzi', 'Márcuri', 'Xhúadi', 'Viénerçi', 'Sáturi'],
'weekdays_short' => ['Súl', 'Lún', 'Mai', 'Már', 'Xhú', 'Vié', 'Sát'],
'weekdays_min' => ['Sú', 'Lú', 'Ma', 'Má', 'Xh', 'Vi', 'Sá'],
'ordinal' => ':number.',
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 4,
];
+57
View File
@@ -0,0 +1,57 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Josh Soref
* - JD Isaacks
*/
return [
'year' => '{1}ⴰⵙⴳⴰⵙ|:count ⵉⵙⴳⴰⵙⵏ',
'month' => '{1}ⴰⵢoⵓⵔ|:count ⵉⵢⵢⵉⵔⵏ',
'week' => ':count ⵉⵎⴰⵍⴰⵙⵙ',
'day' => '{1}ⴰⵙⵙ|:count oⵙⵙⴰⵏ',
'hour' => '{1}ⵙⴰⵄⴰ|:count ⵜⴰⵙⵙⴰⵄⵉⵏ',
'minute' => '{1}ⵎⵉⵏⵓⴺ|:count ⵎⵉⵏⵓⴺ',
'second' => '{1}ⵉⵎⵉⴽ|:count ⵉⵎⵉⴽ',
'ago' => 'ⵢⴰⵏ :time',
'from_now' => 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ :time',
'diff_today' => 'ⴰⵙⴷⵅ',
'diff_yesterday' => 'ⴰⵚⴰⵏⵜ',
'diff_yesterday_regexp' => 'ⴰⵚⴰⵏⵜ(?:\\s+ⴴ)?',
'diff_tomorrow' => 'ⴰⵙⴽⴰ',
'diff_tomorrow_regexp' => 'ⴰⵙⴽⴰ(?:\\s+ⴴ)?',
'diff_today_regexp' => 'ⴰⵙⴷⵅ(?:\\s+ⴴ)?',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'dddd D MMMM YYYY HH:mm',
],
'calendar' => [
'sameDay' => '[ⴰⵙⴷⵅ ⴴ] LT',
'nextDay' => '[ⴰⵙⴽⴰ ⴴ] LT',
'nextWeek' => 'dddd [ⴴ] LT',
'lastDay' => '[ⴰⵚⴰⵏⵜ ⴴ] LT',
'lastWeek' => 'dddd [ⴴ] LT',
'sameElse' => 'L',
],
'months' => ['ⵉⵏⵏⴰⵢⵔ', 'ⴱⵕⴰⵢⵕ', 'ⵎⴰⵕⵚ', 'ⵉⴱⵔⵉⵔ', 'ⵎⴰⵢⵢⵓ', 'ⵢⵓⵏⵢⵓ', 'ⵢⵓⵍⵢⵓⵣ', 'ⵖⵓⵛⵜ', 'ⵛⵓⵜⴰⵏⴱⵉⵔ', 'ⴽⵟⵓⴱⵕ', 'ⵏⵓⵡⴰⵏⴱⵉⵔ', 'ⴷⵓⵊⵏⴱⵉⵔ'],
'months_short' => ['ⵉⵏⵏⴰⵢⵔ', 'ⴱⵕⴰⵢⵕ', 'ⵎⴰⵕⵚ', 'ⵉⴱⵔⵉⵔ', 'ⵎⴰⵢⵢⵓ', 'ⵢⵓⵏⵢⵓ', 'ⵢⵓⵍⵢⵓⵣ', 'ⵖⵓⵛⵜ', 'ⵛⵓⵜⴰⵏⴱⵉⵔ', 'ⴽⵟⵓⴱⵕ', 'ⵏⵓⵡⴰⵏⴱⵉⵔ', 'ⴷⵓⵊⵏⴱⵉⵔ'],
'weekdays' => ['ⴰⵙⴰⵎⴰⵙ', 'ⴰⵢⵏⴰⵙ', 'ⴰⵙⵉⵏⴰⵙ', 'ⴰⴽⵔⴰⵙ', 'ⴰⴽⵡⴰⵙ', 'ⴰⵙⵉⵎⵡⴰⵙ', 'ⴰⵙⵉⴹⵢⴰⵙ'],
'weekdays_short' => ['ⴰⵙⴰⵎⴰⵙ', 'ⴰⵢⵏⴰⵙ', 'ⴰⵙⵉⵏⴰⵙ', 'ⴰⴽⵔⴰⵙ', 'ⴰⴽⵡⴰⵙ', 'ⴰⵙⵉⵎⵡⴰⵙ', 'ⴰⵙⵉⴹⵢⴰⵙ'],
'weekdays_min' => ['ⴰⵙⴰⵎⴰⵙ', 'ⴰⵢⵏⴰⵙ', 'ⴰⵙⵉⵏⴰⵙ', 'ⴰⴽⵔⴰⵙ', 'ⴰⴽⵡⴰⵙ', 'ⴰⵙⵉⵎⵡⴰⵙ', 'ⴰⵙⵉⴹⵢⴰⵙ'],
'first_day_of_week' => 6,
'day_of_first_week_of_year' => 1,
'weekend' => [5, 6],
];
+64
View File
@@ -0,0 +1,64 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Josh Soref
* - JD Isaacks
*/
return [
'year' => '{1}:count asgas|:count isgasn',
'a_year' => 'asgas|:count isgasn',
'month' => '{1}:count ayowr|:count iyyirn',
'a_month' => 'ayowr|:count iyyirn',
'week' => ':count imalass',
'a_week' => ':imalass',
'day' => '{1}:count ass|:count ossan',
'a_day' => 'ass|:count ossan',
'hour' => '{1}:count saɛa|:count tassaɛin',
'a_hour' => '{1}saɛa|:count tassaɛin',
'minute' => ':count minuḍ',
'a_minute' => '{1}minuḍ|:count minuḍ',
'second' => ':count imik',
'a_second' => '{1}imik|:count imik',
'ago' => 'yan :time',
'from_now' => 'dadkh s yan :time',
'diff_yesterday' => 'assant',
'diff_yesterday_regexp' => 'assant(?:\\s+g)?',
'diff_today' => 'asdkh',
'diff_today_regexp' => 'asdkh(?:\\s+g)?',
'diff_tomorrow' => 'aska',
'diff_tomorrow_regexp' => 'aska(?:\\s+g)?',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'dddd D MMMM YYYY HH:mm',
],
'calendar' => [
'sameDay' => '[asdkh g] LT',
'nextDay' => '[aska g] LT',
'nextWeek' => 'dddd [g] LT',
'lastDay' => '[assant g] LT',
'lastWeek' => 'dddd [g] LT',
'sameElse' => 'L',
],
'months' => ['innayr', 'brˤayrˤ', 'marˤsˤ', 'ibrir', 'mayyw', 'ywnyw', 'ywlywz', 'ɣwšt', 'šwtanbir', 'ktˤwbrˤ', 'nwwanbir', 'dwjnbir'],
'months_short' => ['innayr', 'brˤayrˤ', 'marˤsˤ', 'ibrir', 'mayyw', 'ywnyw', 'ywlywz', 'ɣwšt', 'šwtanbir', 'ktˤwbrˤ', 'nwwanbir', 'dwjnbir'],
'weekdays' => ['asamas', 'aynas', 'asinas', 'akras', 'akwas', 'asimwas', 'asiḍyas'],
'weekdays_short' => ['asamas', 'aynas', 'asinas', 'akras', 'akwas', 'asimwas', 'asiḍyas'],
'weekdays_min' => ['asamas', 'aynas', 'asinas', 'akras', 'akwas', 'asimwas', 'asiḍyas'],
'meridiem' => ['Zdat azal', 'Ḍeffir aza'],
'first_day_of_week' => 6,
'day_of_first_week_of_year' => 1,
];
+84
View File
@@ -0,0 +1,84 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Philippe Vaucher
* - Tsutomu Kuroda
* - yasinn
*/
return [
'year' => '{1}'.'بىر يىل'.'|:count '.'يىل',
'month' => '{1}'.'بىر ئاي'.'|:count '.'ئاي',
'week' => '{1}'.'بىر ھەپتە'.'|:count '.'ھەپتە',
'day' => '{1}'.'بىر كۈن'.'|:count '.'كۈن',
'hour' => '{1}'.'بىر سائەت'.'|:count '.'سائەت',
'minute' => '{1}'.'بىر مىنۇت'.'|:count '.'مىنۇت',
'second' => '{1}'.'نەچچە سېكونت'.'|:count '.'سېكونت',
'ago' => ':time بۇرۇن',
'from_now' => ':time كېيىن',
'diff_today' => 'بۈگۈن',
'diff_yesterday' => 'تۆنۈگۈن',
'diff_tomorrow' => 'ئەتە',
'diff_tomorrow_regexp' => 'ئەتە(?:\\s+سائەت)?',
'diff_today_regexp' => 'بۈگۈن(?:\\s+سائەت)?',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'YYYY-MM-DD',
'LL' => 'YYYY-يىلىM-ئاينىڭD-كۈنى',
'LLL' => 'YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm',
'LLLL' => 'dddd، YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm',
],
'calendar' => [
'sameDay' => '[بۈگۈن سائەت] LT',
'nextDay' => '[ئەتە سائەت] LT',
'nextWeek' => '[كېلەركى] dddd [سائەت] LT',
'lastDay' => '[تۆنۈگۈن] LT',
'lastWeek' => '[ئالدىنقى] dddd [سائەت] LT',
'sameElse' => 'L',
],
'ordinal' => static function ($number, $period) {
return match ($period) {
'd', 'D', 'DDD' => $number.'-كۈنى',
'w', 'W' => $number.'-ھەپتە',
default => $number,
};
},
'meridiem' => static function ($hour, $minute) {
$time = $hour * 100 + $minute;
if ($time < 600) {
return 'يېرىم كېچە';
}
if ($time < 900) {
return 'سەھەر';
}
if ($time < 1130) {
return 'چۈشتىن بۇرۇن';
}
if ($time < 1230) {
return 'چۈش';
}
if ($time < 1800) {
return 'چۈشتىن كېيىن';
}
return 'كەچ';
},
'months' => ['يانۋار', 'فېۋرال', 'مارت', 'ئاپرېل', 'ماي', 'ئىيۇن', 'ئىيۇل', 'ئاۋغۇست', 'سېنتەبىر', 'ئۆكتەبىر', 'نويابىر', 'دېكابىر'],
'months_short' => ['يانۋار', 'فېۋرال', 'مارت', 'ئاپرېل', 'ماي', 'ئىيۇن', 'ئىيۇل', 'ئاۋغۇست', 'سېنتەبىر', 'ئۆكتەبىر', 'نويابىر', 'دېكابىر'],
'weekdays' => ['يەكشەنبە', 'دۈشەنبە', 'سەيشەنبە', 'چارشەنبە', 'پەيشەنبە', 'جۈمە', 'شەنبە'],
'weekdays_short' => ['يە', 'دۈ', 'سە', 'چا', 'پە', 'جۈ', 'شە'],
'weekdays_min' => ['يە', 'دۈ', 'سە', 'چا', 'پە', 'جۈ', 'شە'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 1,
'list' => [', ', ' ۋە '],
];
+17
View File
@@ -0,0 +1,17 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Kunal Marwaha
* - Alim Boyaq
*/
return require __DIR__.'/ug.php';
+190
View File
@@ -0,0 +1,190 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Carbon\CarbonInterface;
$processHoursFunction = static function (CarbonInterface $date, string $format) {
return $format.'о'.($date->hour === 11 ? 'б' : '').'] LT';
};
/*
* Authors:
* - Kunal Marwaha
* - Josh Soref
* - François B
* - Tim Fish
* - Serhan Apaydın
* - Max Mykhailenko
* - JD Isaacks
* - Max Kovpak
* - AucT
* - Philippe Vaucher
* - Ilya Shaplyko
* - Vadym Ievsieiev
* - Denys Kurets
* - Igor Kasyanchuk
* - Tsutomu Kuroda
* - tjku
* - Max Melentiev
* - Oleh
* - epaminond
* - Juanito Fatas
* - Vitalii Khustochka
* - Akira Matsuda
* - Christopher Dell
* - Enrique Vidal
* - Simone Carletti
* - Aaron Patterson
* - Andriy Tyurnikov
* - Nicolás Hock Isaza
* - Iwakura Taro
* - Andrii Ponomarov
* - alecrabbit
* - vystepanenko
* - AlexWalkerson
* - Andre Havryliuk (Andrend)
* - Max Datsenko (datsenko-md)
*/
return [
'year' => ':count рік|:count роки|:count років',
'y' => ':countр|:countрр|:countрр',
'a_year' => '{1}рік|:count рік|:count роки|:count років',
'month' => ':count місяць|:count місяці|:count місяців',
'm' => ':countм',
'a_month' => '{1}місяць|:count місяць|:count місяці|:count місяців',
'week' => ':count тиждень|:count тижні|:count тижнів',
'w' => ':countт',
'a_week' => '{1}тиждень|:count тиждень|:count тижні|:count тижнів',
'day' => ':count день|:count дні|:count днів',
'd' => ':countд',
'a_day' => '{1}день|:count день|:count дні|:count днів',
'hour' => ':count година|:count години|:count годин',
'h' => ':countг',
'a_hour' => '{1}година|:count година|:count години|:count годин',
'minute' => ':count хвилина|:count хвилини|:count хвилин',
'min' => ':countхв',
'a_minute' => '{1}хвилина|:count хвилина|:count хвилини|:count хвилин',
'second' => ':count секунда|:count секунди|:count секунд',
's' => ':countсек',
'a_second' => '{1}декілька секунд|:count секунда|:count секунди|:count секунд',
'hour_ago' => ':count годину|:count години|:count годин',
'a_hour_ago' => '{1}годину|:count годину|:count години|:count годин',
'minute_ago' => ':count хвилину|:count хвилини|:count хвилин',
'a_minute_ago' => '{1}хвилину|:count хвилину|:count хвилини|:count хвилин',
'second_ago' => ':count секунду|:count секунди|:count секунд',
'a_second_ago' => '{1}декілька секунд|:count секунду|:count секунди|:count секунд',
'hour_from_now' => ':count годину|:count години|:count годин',
'a_hour_from_now' => '{1}годину|:count годину|:count години|:count годин',
'minute_from_now' => ':count хвилину|:count хвилини|:count хвилин',
'a_minute_from_now' => '{1}хвилину|:count хвилину|:count хвилини|:count хвилин',
'second_from_now' => ':count секунду|:count секунди|:count секунд',
'a_second_from_now' => '{1}декілька секунд|:count секунду|:count секунди|:count секунд',
'hour_after' => ':count годину|:count години|:count годин',
'a_hour_after' => '{1}годину|:count годину|:count години|:count годин',
'minute_after' => ':count хвилину|:count хвилини|:count хвилин',
'a_minute_after' => '{1}хвилину|:count хвилину|:count хвилини|:count хвилин',
'second_after' => ':count секунду|:count секунди|:count секунд',
'a_second_after' => '{1}декілька секунд|:count секунду|:count секунди|:count секунд',
'hour_before' => ':count годину|:count години|:count годин',
'a_hour_before' => '{1}годину|:count годину|:count години|:count годин',
'minute_before' => ':count хвилину|:count хвилини|:count хвилин',
'a_minute_before' => '{1}хвилину|:count хвилину|:count хвилини|:count хвилин',
'second_before' => ':count секунду|:count секунди|:count секунд',
'a_second_before' => '{1}декілька секунд|:count секунду|:count секунди|:count секунд',
'ago' => ':time тому',
'from_now' => 'за :time',
'after' => ':time після',
'before' => ':time до',
'diff_now' => 'щойно',
'diff_today' => 'Сьогодні',
'diff_today_regexp' => 'Сьогодні(?:\\s+о)?',
'diff_yesterday' => 'вчора',
'diff_yesterday_regexp' => 'Вчора(?:\\s+о)?',
'diff_tomorrow' => 'завтра',
'diff_tomorrow_regexp' => 'Завтра(?:\\s+о)?',
'diff_before_yesterday' => 'позавчора',
'diff_after_tomorrow' => 'післязавтра',
'period_recurrences' => 'один раз|:count рази|:count разів',
'period_interval' => 'кожні :interval',
'period_start_date' => 'з :date',
'period_end_date' => 'до :date',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD.MM.YYYY',
'LL' => 'D MMMM YYYY',
'LLL' => 'D MMMM YYYY, HH:mm',
'LLLL' => 'dddd, D MMMM YYYY, HH:mm',
],
'calendar' => [
'sameDay' => static fn (CarbonInterface $date) => $processHoursFunction($date, '[Сьогодні '),
'nextDay' => static fn (CarbonInterface $date) => $processHoursFunction($date, '[Завтра '),
'nextWeek' => static fn (CarbonInterface $date) => $processHoursFunction($date, '[У] dddd ['),
'lastDay' => static fn (CarbonInterface $date) => $processHoursFunction($date, '[Вчора '),
'lastWeek' => static fn (CarbonInterface $date) => match ($date->dayOfWeek) {
0, 3, 5, 6 => $processHoursFunction($date, '[Минулої] dddd ['),
default => $processHoursFunction($date, '[Минулого] dddd ['),
},
'sameElse' => 'L',
],
'ordinal' => static fn ($number, $period) => match ($period) {
'M', 'd', 'DDD', 'w', 'W' => $number.'-й',
'D' => $number.'-го',
default => $number,
},
'meridiem' => static function ($hour) {
if ($hour < 4) {
return 'ночі';
}
if ($hour < 12) {
return 'ранку';
}
if ($hour < 17) {
return 'дня';
}
return 'вечора';
},
'months' => ['січня', 'лютого', 'березня', 'квітня', 'травня', 'червня', 'липня', 'серпня', 'вересня', 'жовтня', 'листопада', 'грудня'],
'months_standalone' => ['січень', 'лютий', 'березень', 'квітень', 'травень', 'червень', 'липень', 'серпень', 'вересень', 'жовтень', 'листопад', 'грудень'],
'months_short' => ['січ', 'лют', 'бер', 'кві', 'тра', 'чер', 'лип', 'сер', 'вер', 'жов', 'лис', 'гру'],
'months_regexp' => '/(D[oD]?(\[[^\[\]]*\]|\s)+MMMM?|L{2,4}|l{2,4})/',
'weekdays' => static function (CarbonInterface $date, $format, $index) {
static $words = [
'nominative' => ['неділя', 'понеділок', 'вівторок', 'середа', 'четвер', 'п’ятниця', 'субота'],
'accusative' => ['неділю', 'понеділок', 'вівторок', 'середу', 'четвер', 'п’ятницю', 'суботу'],
'genitive' => ['неділі', 'понеділка', 'вівторка', 'середи', 'четверга', 'п’ятниці', 'суботи'],
];
$format ??= '';
$nounCase = preg_match('/(\[(В|в|У|у)\])\s+dddd/u', $format)
? 'accusative'
: (
preg_match('/\[?(?:минулої|наступної)?\s*\]\s+dddd/u', $format)
? 'genitive'
: 'nominative'
);
return $words[$nounCase][$index] ?? null;
},
'weekdays_short' => ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],
'weekdays_min' => ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 1,
'list' => [', ', ' i '],
];
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/uk.php';
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/unm_US.php';
+58
View File
@@ -0,0 +1,58 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - bug-glibc-locales@gnu.org
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'DD/MM/YY',
],
'months' => ['enikwsi', 'chkwali', 'xamokhwite', 'kwetayoxe', 'tainipen', 'kichinipen', 'lainipen', 'winaminke', 'kichitahkok', 'puksit', 'wini', 'muxkotae'],
'months_short' => ['eni', 'chk', 'xam', 'kwe', 'tai', 'nip', 'lai', 'win', 'tah', 'puk', 'kun', 'mux'],
'weekdays' => ['kentuwei', 'manteke', 'tusteke', 'lelai', 'tasteke', 'pelaiteke', 'sateteke'],
'weekdays_short' => ['ken', 'man', 'tus', 'lel', 'tas', 'pel', 'sat'],
'weekdays_min' => ['ken', 'man', 'tus', 'lel', 'tas', 'pel', 'sat'],
'first_day_of_week' => 0,
'day_of_first_week_of_year' => 1,
// Too unreliable
/*
'year' => ':count kaxtëne',
'y' => ':count kaxtëne',
'a_year' => ':count kaxtëne',
'month' => ':count piskewëni kishux', // less reliable
'm' => ':count piskewëni kishux', // less reliable
'a_month' => ':count piskewëni kishux', // less reliable
'week' => ':count kishku', // less reliable
'w' => ':count kishku', // less reliable
'a_week' => ':count kishku', // less reliable
'day' => ':count kishku',
'd' => ':count kishku',
'a_day' => ':count kishku',
'hour' => ':count xkuk', // less reliable
'h' => ':count xkuk', // less reliable
'a_hour' => ':count xkuk', // less reliable
'minute' => ':count txituwàk', // less reliable
'min' => ':count txituwàk', // less reliable
'a_minute' => ':count txituwàk', // less reliable
'second' => ':count nisha', // less reliable
's' => ':count nisha', // less reliable
'a_second' => ':count nisha', // less reliable
*/
]);
+94
View File
@@ -0,0 +1,94 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$months = [
'جنوری',
'فروری',
'مارچ',
'اپریل',
'مئی',
'جون',
'جولائی',
'اگست',
'ستمبر',
'اکتوبر',
'نومبر',
'دسمبر',
];
$weekdays = [
'اتوار',
'پیر',
'منگل',
'بدھ',
'جمعرات',
'جمعہ',
'ہفتہ',
];
/*
* Authors:
* - Sawood Alam
* - Mehshan
* - Philippe Vaucher
* - Tsutomu Kuroda
* - tjku
* - Zaid Akram
* - Max Melentiev
* - hafezdivandari
* - Hossein Jabbari
* - nimamo
*/
return [
'year' => 'ایک سال|:count سال',
'month' => 'ایک ماہ|:count ماہ',
'week' => ':count ہفتے',
'day' => 'ایک دن|:count دن',
'hour' => 'ایک گھنٹہ|:count گھنٹے',
'minute' => 'ایک منٹ|:count منٹ',
'second' => 'چند سیکنڈ|:count سیکنڈ',
'ago' => ':time قبل',
'from_now' => ':time بعد',
'after' => ':time بعد',
'before' => ':time پہلے',
'diff_now' => 'اب',
'diff_today' => 'آج',
'diff_today_regexp' => 'آج(?:\\s+بوقت)?',
'diff_yesterday' => 'گزشتہ کل',
'diff_yesterday_regexp' => 'گذشتہ(?:\\s+روز)?(?:\\s+بوقت)?',
'diff_tomorrow' => 'آئندہ کل',
'diff_tomorrow_regexp' => 'کل(?:\\s+بوقت)?',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'dddd، D MMMM YYYY HH:mm',
],
'calendar' => [
'sameDay' => '[آج بوقت] LT',
'nextDay' => '[کل بوقت] LT',
'nextWeek' => 'dddd [بوقت] LT',
'lastDay' => '[گذشتہ روز بوقت] LT',
'lastWeek' => '[گذشتہ] dddd [بوقت] LT',
'sameElse' => 'L',
],
'meridiem' => ['صبح', 'شام'],
'months' => $months,
'months_short' => $months,
'weekdays' => $weekdays,
'weekdays_short' => $weekdays,
'weekdays_min' => $weekdays,
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 4,
'list' => ['، ', ' اور '],
];
+26
View File
@@ -0,0 +1,26 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Red Hat, Pune bug-glibc-locales@gnu.org
*/
return array_replace_recursive(require __DIR__.'/ur.php', [
'formats' => [
'L' => 'D/M/YY',
],
'months' => ['جنوری', 'فروری', 'مارچ', 'اپریل', 'مئی', 'جون', 'جولائی', 'اگست', 'ستمبر', 'اکتوبر', 'نومبر', 'دسمبر'],
'months_short' => ['جنوری', 'فروری', 'مارچ', 'اپریل', 'مئی', 'جون', 'جولائی', 'اگست', 'ستمبر', 'اکتوبر', 'نومبر', 'دسمبر'],
'weekdays' => ['اتوار', 'پیر', 'منگل', 'بدھ', 'جمعرات', 'جمعہ', 'سنیچر'],
'weekdays_short' => ['اتوار', 'پیر', 'منگل', 'بدھ', 'جمعرات', 'جمعہ', 'سنیچر'],
'weekdays_min' => ['اتوار', 'پیر', 'منگل', 'بدھ', 'جمعرات', 'جمعہ', 'سنیچر'],
'day_of_first_week_of_year' => 1,
]);
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - bug-glibc-locales@gnu.org
*/
return array_replace_recursive(require __DIR__.'/ur.php', [
'formats' => [
'L' => 'DD/MM/YYYY',
],
'months' => ['جنوری', 'فروری', 'مارچ', 'اپریل', 'مئی', 'جون', 'جولائی', 'اگست', 'ستمبر', 'اکتوبر', 'نومبر', 'دسمبر'],
'months_short' => ['جنوری', 'فروری', 'مارچ', 'اپریل', 'مئی', 'جون', 'جولائی', 'اگست', 'ستمبر', 'اکتوبر', 'نومبر', 'دسمبر'],
'weekdays' => ['اتوار', 'پير', 'منگل', 'بدھ', 'جمعرات', 'جمعه', 'هفته'],
'weekdays_short' => ['اتوار', 'پير', 'منگل', 'بدھ', 'جمعرات', 'جمعه', 'هفته'],
'weekdays_min' => ['اتوار', 'پير', 'منگل', 'بدھ', 'جمعرات', 'جمعه', 'هفته'],
'day_of_first_week_of_year' => 1,
'meridiem' => ['ص', 'ش'],
]);
+85
View File
@@ -0,0 +1,85 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Dmitriy Shabanov
* - JD Isaacks
* - Inoyatulloh
* - Jamshid
* - aarkhipov
* - Philippe Vaucher
* - felixthemagnificent
* - Tsutomu Kuroda
* - tjku
* - Max Melentiev
* - Juanito Fatas
* - Alisher Ulugbekov
* - Ergashev Adizbek
*/
return [
'year' => ':count йил',
'a_year' => '{1}бир йил|:count йил',
'y' => ':count й',
'month' => ':count ой',
'a_month' => '{1}бир ой|:count ой',
'm' => ':count о',
'week' => ':count ҳафта',
'a_week' => '{1}бир ҳафта|:count ҳафта',
'w' => ':count ҳ',
'day' => ':count кун',
'a_day' => '{1}бир кун|:count кун',
'd' => ':count к',
'hour' => ':count соат',
'a_hour' => '{1}бир соат|:count соат',
'h' => ':count с',
'minute' => ':count дақиқа',
'a_minute' => '{1}бир дақиқа|:count дақиқа',
'min' => ':count д',
'second' => ':count сония',
'a_second' => '{1}сония|:count сония',
's' => ':count с',
'ago' => ':time аввал',
'from_now' => 'Якин :time ичида',
'after' => ':timeдан кейин',
'before' => ':time олдин',
'diff_now' => 'ҳозир',
'diff_today' => 'Бугун',
'diff_today_regexp' => 'Бугун(?:\\s+соат)?',
'diff_yesterday' => 'Кеча',
'diff_yesterday_regexp' => 'Кеча(?:\\s+соат)?',
'diff_tomorrow' => 'Эртага',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'D MMMM YYYY, dddd HH:mm',
],
'calendar' => [
'sameDay' => '[Бугун соат] LT [да]',
'nextDay' => '[Эртага] LT [да]',
'nextWeek' => 'dddd [куни соат] LT [да]',
'lastDay' => '[Кеча соат] LT [да]',
'lastWeek' => '[Утган] dddd [куни соат] LT [да]',
'sameElse' => 'L',
],
'months' => ['январ', 'феврал', 'март', 'апрел', 'май', 'июн', 'июл', 'август', 'сентябр', 'октябр', 'ноябр', 'декабр'],
'months_short' => ['янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек'],
'weekdays' => ['якшанба', 'душанба', 'сешанба', 'чоршанба', 'пайшанба', 'жума', 'шанба'],
'weekdays_short' => ['якш', 'душ', 'сеш', 'чор', 'пай', 'жум', 'шан'],
'weekdays_min' => ['як', 'ду', 'се', 'чо', 'па', 'жу', 'ша'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 1,
'meridiem' => ['эрталаб', 'кечаси'],
'list' => [', ', ' ва '],
];
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/fa.php', [
'weekdays' => ['یکشنبه', 'دوشنبه', 'سه‌شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'],
'weekdays_short' => ['ی.', 'د.', 'س.', 'چ.', 'پ.', 'ج.', 'ش.'],
'weekdays_min' => ['ی.', 'د.', 'س.', 'چ.', 'پ.', 'ج.', 'ش.'],
'months' => ['جنوری', 'فبروری', 'مارچ', 'اپریل', 'می', 'جون', 'جولای', 'اگست', 'سپتمبر', 'اکتوبر', 'نومبر', 'دسمبر'],
'months_short' => ['جنو', 'فبر', 'مار', 'اپر', 'می', 'جون', 'جول', 'اگس', 'سپت', 'اکت', 'نوم', 'دسم'],
'first_day_of_week' => 6,
'weekend' => [4, 5],
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'YYYY-MM-dd',
'LL' => 'YYYY MMM D',
'LLL' => 'YYYY MMMM D HH:mm',
'LLLL' => 'YYYY MMMM D, dddd HH:mm',
],
]);
+20
View File
@@ -0,0 +1,20 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/uz.php', [
'formats' => [
'L' => 'DD/MM/yy',
'LL' => 'D MMM, YYYY',
'LLL' => 'D MMMM, YYYY HH:mm',
'LLLL' => 'dddd, DD MMMM, YYYY HH:mm',
],
'meridiem' => ['ТО', 'ТК'],
]);
+74
View File
@@ -0,0 +1,74 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Josh Soref
* - Rasulbek
* - Ilyosjon Kamoldinov (ilyosjon09)
*/
return [
'year' => ':count yil',
'a_year' => '{1}bir yil|:count yil',
'y' => ':count y',
'month' => ':count oy',
'a_month' => '{1}bir oy|:count oy',
'm' => ':count o',
'week' => ':count hafta',
'a_week' => '{1}bir hafta|:count hafta',
'w' => ':count h',
'day' => ':count kun',
'a_day' => '{1}bir kun|:count kun',
'd' => ':count k',
'hour' => ':count soat',
'a_hour' => '{1}bir soat|:count soat',
'h' => ':count soat',
'minute' => ':count daqiqa',
'a_minute' => '{1}bir daqiqa|:count daqiqa',
'min' => ':count d',
'second' => ':count soniya',
'a_second' => '{1}soniya|:count soniya',
's' => ':count son.',
'ago' => ':time avval',
'from_now' => 'Yaqin :time ichida',
'after' => ':timedan keyin',
'before' => ':time oldin',
'diff_yesterday' => 'Kecha',
'diff_yesterday_regexp' => 'Kecha(?:\\s+soat)?',
'diff_today' => 'Bugun',
'diff_today_regexp' => 'Bugun(?:\\s+soat)?',
'diff_tomorrow' => 'Ertaga',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'D MMMM YYYY, dddd HH:mm',
],
'calendar' => [
'sameDay' => '[Bugun soat] LT [da]',
'nextDay' => '[Ertaga] LT [da]',
'nextWeek' => 'dddd [kuni soat] LT [da]',
'lastDay' => '[Kecha soat] LT [da]',
'lastWeek' => '[O\'tgan] dddd [kuni soat] LT [da]',
'sameElse' => 'L',
],
'months' => ['Yanvar', 'Fevral', 'Mart', 'Aprel', 'May', 'Iyun', 'Iyul', 'Avgust', 'Sentabr', 'Oktabr', 'Noyabr', 'Dekabr'],
'months_short' => ['Yan', 'Fev', 'Mar', 'Apr', 'May', 'Iyun', 'Iyul', 'Avg', 'Sen', 'Okt', 'Noy', 'Dek'],
'weekdays' => ['Yakshanba', 'Dushanba', 'Seshanba', 'Chorshanba', 'Payshanba', 'Juma', 'Shanba'],
'weekdays_short' => ['Yak', 'Dush', 'Sesh', 'Chor', 'Pay', 'Jum', 'Shan'],
'weekdays_min' => ['Ya', 'Du', 'Se', 'Cho', 'Pa', 'Ju', 'Sha'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 1,
'list' => [', ', ' va '],
'meridiem' => ['TO', 'TK'],
];
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Bobir Ismailov Bobir Ismailov, Pablo Saratxaga, Mashrab Kuvatov bobir_is@yahoo.com, pablo@mandrakesoft.com, kmashrab@uni-bremen.de
*/
return array_replace_recursive(require __DIR__.'/uz_Latn.php', [
'formats' => [
'L' => 'DD/MM/YY',
],
'months' => ['Yanvar', 'Fevral', 'Mart', 'Aprel', 'May', 'Iyun', 'Iyul', 'Avgust', 'Sentabr', 'Oktabr', 'Noyabr', 'Dekabr'],
'months_short' => ['Yan', 'Fev', 'Mar', 'Apr', 'May', 'Iyn', 'Iyl', 'Avg', 'Sen', 'Okt', 'Noy', 'Dek'],
'weekdays' => ['Yakshanba', 'Dushanba', 'Seshanba', 'Chorshanba', 'Payshanba', 'Juma', 'Shanba'],
'weekdays_short' => ['Yak', 'Du', 'Se', 'Cho', 'Pay', 'Ju', 'Sha'],
'weekdays_min' => ['Yak', 'Du', 'Se', 'Cho', 'Pay', 'Ju', 'Sha'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 1,
]);
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Mashrab Kuvatov Mashrab Kuvatov, Pablo Saratxaga kmashrab@uni-bremen.de, pablo@mandrakesoft.com
*/
return array_replace_recursive(require __DIR__.'/uz.php', [
'formats' => [
'L' => 'DD/MM/YY',
],
'months' => ['Январ', 'Феврал', 'Март', 'Апрел', 'Май', 'Июн', 'Июл', 'Август', 'Сентябр', 'Октябр', 'Ноябр', 'Декабр'],
'months_short' => ['Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'],
'weekdays' => ['Якшанба', 'Душанба', 'Сешанба', 'Чоршанба', 'Пайшанба', 'Жума', 'Шанба'],
'weekdays_short' => ['Якш', 'Душ', 'Сеш', 'Чор', 'Пай', 'Жум', 'Шан'],
'weekdays_min' => ['Якш', 'Душ', 'Сеш', 'Чор', 'Пай', 'Жум', 'Шан'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 1,
]);
+35
View File
@@ -0,0 +1,35 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'weekdays' => ['ꕞꕌꔵ', 'ꗳꗡꘉ', 'ꕚꕞꕚ', 'ꕉꕞꕒ', 'ꕉꔤꕆꕢ', 'ꕉꔤꕀꕮ', 'ꔻꔬꔳ'],
'weekdays_short' => ['ꕞꕌꔵ', 'ꗳꗡꘉ', 'ꕚꕞꕚ', 'ꕉꕞꕒ', 'ꕉꔤꕆꕢ', 'ꕉꔤꕀꕮ', 'ꔻꔬꔳ'],
'weekdays_min' => ['ꕞꕌꔵ', 'ꗳꗡꘉ', 'ꕚꕞꕚ', 'ꕉꕞꕒ', 'ꕉꔤꕆꕢ', 'ꕉꔤꕀꕮ', 'ꔻꔬꔳ'],
'months' => ['ꖨꖕ ꕪꕴ ꔞꔀꕮꕊ', 'ꕒꕡꖝꖕ', 'ꕾꖺ', 'ꖢꖕ', 'ꖑꕱ', 'ꖱꘋ', 'ꖱꕞꔤ', 'ꗛꔕ', 'ꕢꕌ', 'ꕭꖃ', 'ꔞꘋꕔꕿ ꕸꖃꗏ', 'ꖨꖕ ꕪꕴ ꗏꖺꕮꕊ'],
'months_short' => ['ꖨꖕꔞ', 'ꕒꕡ', 'ꕾꖺ', 'ꖢꖕ', 'ꖑꕱ', 'ꖱꘋ', 'ꖱꕞ', 'ꗛꔕ', 'ꕢꕌ', 'ꕭꖃ', 'ꔞꘋ', 'ꖨꖕꗏ'],
'first_day_of_week' => 1,
'formats' => [
'LT' => 'h:mm a',
'LTS' => 'h:mm:ss a',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMM YYYY',
'LLL' => 'D MMMM YYYY h:mm a',
'LLLL' => 'dddd, D MMMM YYYY h:mm a',
],
'year' => ':count ꕀ', // less reliable
'y' => ':count ꕀ', // less reliable
'a_year' => ':count ꕀ', // less reliable
'second' => ':count ꗱꕞꕯꕊ', // less reliable
's' => ':count ꗱꕞꕯꕊ', // less reliable
'a_second' => ':count ꗱꕞꕯꕊ', // less reliable
]);
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'weekdays' => ['lahadi', 'tɛɛnɛɛ', 'talata', 'alaba', 'aimisa', 'aijima', 'siɓiti'],
'weekdays_short' => ['lahadi', 'tɛɛnɛɛ', 'talata', 'alaba', 'aimisa', 'aijima', 'siɓiti'],
'weekdays_min' => ['lahadi', 'tɛɛnɛɛ', 'talata', 'alaba', 'aimisa', 'aijima', 'siɓiti'],
'months' => ['luukao kemã', 'ɓandaɓu', 'vɔɔ', 'fulu', 'goo', '6', '7', 'kɔnde', 'saah', 'galo', 'kenpkato ɓololɔ', 'luukao lɔma'],
'months_short' => ['luukao kemã', 'ɓandaɓu', 'vɔɔ', 'fulu', 'goo', '6', '7', 'kɔnde', 'saah', 'galo', 'kenpkato ɓololɔ', 'luukao lɔma'],
'first_day_of_week' => 1,
'formats' => [
'LT' => 'h:mm a',
'LTS' => 'h:mm:ss a',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMM YYYY',
'LLL' => 'D MMMM YYYY h:mm a',
'LLLL' => 'dddd, D MMMM YYYY h:mm a',
],
]);
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/vai.php';
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/ve_ZA.php';
+50
View File
@@ -0,0 +1,50 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Zuza Software Foundation (Translate.org.za) Dwayne Bailey dwayne@translate.org.za
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'DD/MM/YYYY',
],
'months' => ['Phando', 'Luhuhi', 'Ṱhafamuhwe', 'Lambamai', 'Shundunthule', 'Fulwi', 'Fulwana', 'Ṱhangule', 'Khubvumedzi', 'Tshimedzi', 'Ḽara', 'Nyendavhusiku'],
'months_short' => ['Pha', 'Luh', 'Fam', 'Lam', 'Shu', 'Lwi', 'Lwa', 'Ngu', 'Khu', 'Tsh', 'Ḽar', 'Nye'],
'weekdays' => ['Swondaha', 'Musumbuluwo', 'Ḽavhuvhili', 'Ḽavhuraru', 'Ḽavhuṋa', 'Ḽavhuṱanu', 'Mugivhela'],
'weekdays_short' => ['Swo', 'Mus', 'Vhi', 'Rar', 'ṋa', 'Ṱan', 'Mug'],
'weekdays_min' => ['Swo', 'Mus', 'Vhi', 'Rar', 'ṋa', 'Ṱan', 'Mug'],
'first_day_of_week' => 0,
'day_of_first_week_of_year' => 1,
// Too unreliable
/*
'day' => ':count vhege', // less reliable
'd' => ':count vhege', // less reliable
'a_day' => ':count vhege', // less reliable
'hour' => ':count watshi', // less reliable
'h' => ':count watshi', // less reliable
'a_hour' => ':count watshi', // less reliable
'minute' => ':count watshi', // less reliable
'min' => ':count watshi', // less reliable
'a_minute' => ':count watshi', // less reliable
'second' => ':count Mu', // less reliable
's' => ':count Mu', // less reliable
'a_second' => ':count Mu', // less reliable
'week' => ':count vhege',
'w' => ':count vhege',
'a_week' => ':count vhege',
*/
]);
+76
View File
@@ -0,0 +1,76 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - François B
* - Andre Polykanine A.K.A. Menelion Elensúlë
* - JD Isaacks
*/
return [
'year' => ':count năm',
'a_year' => '{1}một năm|]1, Inf[:count năm',
'y' => ':count năm',
'month' => ':count tháng',
'a_month' => '{1}một tháng|]1, Inf[:count tháng',
'm' => ':count tháng',
'week' => ':count tuần',
'a_week' => '{1}một tuần|]1, Inf[:count tuần',
'w' => ':count tuần',
'day' => ':count ngày',
'a_day' => '{1}một ngày|]1, Inf[:count ngày',
'd' => ':count ngày',
'hour' => ':count giờ',
'a_hour' => '{1}một giờ|]1, Inf[:count giờ',
'h' => ':count giờ',
'minute' => ':count phút',
'a_minute' => '{1}một phút|]1, Inf[:count phút',
'min' => ':count phút',
'second' => ':count giây',
'a_second' => '{1}vài giây|]1, Inf[:count giây',
's' => ':count giây',
'ago' => ':time trước',
'from_now' => ':time tới',
'after' => ':time sau',
'before' => ':time trước',
'diff_now' => 'bây giờ',
'diff_today' => 'Hôm',
'diff_today_regexp' => 'Hôm(?:\\s+nay)?(?:\\s+lúc)?',
'diff_yesterday' => 'Hôm qua',
'diff_yesterday_regexp' => 'Hôm(?:\\s+qua)?(?:\\s+lúc)?',
'diff_tomorrow' => 'Ngày mai',
'diff_tomorrow_regexp' => 'Ngày(?:\\s+mai)?(?:\\s+lúc)?',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMMM [năm] YYYY',
'LLL' => 'D MMMM [năm] YYYY HH:mm',
'LLLL' => 'dddd, D MMMM [năm] YYYY HH:mm',
],
'calendar' => [
'sameDay' => '[Hôm nay lúc] LT',
'nextDay' => '[Ngày mai lúc] LT',
'nextWeek' => 'dddd [tuần tới lúc] LT',
'lastDay' => '[Hôm qua lúc] LT',
'lastWeek' => 'dddd [tuần trước lúc] LT',
'sameElse' => 'L',
],
'meridiem' => ['SA', 'CH'],
'months' => ['tháng 1', 'tháng 2', 'tháng 3', 'tháng 4', 'tháng 5', 'tháng 6', 'tháng 7', 'tháng 8', 'tháng 9', 'tháng 10', 'tháng 11', 'tháng 12'],
'months_short' => ['Th01', 'Th02', 'Th03', 'Th04', 'Th05', 'Th06', 'Th07', 'Th08', 'Th09', 'Th10', 'Th11', 'Th12'],
'weekdays' => ['chủ nhật', 'thứ hai', 'thứ ba', 'thứ tư', 'thứ năm', 'thứ sáu', 'thứ bảy'],
'weekdays_short' => ['CN', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7'],
'weekdays_min' => ['CN', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 4,
'list' => [', ', ' và '],
];
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/vi.php';
+52
View File
@@ -0,0 +1,52 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'months' => ['M01', 'M02', 'M03', 'M04', 'M05', 'M06', 'M07', 'M08', 'M09', 'M10', 'M11', 'M12'],
'months_short' => ['M01', 'M02', 'M03', 'M04', 'M05', 'M06', 'M07', 'M08', 'M09', 'M10', 'M11', 'M12'],
'first_day_of_week' => 1,
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'YYYY-MM-dd',
'LL' => 'YYYY MMM D',
'LLL' => 'YYYY MMMM D HH:mm',
'LLLL' => 'YYYY MMMM D, dddd HH:mm',
],
'year' => ':count yel',
'y' => ':count yel',
'a_year' => ':count yel',
'month' => ':count mul',
'm' => ':count mul',
'a_month' => ':count mul',
'week' => ':count vig',
'w' => ':count vig',
'a_week' => ':count vig',
'day' => ':count del',
'd' => ':count del',
'a_day' => ':count del',
'hour' => ':count düp',
'h' => ':count düp',
'a_hour' => ':count düp',
'minute' => ':count minut',
'min' => ':count minut',
'a_minute' => ':count minut',
'second' => ':count sekun',
's' => ':count sekun',
'a_second' => ':count sekun',
]);
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'meridiem' => ['utuko', 'kyiukonyi'],
'weekdays' => ['Jumapilyi', 'Jumatatuu', 'Jumanne', 'Jumatanu', 'Alhamisi', 'Ijumaa', 'Jumamosi'],
'weekdays_short' => ['Jpi', 'Jtt', 'Jnn', 'Jtn', 'Alh', 'Iju', 'Jmo'],
'weekdays_min' => ['Jpi', 'Jtt', 'Jnn', 'Jtn', 'Alh', 'Iju', 'Jmo'],
'months' => ['Januari', 'Februari', 'Machi', 'Aprilyi', 'Mei', 'Junyi', 'Julyai', 'Agusti', 'Septemba', 'Oktoba', 'Novemba', 'Desemba'],
'months_short' => ['Jan', 'Feb', 'Mac', 'Apr', 'Mei', 'Jun', 'Jul', 'Ago', 'Sep', 'Okt', 'Nov', 'Des'],
'first_day_of_week' => 1,
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'dddd, D MMMM YYYY HH:mm',
],
]);
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/wa_BE.php';
+55
View File
@@ -0,0 +1,55 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Djan SACRE Pablo Saratxaga pablo@mandrakesoft.com
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'DD/MM/YYYY',
],
'months' => ['di djanvî', 'di fevrî', 'di måss', 'd avri', 'di may', 'di djun', 'di djulete', 'd awousse', 'di setimbe', 'd octôbe', 'di nôvimbe', 'di decimbe'],
'months_short' => ['dja', 'fev', 'mås', 'avr', 'may', 'djn', 'djl', 'awo', 'set', 'oct', 'nôv', 'dec'],
'weekdays' => ['dimegne', 'londi', 'mårdi', 'mierkidi', 'djudi', 'vénrdi', 'semdi'],
'weekdays_short' => ['dim', 'lon', 'mår', 'mie', 'dju', 'vén', 'sem'],
'weekdays_min' => ['dim', 'lon', 'mår', 'mie', 'dju', 'vén', 'sem'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 4,
'year' => ':count anêye',
'y' => ':count anêye',
'a_year' => ':count anêye',
'month' => ':count meûs',
'm' => ':count meûs',
'a_month' => ':count meûs',
'week' => ':count samwinne',
'w' => ':count samwinne',
'a_week' => ':count samwinne',
'day' => ':count djoû',
'd' => ':count djoû',
'a_day' => ':count djoû',
'hour' => ':count eure',
'h' => ':count eure',
'a_hour' => ':count eure',
'minute' => ':count munute',
'min' => ':count munute',
'a_minute' => ':count munute',
'second' => ':count Sigonde',
's' => ':count Sigonde',
'a_second' => ':count Sigonde',
]);
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/wae_CH.php';
+31
View File
@@ -0,0 +1,31 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Walser Translation Team ml@translate-wae.ch
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'YYYY-MM-DD',
],
'months' => ['Jenner', 'Hornig', 'Märze', 'Abrille', 'Meije', 'Bráčet', 'Heiwet', 'Öigšte', 'Herbštmánet', 'Wímánet', 'Wintermánet', 'Chrištmánet'],
'months_short' => ['Jen', 'Hor', 'Mär', 'Abr', 'Mei', 'Brá', 'Hei', 'Öig', 'Her', 'Wím', 'Win', 'Chr'],
'weekdays' => ['Suntag', 'Mäntag', 'Zischtag', 'Mittwuch', 'Frontag', 'Fritag', 'Samschtag'],
'weekdays_short' => ['Sun', 'Män', 'Zis', 'Mit', 'Fro', 'Fri', 'Sam'],
'weekdays_min' => ['Sun', 'Män', 'Zis', 'Mit', 'Fro', 'Fri', 'Sam'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 4,
'month' => ':count Maano', // less reliable
'm' => ':count Maano', // less reliable
'a_month' => ':count Maano', // less reliable
]);
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/wal_ET.php';
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Ge'ez Frontier Foundation locales@geez.org
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'DD/MM/YYYY',
],
'months' => ['ጃንዩወሪ', 'ፌብሩወሪ', 'ማርች', 'ኤፕረል', 'ሜይ', 'ጁን', 'ጁላይ', 'ኦገስት', 'ሴፕቴምበር', 'ኦክተውበር', 'ኖቬምበር', 'ዲሴምበር'],
'months_short' => ['ጃንዩ', 'ፌብሩ', 'ማርች', 'ኤፕረ', 'ሜይ ', 'ጁን ', 'ጁላይ', 'ኦገስ', 'ሴፕቴ', 'ኦክተ', 'ኖቬም', 'ዲሴም'],
'weekdays' => ['ወጋ', 'ሳይኖ', 'ማቆሳኛ', 'አሩዋ', 'ሃሙሳ', 'አርባ', 'ቄራ'],
'weekdays_short' => ['ወጋ ', 'ሳይኖ', 'ማቆሳ', 'አሩዋ', 'ሃሙሳ', 'አርባ', 'ቄራ '],
'weekdays_min' => ['ወጋ ', 'ሳይኖ', 'ማቆሳ', 'አሩዋ', 'ሃሙሳ', 'አርባ', 'ቄራ '],
'first_day_of_week' => 0,
'day_of_first_week_of_year' => 1,
'meridiem' => ['ማለዶ', 'ቃማ'],
]);
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/wo_SN.php';
+39
View File
@@ -0,0 +1,39 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - The Debian Project Christian Perrier bubulle@debian.org
*/
return [
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD.MM.YYYY',
'LL' => 'MMMM DD, YYYY',
'LLL' => 'DD MMM HH:mm',
'LLLL' => 'MMMM DD, YYYY HH:mm',
],
'months' => ['sanwiy\'e', 'feebriy\'e', 'mars', 'awril', 'me', 'suwen', 'sulet', 'uut', 'septaambar', 'oktoobar', 'nowaambar', 'desaambar'],
'months_short' => ['san', 'fee', 'mar', 'awr', 'me ', 'suw', 'sul', 'uut', 'sep', 'okt', 'now', 'des'],
'weekdays' => ['dib\'eer', 'altine', 'talaata', 'allarba', 'alxames', 'ajjuma', 'gaawu'],
'weekdays_short' => ['dib', 'alt', 'tal', 'all', 'alx', 'ajj', 'gaa'],
'weekdays_min' => ['dib', 'alt', 'tal', 'all', 'alx', 'ajj', 'gaa'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 1,
'year' => ':count at',
'month' => ':count wèr',
'week' => ':count ayubés',
'day' => ':count bés',
'hour' => ':count waxtu',
'minute' => ':count simili',
'second' => ':count saa',
];
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/xh_ZA.php';
+55
View File
@@ -0,0 +1,55 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Zuza Software Foundation (Translate.org.za) Dwayne Bailey dwayne@translate.org.za
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'DD/MM/YYYY',
],
'months' => ['eyoMqungu', 'eyoMdumba', 'eyoKwindla', 'uTshazimpuzi', 'uCanzibe', 'eyeSilimela', 'eyeKhala', 'eyeThupa', 'eyoMsintsi', 'eyeDwarha', 'eyeNkanga', 'eyoMnga'],
'months_short' => ['Mqu', 'Mdu', 'Kwi', 'Tsh', 'Can', 'Sil', 'Kha', 'Thu', 'Msi', 'Dwa', 'Nka', 'Mng'],
'weekdays' => ['iCawa', 'uMvulo', 'lwesiBini', 'lwesiThathu', 'ulweSine', 'lwesiHlanu', 'uMgqibelo'],
'weekdays_short' => ['Caw', 'Mvu', 'Bin', 'Tha', 'Sin', 'Hla', 'Mgq'],
'weekdays_min' => ['Caw', 'Mvu', 'Bin', 'Tha', 'Sin', 'Hla', 'Mgq'],
'first_day_of_week' => 0,
'day_of_first_week_of_year' => 1,
'year' => ':count ihlobo', // less reliable
'y' => ':count ihlobo', // less reliable
'a_year' => ':count ihlobo', // less reliable
'hour' => ':count iwotshi', // less reliable
'h' => ':count iwotshi', // less reliable
'a_hour' => ':count iwotshi', // less reliable
'minute' => ':count ingqalelo', // less reliable
'min' => ':count ingqalelo', // less reliable
'a_minute' => ':count ingqalelo', // less reliable
'second' => ':count nceda', // less reliable
's' => ':count nceda', // less reliable
'a_second' => ':count nceda', // less reliable
'month' => ':count inyanga',
'm' => ':count inyanga',
'a_month' => ':count inyanga',
'week' => ':count veki',
'w' => ':count veki',
'a_week' => ':count veki',
'day' => ':count imini',
'd' => ':count imini',
'a_day' => ':count imini',
]);
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'meridiem' => ['Munkyo', 'Eigulo'],
'weekdays' => ['Sabiiti', 'Balaza', 'Owokubili', 'Owokusatu', 'Olokuna', 'Olokutaanu', 'Olomukaaga'],
'weekdays_short' => ['Sabi', 'Bala', 'Kubi', 'Kusa', 'Kuna', 'Kuta', 'Muka'],
'weekdays_min' => ['Sabi', 'Bala', 'Kubi', 'Kusa', 'Kuna', 'Kuta', 'Muka'],
'months' => ['Janwaliyo', 'Febwaliyo', 'Marisi', 'Apuli', 'Maayi', 'Juuni', 'Julaayi', 'Agusito', 'Sebuttemba', 'Okitobba', 'Novemba', 'Desemba'],
'months_short' => ['Jan', 'Feb', 'Mar', 'Apu', 'Maa', 'Juu', 'Jul', 'Agu', 'Seb', 'Oki', 'Nov', 'Des'],
'first_day_of_week' => 1,
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'dddd, D MMMM YYYY HH:mm',
],
]);
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'meridiem' => ['kiɛmɛ́ɛm', 'kisɛ́ndɛ'],
'weekdays' => ['sɔ́ndiɛ', 'móndie', 'muányáŋmóndie', 'metúkpíápɛ', 'kúpélimetúkpiapɛ', 'feléte', 'séselé'],
'weekdays_short' => ['sd', 'md', 'mw', 'et', 'kl', 'fl', 'ss'],
'weekdays_min' => ['sd', 'md', 'mw', 'et', 'kl', 'fl', 'ss'],
'months' => ['pikítíkítie, oólí ú kutúan', 'siɛyɛ́, oóli ú kándíɛ', 'ɔnsúmbɔl, oóli ú kátátúɛ', 'mesiŋ, oóli ú kénie', 'ensil, oóli ú kátánuɛ', 'ɔsɔn', 'efute', 'pisuyú', 'imɛŋ i puɔs', 'imɛŋ i putúk,oóli ú kátíɛ', 'makandikɛ', 'pilɔndɔ́'],
'months_short' => ['o.1', 'o.2', 'o.3', 'o.4', 'o.5', 'o.6', 'o.7', 'o.8', 'o.9', 'o.10', 'o.11', 'o.12'],
'first_day_of_week' => 1,
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'D/M/YYYY',
'LL' => 'D MMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'dddd D MMMM YYYY HH:mm',
],
]);
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/yi_US.php';
+55
View File
@@ -0,0 +1,55 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - http://www.uyip.org/ Pablo Saratxaga pablo@mandrakesoft.com
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'DD/MM/YY',
],
'months' => ['יאַנואַר', 'פֿעברואַר', 'מערץ', 'אַפּריל', 'מיי', 'יוני', 'יולי', 'אויגוסט', 'סעפּטעמבער', 'אקטאבער', 'נאוועמבער', 'דעצעמבער'],
'months_short' => ['יאַנ', 'פֿעב', 'מאַר', 'אַפּר', 'מײַ ', 'יונ', 'יול', 'אױג', 'סעפּ', 'אָקט', 'נאָװ', 'דעצ'],
'weekdays' => ['זונטיק', 'מאָנטיק', 'דינסטיק', 'מיטװאָך', 'דאָנערשטיק', 'פֿרײַטיק', 'שבת'],
'weekdays_short' => ['זונ\'', 'מאָנ\'', 'דינ\'', 'מיט\'', 'דאָנ\'', 'פֿרײַ\'', 'שבת'],
'weekdays_min' => ['זונ\'', 'מאָנ\'', 'דינ\'', 'מיט\'', 'דאָנ\'', 'פֿרײַ\'', 'שבת'],
'first_day_of_week' => 0,
'day_of_first_week_of_year' => 1,
'year' => ':count יאר',
'y' => ':count יאר',
'a_year' => ':count יאר',
'month' => ':count חודש',
'm' => ':count חודש',
'a_month' => ':count חודש',
'week' => ':count וואָך',
'w' => ':count וואָך',
'a_week' => ':count וואָך',
'day' => ':count טאָג',
'd' => ':count טאָג',
'a_day' => ':count טאָג',
'hour' => ':count שעה',
'h' => ':count שעה',
'a_hour' => ':count שעה',
'minute' => ':count מינוט',
'min' => ':count מינוט',
'a_minute' => ':count מינוט',
'second' => ':count סעקונדע',
's' => ':count סעקונדע',
'a_second' => ':count סעקונדע',
]);
+65
View File
@@ -0,0 +1,65 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - François B
* - Atolagbe Abisoye
*/
return [
'year' => 'ọdún :count',
'a_year' => '{1}ọdún kan|ọdún :count',
'month' => 'osù :count',
'a_month' => '{1}osù kan|osù :count',
'week' => 'ọsẹ :count',
'a_week' => '{1}ọsẹ kan|ọsẹ :count',
'day' => 'ọjọ́ :count',
'a_day' => '{1}ọjọ́ kan|ọjọ́ :count',
'hour' => 'wákati :count',
'a_hour' => '{1}wákati kan|wákati :count',
'minute' => 'ìsẹjú :count',
'a_minute' => '{1}ìsẹjú kan|ìsẹjú :count',
'second' => 'iaayá :count',
'a_second' => '{1}ìsẹjú aayá die|aayá :count',
'ago' => ':time kọjá',
'from_now' => 'ní :time',
'diff_yesterday' => 'Àna',
'diff_yesterday_regexp' => 'Àna(?:\\s+ni)?',
'diff_today' => 'Ònì',
'diff_today_regexp' => 'Ònì(?:\\s+ni)?',
'diff_tomorrow' => 'Ọ̀la',
'diff_tomorrow_regexp' => 'Ọ̀la(?:\\s+ni)?',
'formats' => [
'LT' => 'h:mm A',
'LTS' => 'h:mm:ss A',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMMM YYYY',
'LLL' => 'D MMMM YYYY h:mm A',
'LLLL' => 'dddd, D MMMM YYYY h:mm A',
],
'calendar' => [
'sameDay' => '[Ònì ni] LT',
'nextDay' => '[Ọ̀la ni] LT',
'nextWeek' => 'dddd [Ọsẹ̀ tón\'bọ] [ni] LT',
'lastDay' => '[Àna ni] LT',
'lastWeek' => 'dddd [Ọsẹ̀ tólọ́] [ni] LT',
'sameElse' => 'L',
],
'ordinal' => 'ọjọ́ :number',
'months' => ['Sẹ́rẹ́', 'Èrèlè', 'Ẹrẹ̀nà', 'Ìgbé', 'Èbibi', 'Òkùdu', 'Agẹmo', 'Ògún', 'Owewe', 'Ọ̀wàrà', 'Bélú', 'Ọ̀pẹ̀̀'],
'months_short' => ['Sẹ́r', 'Èrl', 'Ẹrn', 'Ìgb', 'Èbi', 'Òkù', 'Agẹ', 'Ògú', 'Owe', 'Ọ̀wà', 'Bél', 'Ọ̀pẹ̀̀'],
'weekdays' => ['Àìkú', 'Ajé', 'Ìsẹ́gun', 'Ọjọ́rú', 'Ọjọ́bọ', 'Ẹtì', 'Àbámẹ́ta'],
'weekdays_short' => ['Àìk', 'Ajé', 'Ìsẹ́', 'Ọjr', 'Ọjb', 'Ẹtì', 'Àbá'],
'weekdays_min' => ['Àì', 'Aj', 'Ìs', 'Ọr', 'Ọb', 'Ẹt', 'Àb'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 4,
'meridiem' => ['Àárọ̀', 'Ọ̀sán'],
];
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/yo.php', [
'meridiem' => ['Àárɔ̀', 'Ɔ̀sán'],
'weekdays' => ['Ɔjɔ́ Àìkú', 'Ɔjɔ́ Ajé', 'Ɔjɔ́ Ìsɛ́gun', 'Ɔjɔ́rú', 'Ɔjɔ́bɔ', 'Ɔjɔ́ Ɛtì', 'Ɔjɔ́ Àbámɛ́ta'],
'weekdays_short' => ['Àìkú', 'Ajé', 'Ìsɛ́gun', 'Ɔjɔ́rú', 'Ɔjɔ́bɔ', 'Ɛtì', 'Àbámɛ́ta'],
'weekdays_min' => ['Àìkú', 'Ajé', 'Ìsɛ́gun', 'Ɔjɔ́rú', 'Ɔjɔ́bɔ', 'Ɛtì', 'Àbámɛ́ta'],
'months' => ['Oshù Shɛ́rɛ́', 'Oshù Èrèlè', 'Oshù Ɛrɛ̀nà', 'Oshù Ìgbé', 'Oshù Ɛ̀bibi', 'Oshù Òkúdu', 'Oshù Agɛmɔ', 'Oshù Ògún', 'Oshù Owewe', 'Oshù Ɔ̀wàrà', 'Oshù Bélú', 'Oshù Ɔ̀pɛ̀'],
'months_short' => ['Shɛ́rɛ́', 'Èrèlè', 'Ɛrɛ̀nà', 'Ìgbé', 'Ɛ̀bibi', 'Òkúdu', 'Agɛmɔ', 'Ògún', 'Owewe', 'Ɔ̀wàrà', 'Bélú', 'Ɔ̀pɛ̀'],
'first_day_of_week' => 1,
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'dddd, D MMMM YYYY HH:mm',
],
]);
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/yo.php';
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/yue_HK.php';
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - bug-glibc-locales@gnu.org
*/
return array_replace_recursive(require __DIR__.'/zh_HK.php', [
'formats' => [
'L' => 'YYYY年MM月DD日 dddd',
],
'months' => ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
'months_short' => ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
'weekdays' => ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
'weekdays_short' => ['日', '一', '二', '三', '四', '五', '六'],
'weekdays_min' => ['日', '一', '二', '三', '四', '五', '六'],
'first_day_of_week' => 0,
'day_of_first_week_of_year' => 1,
'meridiem' => ['上午', '下午'],
]);
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/zh_Hans.php';
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/zh_Hant.php';
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/yuw_PG.php';
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Information from native speakers Hannah Sarvasy nungon.localization@gmail.com
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'DD/MM/YY',
],
'months' => ['jenuari', 'febuari', 'mas', 'epril', 'mei', 'jun', 'julai', 'ögus', 'septemba', 'öktoba', 'nöwemba', 'diksemba'],
'months_short' => ['jen', 'feb', 'mas', 'epr', 'mei', 'jun', 'jul', 'ögu', 'sep', 'ökt', 'nöw', 'dis'],
'weekdays' => ['sönda', 'mönda', 'sinda', 'mitiwö', 'sogipbono', 'nenggo', 'söndanggie'],
'weekdays_short' => ['sön', 'mön', 'sin', 'mit', 'soi', 'nen', 'sab'],
'weekdays_min' => ['sön', 'mön', 'sin', 'mit', 'soi', 'nen', 'sab'],
'first_day_of_week' => 0,
'day_of_first_week_of_year' => 1,
]);
+80
View File
@@ -0,0 +1,80 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - BAKTETE Miloud
*/
return [
'year' => ':count ⵓⵙⴳⴳⵯⴰⵙ|:count ⵉⵙⴳⴳⵓⵙⴰ',
'a_year' => 'ⵓⵙⴳⴳⵯⴰⵙ|:count ⵉⵙⴳⴳⵓⵙⴰ',
'y' => ':count ⵓⵙⴳⴳⵯⴰⵙ|:count ⵉⵙⴳⴳⵓⵙⴰ',
'month' => ':count ⵡⴰⵢⵢⵓⵔ|:count ⴰⵢⵢⵓⵔⵏ',
'a_month' => 'ⵉⴷⵊ ⵡⴰⵢⵢⵓⵔ|:count ⴰⵢⵢⵓⵔⵏ',
'm' => ':count ⴰⵢⵢⵓⵔⵏ',
'week' => ':count ⵉⵎⴰⵍⴰⵙⵙ|:count ⵉⵎⴰⵍⴰⵙⵙⵏ',
'a_week' => 'ⵉⵛⵜ ⵉⵎⴰⵍⴰⵙⵙ|:count ⵉⵎⴰⵍⴰⵙⵙⵏ',
'w' => ':count ⵉⵎⴰⵍⴰⵙⵙ.',
'day' => ':count ⵡⴰⵙⵙ|:count ⵓⵙⵙⴰⵏ',
'a_day' => 'ⵉⴷⵊ ⵡⴰⵙⵙ|:count ⵓⵙⵙⴰⵏ',
'd' => ':count ⵓ',
'hour' => ':count ⵜⵙⵔⴰⴳⵜ|:count ⵜⵉⵙⵔⴰⴳⵉⵏ',
'a_hour' => 'ⵉⵛⵜ ⵜⵙⵔⴰⴳⵜ|:count ⵜⵉⵙⵔⴰⴳⵉⵏ',
'h' => ':count ⵜ',
'minute' => ':count ⵜⵓⵙⴷⵉⴷⵜ|:count ⵜⵓⵙⴷⵉⴷⵉⵏ',
'a_minute' => 'ⵉⵛⵜ ⵜⵓⵙⴷⵉⴷⵜ|:count ⵜⵓⵙⴷⵉⴷⵉⵏ',
'min' => ':count ⵜⵓⵙ',
'second' => ':count ⵜⵙⵉⵏⵜ|:count ⵜⵉⵙⵉⵏⴰ',
'a_second' => 'ⴽⵔⴰ ⵜⵉⵙⵉⵏⴰ|:count ⵜⵉⵙⵉⵏⴰ',
's' => ':count ⵜ',
'ago' => 'ⵣⴳ :time',
'from_now' => 'ⴷⴳ :time',
'after' => ':time ⴰⵡⴰⵔ',
'before' => ':time ⴷⴰⵜ',
'diff_now' => 'ⴰⴷⵡⴰⵍⵉ',
'diff_today' => 'ⴰⵙⵙ',
'diff_today_regexp' => 'ⴰⵙⵙ(?:\\s+ⴰ/ⴰⴷ)?(?:\\s+ⴳ)?',
'diff_yesterday' => 'ⴰⵙⵙⵏⵏⴰⵟ',
'diff_yesterday_regexp' => 'ⴰⵙⵙⵏⵏⴰⵟ(?:\\s+ⴳ)?',
'diff_tomorrow' => 'ⴰⵙⴽⴽⴰ',
'diff_tomorrow_regexp' => 'ⴰⵙⴽⴽⴰ(?:\\s+ⴳ)?',
'diff_before_yesterday' => 'ⴼⵔ ⵉⴹⵏⵏⴰⵟ',
'diff_after_tomorrow' => 'ⵏⴰⴼ ⵓⵙⴽⴽⴰ',
'period_recurrences' => ':count ⵜⵉⴽⴽⴰⵍ',
'period_interval' => 'ⴽⵓ :interval',
'period_start_date' => 'ⴳ :date',
'period_end_date' => 'ⵉ :date',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'dddd D MMMM YYYY HH:mm',
],
'calendar' => [
'sameDay' => '[ⴰⵙⵙ ⴰ/ⴰⴷ ⴳ] LT',
'nextDay' => '[ⴰⵙⴽⴽⴰ ⴳ] LT',
'nextWeek' => 'dddd [ⴳ] LT',
'lastDay' => '[ⴰⵙⵙⵏⵏⴰⵟ ⴳ] LT',
'lastWeek' => 'dddd [ⴰⵎⴳⴳⴰⵔⵓ ⴳ] LT',
'sameElse' => 'L',
],
'meridiem' => ['ⵜⵉⴼⴰⵡⵜ', 'ⵜⴰⴷⴳⴳⵯⴰⵜ'],
'months' => ['ⵉⵏⵏⴰⵢⵔ', 'ⴱⵕⴰⵢⵕ', 'ⵎⴰⵕⵚ', 'ⵉⴱⵔⵉⵔ', 'ⵎⴰⵢⵢⵓ', 'ⵢⵓⵏⵢⵓ', 'ⵢⵓⵍⵢⵓⵣ', 'ⵖⵓⵛⵜ', 'ⵛⵓⵜⴰⵏⴱⵉⵔ', 'ⴽⵟⵓⴱⵕ', 'ⵏⵓⵡⴰⵏⴱⵉⵔ', 'ⴷⵓⵊⴰⵏⴱⵉⵔ'],
'months_short' => ['ⵉⵏⵏ', 'ⴱⵕⴰ', 'ⵎⴰⵕ', 'ⵉⴱⵔ', 'ⵎⴰⵢ', 'ⵢⵓⵏ', 'ⵢⵓⵍ', 'ⵖⵓⵛ', 'ⵛⵓⵜ', 'ⴽⵟⵓ', 'ⵏⵓⵡ', 'ⴷⵓⵊ'],
'weekdays' => ['ⵓⵙⴰⵎⴰⵙ', 'ⵡⴰⵢⵏⴰⵙ', 'ⵓⵙⵉⵏⴰⵙ', 'ⵡⴰⴽⵕⴰⵙ', 'ⵓⴽⵡⴰⵙ', 'ⵓⵙⵉⵎⵡⴰⵙ', 'ⵓⵙⵉⴹⵢⴰⵙ'],
'weekdays_short' => ['ⵓⵙⴰ', 'ⵡⴰⵢ', 'ⵓⵙⵉ', 'ⵡⴰⴽ', 'ⵓⴽⵡ', 'ⵓⵙⵉⵎ', 'ⵓⵙⵉⴹ'],
'weekdays_min' => ['ⵓⵙⴰ', 'ⵡⴰⵢ', 'ⵓⵙⵉ', 'ⵡⴰⴽ', 'ⵓⴽⵡ', 'ⵓⵙⵉⵎ', 'ⵓⵙⵉⴹ'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 1,
'list' => [', ', ' ⴷ '],
];
+29
View File
@@ -0,0 +1,29 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - xuri
* - sycuato
* - bokideckonja
* - Luo Ning
* - William Yang (williamyang233)
*/
return array_merge(require __DIR__.'/zh_Hans.php', [
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'YYYY/MM/DD',
'LL' => 'YYYY年M月D日',
'LLL' => 'YYYY年M月D日 A h点mm分',
'LLLL' => 'YYYY年M月D日dddd A h点mm分',
],
]);
+33
View File
@@ -0,0 +1,33 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - monkeycon
* - François B
* - Jason Katz-Brown
* - Serhan Apaydın
* - Matt Johnson
* - JD Isaacks
* - Zeno Zeng
* - Chris Hemp
* - shankesgk2
*/
return array_merge(require __DIR__.'/zh.php', [
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'YYYY/MM/DD',
'LL' => 'YYYY年M月D日',
'LLL' => 'YYYY年M月D日Ah点mm分',
'LLLL' => 'YYYY年M月D日ddddAh点mm分',
],
]);
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/zh_Hant_HK.php';
+102
View File
@@ -0,0 +1,102 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - monkeycon
* - François B
* - Jason Katz-Brown
* - Konstantin Konev
* - Chris Lam
* - Serhan Apaydın
* - Gary Lo
* - JD Isaacks
* - Chris Hemp
* - shankesgk2
* - Daniel Cheung (danvim)
*/
return [
'year' => ':count:optional-space年',
'y' => ':count:optional-space年',
'month' => ':count:optional-space个月',
'm' => ':count:optional-space个月',
'week' => ':count:optional-space周',
'w' => ':count:optional-space周',
'day' => ':count:optional-space天',
'd' => ':count:optional-space天',
'hour' => ':count:optional-space小时',
'h' => ':count:optional-space小时',
'minute' => ':count:optional-space分钟',
'min' => ':count:optional-space分钟',
'second' => ':count:optional-space秒',
'a_second' => '{1}几秒|]1,Inf[:count:optional-space秒',
's' => ':count:optional-space秒',
'ago' => ':time前',
'from_now' => ':time后',
'after' => ':time后',
'before' => ':time前',
'diff_now' => '现在',
'diff_today' => '今天',
'diff_yesterday' => '昨天',
'diff_tomorrow' => '明天',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'YYYY/MM/DD',
'LL' => 'YYYY年M月D日',
'LLL' => 'YYYY年M月D日 HH:mm',
'LLLL' => 'YYYY年M月D日dddd HH:mm',
],
'calendar' => [
'sameDay' => '[今天]LT',
'nextDay' => '[明天]LT',
'nextWeek' => '[下]ddddLT',
'lastDay' => '[昨天]LT',
'lastWeek' => '[上]ddddLT',
'sameElse' => 'L',
],
'ordinal' => static function ($number, $period) {
return match ($period) {
'd', 'D', 'DDD' => $number.'日',
'M' => $number.'月',
'w', 'W' => $number.'周',
default => $number,
};
},
'meridiem' => static function ($hour, $minute) {
$time = $hour * 100 + $minute;
if ($time < 600) {
return '凌晨';
}
if ($time < 900) {
return '早上';
}
if ($time < 1130) {
return '上午';
}
if ($time < 1230) {
return '中午';
}
if ($time < 1800) {
return '下午';
}
return '晚上';
},
'months' => ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
'months_short' => ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
'weekdays' => ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
'weekdays_short' => ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
'weekdays_min' => ['日', '一', '二', '三', '四', '五', '六'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 4,
'list' => '',
];
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/zh_Hans.php';
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/zh_Hans.php';
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/zh_Hans.php';
+104
View File
@@ -0,0 +1,104 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Adam
* - monkeycon
* - François B
* - Jason Katz-Brown
* - Chris Lam
* - Serhan Apaydın
* - Gary Lo
* - JD Isaacks
* - Chris Hemp
* - Eddie
* - KID
* - shankesgk2
* - Daniel Cheung (danvim)
*/
return [
'year' => ':count:optional-space年',
'y' => ':count:optional-space年',
'month' => ':count:optional-space個月',
'm' => ':count:optional-space月',
'week' => ':count:optional-space週',
'w' => ':count:optional-space週',
'day' => ':count:optional-space天',
'd' => ':count:optional-space天',
'hour' => ':count:optional-space小時',
'h' => ':count:optional-space小時',
'minute' => ':count:optional-space分鐘',
'min' => ':count:optional-space分鐘',
'second' => ':count:optional-space秒',
'a_second' => '{1}幾秒|]1,Inf[:count:optional-space秒',
's' => ':count:optional-space秒',
'ago' => ':time前',
'from_now' => ':time後',
'after' => ':time後',
'before' => ':time前',
'diff_now' => '現在',
'diff_today' => '今天',
'diff_yesterday' => '昨天',
'diff_tomorrow' => '明天',
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'YYYY/MM/DD',
'LL' => 'YYYY年M月D日',
'LLL' => 'YYYY年M月D日 HH:mm',
'LLLL' => 'YYYY年M月D日dddd HH:mm',
],
'calendar' => [
'sameDay' => '[今天] LT',
'nextDay' => '[明天] LT',
'nextWeek' => '[下]dddd LT',
'lastDay' => '[昨天] LT',
'lastWeek' => '[上]dddd LT',
'sameElse' => 'L',
],
'ordinal' => static function ($number, $period) {
return match ($period) {
'd', 'D', 'DDD' => $number.'日',
'M' => $number.'月',
'w', 'W' => $number.'周',
default => $number,
};
},
'meridiem' => static function ($hour, $minute) {
$time = $hour * 100 + $minute;
if ($time < 600) {
return '凌晨';
}
if ($time < 900) {
return '早上';
}
if ($time < 1130) {
return '上午';
}
if ($time < 1230) {
return '中午';
}
if ($time < 1800) {
return '下午';
}
return '晚上';
},
'months' => ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
'months_short' => ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
'weekdays' => ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
'weekdays_short' => ['週日', '週一', '週二', '週三', '週四', '週五', '週六'],
'weekdays_min' => ['日', '一', '二', '三', '四', '五', '六'],
'first_day_of_week' => 1,
'day_of_first_week_of_year' => 4,
'list' => '',
];
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/zh_Hant.php';
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/zh_Hant.php';
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/zh_Hant.php';
+21
View File
@@ -0,0 +1,21 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - tarunvelli
* - Eddie
* - KID
* - shankesgk2
*/
return array_replace_recursive(require __DIR__.'/zh_Hant.php', [
'after' => ':time后',
]);
+26
View File
@@ -0,0 +1,26 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
*/
return array_replace_recursive(require __DIR__.'/zh.php', [
'formats' => [
'L' => 'YYYY年MM月DD日',
],
'months' => ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
'months_short' => ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
'weekdays' => ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
'weekdays_short' => ['日', '一', '二', '三', '四', '五', '六'],
'weekdays_min' => ['日', '一', '二', '三', '四', '五', '六'],
'day_of_first_week_of_year' => 1,
]);
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return require __DIR__.'/zh_Hant_TW.php';
+20
View File
@@ -0,0 +1,20 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - IBM Globalization Center of Competency, Yamato Software Laboratory bug-glibc-locales@gnu.org
*/
return array_replace_recursive(require __DIR__.'/zh.php', [
'formats' => [
'L' => 'YYYY-MM-DD',
],
]);
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Unknown default region, use the first alphabetically.
*/
return require __DIR__.'/zu_ZA.php';
+55
View File
@@ -0,0 +1,55 @@
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Authors:
* - Zuza Software Foundation (Translate.org.za) Dwayne Bailey dwayne@translate.org.za
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'formats' => [
'L' => 'DD/MM/YYYY',
],
'months' => ['Januwari', 'Februwari', 'Mashi', 'Ephreli', 'Meyi', 'Juni', 'Julayi', 'Agasti', 'Septhemba', 'Okthoba', 'Novemba', 'Disemba'],
'months_short' => ['Jan', 'Feb', 'Mas', 'Eph', 'Mey', 'Jun', 'Jul', 'Aga', 'Sep', 'Okt', 'Nov', 'Dis'],
'weekdays' => ['iSonto', 'uMsombuluko', 'uLwesibili', 'uLwesithathu', 'uLwesine', 'uLwesihlanu', 'uMgqibelo'],
'weekdays_short' => ['Son', 'Mso', 'Bil', 'Tha', 'Sin', 'Hla', 'Mgq'],
'weekdays_min' => ['Son', 'Mso', 'Bil', 'Tha', 'Sin', 'Hla', 'Mgq'],
'first_day_of_week' => 0,
'day_of_first_week_of_year' => 1,
'year' => 'kweminyaka engu-:count',
'y' => 'kweminyaka engu-:count',
'a_year' => 'kweminyaka engu-:count',
'month' => 'izinyanga ezingu-:count',
'm' => 'izinyanga ezingu-:count',
'a_month' => 'izinyanga ezingu-:count',
'week' => 'lwamasonto angu-:count',
'w' => 'lwamasonto angu-:count',
'a_week' => 'lwamasonto angu-:count',
'day' => 'ezingaba ngu-:count',
'd' => 'ezingaba ngu-:count',
'a_day' => 'ezingaba ngu-:count',
'hour' => 'amahora angu-:count',
'h' => 'amahora angu-:count',
'a_hour' => 'amahora angu-:count',
'minute' => 'ngemizuzu engu-:count',
'min' => 'ngemizuzu engu-:count',
'a_minute' => 'ngemizuzu engu-:count',
'second' => 'imizuzwana engu-:count',
's' => 'imizuzwana engu-:count',
'a_second' => 'imizuzwana engu-:count',
]);
+271
View File
@@ -0,0 +1,271 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use JsonSerializable;
class Language implements JsonSerializable
{
protected static ?array $languagesNames = null;
protected static ?array $regionsNames = null;
protected string $id;
protected string $code;
protected ?string $variant = null;
protected ?string $region = null;
protected ?array $names = null;
protected ?string $isoName = null;
protected ?string $nativeName = null;
public function __construct(string $id)
{
$this->id = str_replace('-', '_', $id);
$parts = explode('_', $this->id);
$this->code = $parts[0];
if (isset($parts[1])) {
if (!preg_match('/^[A-Z]+$/', $parts[1])) {
$this->variant = $parts[1];
$parts[1] = $parts[2] ?? null;
}
if ($parts[1]) {
$this->region = $parts[1];
}
}
}
/**
* Get the list of the known languages.
*
* @return array
*/
public static function all(): array
{
static::$languagesNames ??= require __DIR__.'/List/languages.php';
return static::$languagesNames;
}
/**
* Get the list of the known regions.
*
* ⚠ ISO 3166-2 short name provided with no warranty, should not
* be used for any purpose to show official state names.
*/
public static function regions(): array
{
static::$regionsNames ??= require __DIR__.'/List/regions.php';
return static::$regionsNames;
}
/**
* Get both isoName and nativeName as an array.
*/
public function getNames(): array
{
$this->names ??= static::all()[$this->code] ?? [
'isoName' => $this->code,
'nativeName' => $this->code,
];
return $this->names;
}
/**
* Returns the original locale ID.
*/
public function getId(): string
{
return $this->id;
}
/**
* Returns the code of the locale "en"/"fr".
*/
public function getCode(): string
{
return $this->code;
}
/**
* Returns the variant code such as cyrl/latn.
*/
public function getVariant(): ?string
{
return $this->variant;
}
/**
* Returns the variant such as Cyrillic/Latin.
*/
public function getVariantName(): ?string
{
if ($this->variant === 'Latn') {
return 'Latin';
}
if ($this->variant === 'Cyrl') {
return 'Cyrillic';
}
return $this->variant;
}
/**
* Returns the region part of the locale.
*/
public function getRegion(): ?string
{
return $this->region;
}
/**
* Returns the region name for the current language.
*
* ⚠ ISO 3166-2 short name provided with no warranty, should not
* be used for any purpose to show official state names.
*/
public function getRegionName(): ?string
{
return $this->region ? (static::regions()[$this->region] ?? $this->region) : null;
}
/**
* Returns the long ISO language name.
*/
public function getFullIsoName(): string
{
$this->isoName ??= $this->getNames()['isoName'];
return $this->isoName;
}
/**
* Set the ISO language name.
*/
public function setIsoName(string $isoName): static
{
$this->isoName = $isoName;
return $this;
}
/**
* Return the full name of the language in this language.
*/
public function getFullNativeName(): string
{
$this->nativeName ??= $this->getNames()['nativeName'];
return $this->nativeName;
}
/**
* Set the name of the language in this language.
*/
public function setNativeName(string $nativeName): static
{
$this->nativeName = $nativeName;
return $this;
}
/**
* Returns the short ISO language name.
*/
public function getIsoName(): string
{
$name = $this->getFullIsoName();
return trim(strstr($name, ',', true) ?: $name);
}
/**
* Get the short name of the language in this language.
*/
public function getNativeName(): string
{
$name = $this->getFullNativeName();
return trim(strstr($name, ',', true) ?: $name);
}
/**
* Get a string with short ISO name, region in parentheses if applicable, variant in parentheses if applicable.
*/
public function getIsoDescription(): string
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
}
/**
* Get a string with short native name, region in parentheses if applicable, variant in parentheses if applicable.
*/
public function getNativeDescription(): string
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
}
/**
* Get a string with long ISO name, region in parentheses if applicable, variant in parentheses if applicable.
*/
public function getFullIsoDescription(): string
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getFullIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
}
/**
* Get a string with long native name, region in parentheses if applicable, variant in parentheses if applicable.
*/
public function getFullNativeDescription(): string
{
$region = $this->getRegionName();
$variant = $this->getVariantName();
return $this->getFullNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : '');
}
/**
* Returns the original locale ID.
*/
public function __toString(): string
{
return $this->getId();
}
/**
* Get a string with short ISO name, region in parentheses if applicable, variant in parentheses if applicable.
*/
public function jsonSerialize(): string
{
return $this->getIsoDescription();
}
}
@@ -0,0 +1,129 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Laravel;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterval;
use Carbon\CarbonPeriod;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Events\Dispatcher;
use Illuminate\Events\EventDispatcher;
use Illuminate\Support\Carbon as IlluminateCarbon;
use Illuminate\Support\Facades\Date;
use Throwable;
class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
/** @var callable|null */
protected $appGetter = null;
/** @var callable|null */
protected $localeGetter = null;
public function setAppGetter(?callable $appGetter): void
{
$this->appGetter = $appGetter;
}
public function setLocaleGetter(?callable $localeGetter): void
{
$this->localeGetter = $localeGetter;
}
public function boot()
{
$this->updateLocale();
if (!$this->app->bound('events')) {
return;
}
$service = $this;
$events = $this->app['events'];
if ($this->isEventDispatcher($events)) {
$events->listen(class_exists('Illuminate\Foundation\Events\LocaleUpdated') ? 'Illuminate\Foundation\Events\LocaleUpdated' : 'locale.changed', function () use ($service) {
$service->updateLocale();
});
}
}
public function updateLocale()
{
$locale = $this->getLocale();
if ($locale === null) {
return;
}
Carbon::setLocale($locale);
CarbonImmutable::setLocale($locale);
CarbonPeriod::setLocale($locale);
CarbonInterval::setLocale($locale);
if (class_exists(IlluminateCarbon::class)) {
IlluminateCarbon::setLocale($locale);
}
if (class_exists(Date::class)) {
try {
$root = Date::getFacadeRoot();
$root->setLocale($locale);
} catch (Throwable) {
// Non Carbon class in use in Date facade
}
}
}
public function register()
{
// Needed for Laravel < 5.3 compatibility
}
protected function getLocale()
{
if ($this->localeGetter) {
return ($this->localeGetter)();
}
$app = $this->getApp();
$app = $app && method_exists($app, 'getLocale')
? $app
: $this->getGlobalApp('translator');
return $app ? $app->getLocale() : null;
}
protected function getApp()
{
if ($this->appGetter) {
return ($this->appGetter)();
}
return $this->app ?? $this->getGlobalApp();
}
protected function getGlobalApp(...$args)
{
return \function_exists('app') ? \app(...$args) : null;
}
protected function isEventDispatcher($instance)
{
return $instance instanceof EventDispatcher
|| $instance instanceof Dispatcher
|| $instance instanceof DispatcherContract;
}
}
File diff suppressed because it is too large Load Diff
+292
View File
@@ -0,0 +1,292 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* ISO 3166-2 short names.
*
* ⚠ Provided with No Warranty
*
* This list has no official value, and it's using short name, i.e. the first column of
* https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
*
* Without the extra parenthesis unless a particular ambiguity in the list.
*
* For instance:
* - Falkland Islands and Malvinas both to FK, but we keep only the first for brevity and
* because there is no ambiguity in the list to justify longer name.
* - For Sint Maarten/Saint Martin not to have any confusion between FM and SX codes that
* are on the same island and so to be clear it's not referring to the whole island,
* south (dutch-speaking) and north (french-speaking) parentheses are kept for disambiguation.
* - For Virgin Islands, that can refer to either VG or VI, parentheses are also kept for
* disambiguation.
*
* We won't take into consideration any change request in this list unless there is an update
* in ISO 3166-2 itself that we need to align to.
*
* It's a purely geographical helper, state sovereignty is out of scope, for political
* complains you should address them directly to https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
*
* Anyone needing official state names (such as the second column of the wikipedia page above)
* should seek for another tool, this list is not meant to provide long names.
*/
return [
'AD' => 'Andorra',
'AE' => 'United Arab Emirates',
'AF' => 'Afghanistan',
'AG' => 'Antigua and Barbuda',
'AI' => 'Anguilla',
'AL' => 'Albania',
'AM' => 'Armenia',
'AO' => 'Angola',
'AQ' => 'Antarctica',
'AR' => 'Argentina',
'AS' => 'American Samoa',
'AT' => 'Austria',
'AU' => 'Australia',
'AW' => 'Aruba',
'AX' => 'Åland Islands',
'AZ' => 'Azerbaijan',
'BA' => 'Bosnia and Herzegovina',
'BB' => 'Barbados',
'BD' => 'Bangladesh',
'BE' => 'Belgium',
'BF' => 'Burkina Faso',
'BG' => 'Bulgaria',
'BH' => 'Bahrain',
'BI' => 'Burundi',
'BJ' => 'Benin',
'BL' => 'Saint Barthélemy',
'BM' => 'Bermuda',
'BN' => 'Brunei Darussalam',
'BO' => 'Bolivia',
'BQ' => 'Bonaire, Sint Eustatius and Saba',
'BR' => 'Brazil',
'BS' => 'Bahamas',
'BT' => 'Bhutan',
'BV' => 'Bouvet Island',
'BW' => 'Botswana',
'BY' => 'Belarus',
'BZ' => 'Belize',
'CA' => 'Canada',
'CC' => 'Cocos (Keeling) Islands',
'CD' => 'Congo, Democratic Republic of the',
'CF' => 'Central African Republic',
'CG' => 'Congo',
'CH' => 'Switzerland',
'CI' => 'Côte d\'Ivoire',
'CK' => 'Cook Islands',
'CL' => 'Chile',
'CM' => 'Cameroon',
'CN' => 'China',
'CO' => 'Colombia',
'CR' => 'Costa Rica',
'CU' => 'Cuba',
'CV' => 'Cabo Verde',
'CW' => 'Curaçao',
'CX' => 'Christmas Island',
'CY' => 'Cyprus',
'CZ' => 'Czechia',
'DE' => 'Germany',
'DJ' => 'Djibouti',
'DK' => 'Denmark',
'DM' => 'Dominica',
'DO' => 'Dominican Republic',
'DZ' => 'Algeria',
'EC' => 'Ecuador',
'EE' => 'Estonia',
'EG' => 'Egypt',
'EH' => 'Western Sahara',
'ER' => 'Eritrea',
'ES' => 'Spain',
'ET' => 'Ethiopia',
'FI' => 'Finland',
'FJ' => 'Fiji',
'FK' => 'Falkland Islands',
'FM' => 'Micronesia',
'FO' => 'Faroe Islands',
'FR' => 'France',
'GA' => 'Gabon',
'GB' => 'United Kingdom of Great Britain and Northern Ireland',
'GD' => 'Grenada',
'GE' => 'Georgia',
'GF' => 'French Guiana',
'GG' => 'Guernsey',
'GH' => 'Ghana',
'GI' => 'Gibraltar',
'GL' => 'Greenland',
'GM' => 'Gambia',
'GN' => 'Guinea',
'GP' => 'Guadeloupe',
'GQ' => 'Equatorial Guinea',
'GR' => 'Greece',
'GS' => 'South Georgia and the South Sandwich Islands',
'GT' => 'Guatemala',
'GU' => 'Guam',
'GW' => 'Guinea-Bissau',
'GY' => 'Guyana',
'HK' => 'Hong Kong',
'HM' => 'Heard Island and McDonald Islands',
'HN' => 'Honduras',
'HR' => 'Croatia',
'HT' => 'Haiti',
'HU' => 'Hungary',
'ID' => 'Indonesia',
'IE' => 'Ireland',
'IL' => 'Israel',
'IM' => 'Isle of Man',
'IN' => 'India',
'IO' => 'British Indian Ocean Territory',
'IQ' => 'Iraq',
'IR' => 'Iran',
'IS' => 'Iceland',
'IT' => 'Italy',
'JE' => 'Jersey',
'JM' => 'Jamaica',
'JO' => 'Jordan',
'JP' => 'Japan',
'KE' => 'Kenya',
'KG' => 'Kyrgyzstan',
'KH' => 'Cambodia',
'KI' => 'Kiribati',
'KM' => 'Comoros',
'KN' => 'Saint Kitts and Nevis',
'KP' => 'Korea (Democratic People\'s Republic of)',
'KR' => 'Korea, Republic of',
'KW' => 'Kuwait',
'KY' => 'Cayman Islands',
'KZ' => 'Kazakhstan',
'LA' => 'Lao People\'s Democratic Republic',
'LB' => 'Lebanon',
'LC' => 'Saint Lucia',
'LI' => 'Liechtenstein',
'LK' => 'Sri Lanka',
'LR' => 'Liberia',
'LS' => 'Lesotho',
'LT' => 'Lithuania',
'LU' => 'Luxembourg',
'LV' => 'Latvia',
'LY' => 'Libya',
'MA' => 'Morocco',
'MC' => 'Monaco',
'MD' => 'Moldova',
'ME' => 'Montenegro',
'MF' => 'Saint Martin (French part)',
'MG' => 'Madagascar',
'MH' => 'Marshall Islands',
'MK' => 'North Macedonia',
'ML' => 'Mali',
'MM' => 'Myanmar',
'MN' => 'Mongolia',
'MO' => 'Macao',
'MP' => 'Northern Mariana Islands',
'MQ' => 'Martinique',
'MR' => 'Mauritania',
'MS' => 'Montserrat',
'MT' => 'Malta',
'MU' => 'Mauritius',
'MV' => 'Maldives',
'MW' => 'Malawi',
'MX' => 'Mexico',
'MY' => 'Malaysia',
'MZ' => 'Mozambique',
'NA' => 'Namibia',
'NC' => 'New Caledonia',
'NE' => 'Niger',
'NF' => 'Norfolk Island',
'NG' => 'Nigeria',
'NI' => 'Nicaragua',
'NL' => 'Netherlands',
'NO' => 'Norway',
'NP' => 'Nepal',
'NR' => 'Nauru',
'NU' => 'Niue',
'NZ' => 'New Zealand',
'OM' => 'Oman',
'PA' => 'Panama',
'PE' => 'Peru',
'PF' => 'French Polynesia',
'PG' => 'Papua New Guinea',
'PH' => 'Philippines',
'PK' => 'Pakistan',
'PL' => 'Poland',
'PM' => 'Saint Pierre and Miquelon',
'PN' => 'Pitcairn',
'PR' => 'Puerto Rico',
'PS' => 'Palestine',
'PT' => 'Portugal',
'PW' => 'Palau',
'PY' => 'Paraguay',
'QA' => 'Qatar',
'RE' => 'Réunion',
'RO' => 'Romania',
'RS' => 'Serbia',
'RU' => 'Russian Federation',
'RW' => 'Rwanda',
'SA' => 'Saudi Arabia',
'SB' => 'Solomon Islands',
'SC' => 'Seychelles',
'SD' => 'Sudan',
'SE' => 'Sweden',
'SG' => 'Singapore',
'SH' => 'Saint Helena, Ascension and Tristan da Cunha',
'SI' => 'Slovenia',
'SJ' => 'Svalbard and Jan Mayen',
'SK' => 'Slovakia',
'SL' => 'Sierra Leone',
'SM' => 'San Marino',
'SN' => 'Senegal',
'SO' => 'Somalia',
'SR' => 'Suriname',
'SS' => 'South Sudan',
'ST' => 'Sao Tome and Principe',
'SV' => 'El Salvador',
'SX' => 'Sint Maarten (Dutch part)',
'SY' => 'Syrian Arab Republic',
'SZ' => 'Eswatini',
'TC' => 'Turks and Caicos Islands',
'TD' => 'Chad',
'TF' => 'French Southern Territories',
'TG' => 'Togo',
'TH' => 'Thailand',
'TJ' => 'Tajikistan',
'TK' => 'Tokelau',
'TL' => 'Timor-Leste',
'TM' => 'Turkmenistan',
'TN' => 'Tunisia',
'TO' => 'Tonga',
'TR' => 'Turkey',
'TT' => 'Trinidad and Tobago',
'TV' => 'Tuvalu',
'TW' => 'Taiwan',
'TZ' => 'Tanzania',
'UA' => 'Ukraine',
'UG' => 'Uganda',
'UM' => 'United States Minor Outlying Islands',
'US' => 'United States of America',
'UY' => 'Uruguay',
'UZ' => 'Uzbekistan',
'VA' => 'Holy See',
'VC' => 'Saint Vincent and the Grenadines',
'VE' => 'Venezuela',
'VG' => 'Virgin Islands (British)',
'VI' => 'Virgin Islands (U.S.)',
'VN' => 'Viet Nam',
'VU' => 'Vanuatu',
'WF' => 'Wallis and Futuna',
'WS' => 'Samoa',
'YE' => 'Yemen',
'YT' => 'Mayotte',
'ZA' => 'South Africa',
'ZM' => 'Zambia',
'ZW' => 'Zimbabwe',
];
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\MessageFormatter;
use ReflectionMethod;
use Symfony\Component\Translation\Formatter\MessageFormatter;
use Symfony\Component\Translation\Formatter\MessageFormatterInterface;
// @codeCoverageIgnoreStart
$transMethod = new ReflectionMethod(MessageFormatterInterface::class, 'format');
require $transMethod->getParameters()[0]->hasType()
? __DIR__.'/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperStrongType.php'
: __DIR__.'/../../../lazy/Carbon/MessageFormatter/MessageFormatterMapperWeakType.php';
// @codeCoverageIgnoreEnd
final class MessageFormatterMapper extends LazyMessageFormatter
{
/**
* Wrapped formatter.
*
* @var MessageFormatterInterface
*/
protected $formatter;
public function __construct(?MessageFormatterInterface $formatter = null)
{
$this->formatter = $formatter ?? new MessageFormatter();
}
protected function transformLocale(?string $locale): ?string
{
return $locale ? preg_replace('/[_@][A-Za-z][a-z]{2,}/', '', $locale) : $locale;
}
}
+79
View File
@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon;
use Carbon\Exceptions\InvalidFormatException;
enum Month: int
{
// Using constants is only safe starting from PHP 8.2
case January = 1; // CarbonInterface::JANUARY
case February = 2; // CarbonInterface::FEBRUARY
case March = 3; // CarbonInterface::MARCH
case April = 4; // CarbonInterface::APRIL
case May = 5; // CarbonInterface::MAY
case June = 6; // CarbonInterface::JUNE
case July = 7; // CarbonInterface::JULY
case August = 8; // CarbonInterface::AUGUST
case September = 9; // CarbonInterface::SEPTEMBER
case October = 10; // CarbonInterface::OCTOBER
case November = 11; // CarbonInterface::NOVEMBER
case December = 12; // CarbonInterface::DECEMBER
public static function int(self|int|null $value): ?int
{
return $value instanceof self ? $value->value : $value;
}
public static function fromNumber(int $number): self
{
$month = $number % CarbonInterface::MONTHS_PER_YEAR;
return self::from($month + ($month < 1 ? CarbonInterface::MONTHS_PER_YEAR : 0));
}
public static function fromName(string $name, ?string $locale = null): self
{
try {
return self::from(CarbonImmutable::parseFromLocale("$name 1", $locale)->month);
} catch (InvalidFormatException $exception) {
// Possibly current language expect a dot after short name, but it's missing
if ($locale !== null && !mb_strlen($name) < 4 && !str_ends_with($name, '.')) {
try {
return self::from(CarbonImmutable::parseFromLocale("$name. 1", $locale)->month);
} catch (InvalidFormatException $e) {
// Throw previous error
}
}
throw $exception;
}
}
public function ofTheYear(CarbonImmutable|int|null $now = null): CarbonImmutable
{
if (\is_int($now)) {
return CarbonImmutable::create($now, $this->value);
}
$modifier = $this->name.' 1st';
return $now?->modify($modifier) ?? new CarbonImmutable($modifier);
}
public function locale(string $locale, ?CarbonImmutable $now = null): CarbonImmutable
{
return $this->ofTheYear($now)->locale($locale);
}
}
@@ -0,0 +1,137 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\PHPStan;
use Carbon\CarbonInterface;
use Carbon\FactoryImmutable;
use Closure;
use InvalidArgumentException;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\MethodsClassReflectionExtension;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\ClosureTypeFactory;
use ReflectionFunction;
use ReflectionMethod;
use stdClass;
use Throwable;
/**
* Class MacroExtension.
*
* @codeCoverageIgnore Pure PHPStan wrapper.
*/
final class MacroExtension implements MethodsClassReflectionExtension
{
/**
* @var ReflectionProvider
*/
protected $reflectionProvider;
/**
* @var ClosureTypeFactory
*/
protected $closureTypeFactory;
/**
* Extension constructor.
*
* @param ReflectionProvider $reflectionProvider
* @param ClosureTypeFactory $closureTypeFactory
*/
public function __construct(
ReflectionProvider $reflectionProvider,
ClosureTypeFactory $closureTypeFactory
) {
$this->reflectionProvider = $reflectionProvider;
$this->closureTypeFactory = $closureTypeFactory;
}
/**
* {@inheritdoc}
*/
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
{
if (
$classReflection->getName() !== CarbonInterface::class &&
!$classReflection->isSubclassOf(CarbonInterface::class)
) {
return false;
}
$className = $classReflection->getName();
return \is_callable([$className, 'hasMacro']) &&
$className::hasMacro($methodName);
}
/**
* {@inheritdoc}
*/
public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
{
$macros = FactoryImmutable::getDefaultInstance()->getSettings()['macros'] ?? [];
$macro = $macros[$methodName] ?? throw new InvalidArgumentException("Macro '$methodName' not found");
$static = false;
$final = false;
$deprecated = false;
$docComment = null;
if (\is_array($macro) && \count($macro) === 2 && \is_string($macro[1])) {
\assert($macro[1] !== '');
$reflection = new ReflectionMethod($macro[0], $macro[1]);
$closure = \is_object($macro[0]) ? $reflection->getClosure($macro[0]) : $reflection->getClosure();
$static = $reflection->isStatic();
$final = $reflection->isFinal();
$deprecated = $reflection->isDeprecated();
$docComment = $reflection->getDocComment() ?: null;
} elseif (\is_string($macro)) {
$reflection = new ReflectionFunction($macro);
$closure = $reflection->getClosure();
$deprecated = $reflection->isDeprecated();
$docComment = $reflection->getDocComment() ?: null;
} elseif ($macro instanceof Closure) {
$closure = $macro;
try {
$boundClosure = Closure::bind($closure, new stdClass());
$static = (!$boundClosure || (new ReflectionFunction($boundClosure))->getClosureThis() === null);
} catch (Throwable) {
$static = true;
}
$reflection = new ReflectionFunction($macro);
$deprecated = $reflection->isDeprecated();
$docComment = $reflection->getDocComment() ?: null;
}
if (!isset($closure)) {
throw new InvalidArgumentException('Could not create reflection from the spec given'); // @codeCoverageIgnore
}
$closureType = $this->closureTypeFactory->fromClosureObject($closure);
return new MacroMethodReflection(
$classReflection,
$methodName,
$closureType,
$static,
$final,
$deprecated,
$docComment,
);
}
}
@@ -0,0 +1,124 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\PHPStan;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ParametersAcceptor;
use PHPStan\TrinaryLogic;
use PHPStan\Type\Type;
use function preg_match;
class MacroMethodReflection implements MethodReflection
{
private ClassReflection $declaringClass;
private string $methodName;
private ParametersAcceptor $macroClosureType;
private bool $static;
private bool $final;
private bool $deprecated;
private ?string $docComment;
public function __construct(
ClassReflection $declaringClass,
string $methodName,
ParametersAcceptor $macroClosureType,
bool $static,
bool $final,
bool $deprecated,
?string $docComment
) {
$this->declaringClass = $declaringClass;
$this->methodName = $methodName;
$this->macroClosureType = $macroClosureType;
$this->static = $static;
$this->final = $final;
$this->deprecated = $deprecated;
$this->docComment = $docComment;
}
public function getDeclaringClass(): ClassReflection
{
return $this->declaringClass;
}
public function isStatic(): bool
{
return $this->static;
}
public function isPrivate(): bool
{
return false;
}
public function isPublic(): bool
{
return true;
}
public function getDocComment(): ?string
{
return $this->docComment;
}
public function getName(): string
{
return $this->methodName;
}
public function getPrototype(): \PHPStan\Reflection\ClassMemberReflection
{
return $this;
}
public function getVariants(): array
{
return [$this->macroClosureType];
}
public function isDeprecated(): TrinaryLogic
{
return TrinaryLogic::createFromBoolean(
$this->deprecated ||
preg_match('/@deprecated/i', $this->getDocComment() ?: '')
);
}
public function getDeprecatedDescription(): ?string
{
return null;
}
public function isFinal(): TrinaryLogic
{
return TrinaryLogic::createFromBoolean($this->final);
}
public function isInternal(): TrinaryLogic
{
return TrinaryLogic::createNo();
}
public function getThrowType(): ?Type
{
return null;
}
public function hasSideEffects(): TrinaryLogic
{
return TrinaryLogic::createMaybe();
}
}
+469
View File
@@ -0,0 +1,469 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\Exceptions\UnknownUnitException;
use Carbon\Unit;
use Carbon\WeekDay;
/**
* Trait Boundaries.
*
* startOf, endOf and derived method for each unit.
*
* Depends on the following properties:
*
* @property int $year
* @property int $month
* @property int $daysInMonth
* @property int $quarter
*
* Depends on the following methods:
*
* @method $this setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0)
* @method $this setDate(int $year, int $month, int $day)
* @method $this addMonths(int $value = 1)
*/
trait Boundaries
{
/**
* Resets the time to 00:00:00 start of day
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->startOfDay();
* ```
*
* @return static
*/
public function startOfDay()
{
return $this->setTime(0, 0, 0, 0);
}
/**
* Resets the time to 23:59:59.999999 end of day
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->endOfDay();
* ```
*
* @return static
*/
public function endOfDay()
{
return $this->setTime(static::HOURS_PER_DAY - 1, static::MINUTES_PER_HOUR - 1, static::SECONDS_PER_MINUTE - 1, static::MICROSECONDS_PER_SECOND - 1);
}
/**
* Resets the date to the first day of the month and the time to 00:00:00
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->startOfMonth();
* ```
*
* @return static
*/
public function startOfMonth()
{
return $this->setDate($this->year, $this->month, 1)->startOfDay();
}
/**
* Resets the date to end of the month and time to 23:59:59.999999
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->endOfMonth();
* ```
*
* @return static
*/
public function endOfMonth()
{
return $this->setDate($this->year, $this->month, $this->daysInMonth)->endOfDay();
}
/**
* Resets the date to the first day of the quarter and the time to 00:00:00
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->startOfQuarter();
* ```
*
* @return static
*/
public function startOfQuarter()
{
$month = ($this->quarter - 1) * static::MONTHS_PER_QUARTER + 1;
return $this->setDate($this->year, $month, 1)->startOfDay();
}
/**
* Resets the date to end of the quarter and time to 23:59:59.999999
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->endOfQuarter();
* ```
*
* @return static
*/
public function endOfQuarter()
{
return $this->startOfQuarter()->addMonths(static::MONTHS_PER_QUARTER - 1)->endOfMonth();
}
/**
* Resets the date to the first day of the year and the time to 00:00:00
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->startOfYear();
* ```
*
* @return static
*/
public function startOfYear()
{
return $this->setDate($this->year, 1, 1)->startOfDay();
}
/**
* Resets the date to end of the year and time to 23:59:59.999999
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->endOfYear();
* ```
*
* @return static
*/
public function endOfYear()
{
return $this->setDate($this->year, 12, 31)->endOfDay();
}
/**
* Resets the date to the first day of the decade and the time to 00:00:00
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->startOfDecade();
* ```
*
* @return static
*/
public function startOfDecade()
{
$year = $this->year - $this->year % static::YEARS_PER_DECADE;
return $this->setDate($year, 1, 1)->startOfDay();
}
/**
* Resets the date to end of the decade and time to 23:59:59.999999
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->endOfDecade();
* ```
*
* @return static
*/
public function endOfDecade()
{
$year = $this->year - $this->year % static::YEARS_PER_DECADE + static::YEARS_PER_DECADE - 1;
return $this->setDate($year, 12, 31)->endOfDay();
}
/**
* Resets the date to the first day of the century and the time to 00:00:00
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->startOfCentury();
* ```
*
* @return static
*/
public function startOfCentury()
{
$year = $this->year - ($this->year - 1) % static::YEARS_PER_CENTURY;
return $this->setDate($year, 1, 1)->startOfDay();
}
/**
* Resets the date to end of the century and time to 23:59:59.999999
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->endOfCentury();
* ```
*
* @return static
*/
public function endOfCentury()
{
$year = $this->year - 1 - ($this->year - 1) % static::YEARS_PER_CENTURY + static::YEARS_PER_CENTURY;
return $this->setDate($year, 12, 31)->endOfDay();
}
/**
* Resets the date to the first day of the millennium and the time to 00:00:00
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->startOfMillennium();
* ```
*
* @return static
*/
public function startOfMillennium()
{
$year = $this->year - ($this->year - 1) % static::YEARS_PER_MILLENNIUM;
return $this->setDate($year, 1, 1)->startOfDay();
}
/**
* Resets the date to end of the millennium and time to 23:59:59.999999
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->endOfMillennium();
* ```
*
* @return static
*/
public function endOfMillennium()
{
$year = $this->year - 1 - ($this->year - 1) % static::YEARS_PER_MILLENNIUM + static::YEARS_PER_MILLENNIUM;
return $this->setDate($year, 12, 31)->endOfDay();
}
/**
* Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->startOfWeek() . "\n";
* echo Carbon::parse('2018-07-25 12:45:16')->locale('ar')->startOfWeek() . "\n";
* echo Carbon::parse('2018-07-25 12:45:16')->startOfWeek(Carbon::SUNDAY) . "\n";
* ```
*
* @param WeekDay|int|null $weekStartsAt optional start allow you to specify the day of week to use to start the week
*
* @return static
*/
public function startOfWeek(WeekDay|int|null $weekStartsAt = null): static
{
return $this
->subDays(
(static::DAYS_PER_WEEK + $this->dayOfWeek - (WeekDay::int($weekStartsAt) ?? $this->firstWeekDay)) %
static::DAYS_PER_WEEK,
)
->startOfDay();
}
/**
* Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59.999999
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->endOfWeek() . "\n";
* echo Carbon::parse('2018-07-25 12:45:16')->locale('ar')->endOfWeek() . "\n";
* echo Carbon::parse('2018-07-25 12:45:16')->endOfWeek(Carbon::SATURDAY) . "\n";
* ```
*
* @param WeekDay|int|null $weekEndsAt optional end allow you to specify the day of week to use to end the week
*
* @return static
*/
public function endOfWeek(WeekDay|int|null $weekEndsAt = null): static
{
return $this
->addDays(
(static::DAYS_PER_WEEK - $this->dayOfWeek + (WeekDay::int($weekEndsAt) ?? $this->lastWeekDay)) %
static::DAYS_PER_WEEK,
)
->endOfDay();
}
/**
* Modify to start of current hour, minutes and seconds become 0
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->startOfHour();
* ```
*/
public function startOfHour(): static
{
return $this->setTime($this->hour, 0, 0, 0);
}
/**
* Modify to end of current hour, minutes and seconds become 59
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->endOfHour();
* ```
*/
public function endOfHour(): static
{
return $this->setTime($this->hour, static::MINUTES_PER_HOUR - 1, static::SECONDS_PER_MINUTE - 1, static::MICROSECONDS_PER_SECOND - 1);
}
/**
* Modify to start of current minute, seconds become 0
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->startOfMinute();
* ```
*/
public function startOfMinute(): static
{
return $this->setTime($this->hour, $this->minute, 0, 0);
}
/**
* Modify to end of current minute, seconds become 59
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16')->endOfMinute();
* ```
*/
public function endOfMinute(): static
{
return $this->setTime($this->hour, $this->minute, static::SECONDS_PER_MINUTE - 1, static::MICROSECONDS_PER_SECOND - 1);
}
/**
* Modify to start of current second, microseconds become 0
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16.334455')
* ->startOfSecond()
* ->format('H:i:s.u');
* ```
*/
public function startOfSecond(): static
{
return $this->setTime($this->hour, $this->minute, $this->second, 0);
}
/**
* Modify to end of current second, microseconds become 999999
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16.334455')
* ->endOfSecond()
* ->format('H:i:s.u');
* ```
*/
public function endOfSecond(): static
{
return $this->setTime($this->hour, $this->minute, $this->second, static::MICROSECONDS_PER_SECOND - 1);
}
/**
* Modify to start of current millisecond, microseconds such as 12345 become 123000
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16.334455')
* ->startOfSecond()
* ->format('H:i:s.u');
* ```
*/
public function startOfMillisecond(): static
{
$millisecond = (int) floor($this->micro / 1000);
return $this->setTime($this->hour, $this->minute, $this->second, $millisecond * 1000);
}
/**
* Modify to end of current millisecond, microseconds such as 12345 become 123999
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16.334455')
* ->endOfSecond()
* ->format('H:i:s.u');
* ```
*/
public function endOfMillisecond(): static
{
$millisecond = (int) floor($this->micro / 1000);
return $this->setTime($this->hour, $this->minute, $this->second, $millisecond * 1000 + 999);
}
/**
* Modify to start of current given unit.
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16.334455')
* ->startOf(Unit::Month)
* ->endOf(Unit::Week, Carbon::FRIDAY);
* ```
*/
public function startOf(Unit|string $unit, mixed ...$params): static
{
$ucfUnit = ucfirst($unit instanceof Unit ? $unit->value : static::singularUnit($unit));
$method = "startOf$ucfUnit";
if (!method_exists($this, $method)) {
throw new UnknownUnitException($unit);
}
return $this->$method(...$params);
}
/**
* Modify to end of current given unit.
*
* @example
* ```
* echo Carbon::parse('2018-07-25 12:45:16.334455')
* ->startOf(Unit::Month)
* ->endOf(Unit::Week, Carbon::FRIDAY);
* ```
*/
public function endOf(Unit|string $unit, mixed ...$params): static
{
$ucfUnit = ucfirst($unit instanceof Unit ? $unit->value : static::singularUnit($unit));
$method = "endOf$ucfUnit";
if (!method_exists($this, $method)) {
throw new UnknownUnitException($unit);
}
return $this->$method(...$params);
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\Exceptions\InvalidCastException;
use DateTimeInterface;
/**
* Trait Cast.
*
* Utils to cast into an other class.
*/
trait Cast
{
/**
* Cast the current instance into the given class.
*
* @template T
*
* @param class-string<T> $className The $className::instance() method will be called to cast the current object.
*
* @return T
*/
public function cast(string $className): mixed
{
if (!method_exists($className, 'instance')) {
if (is_a($className, DateTimeInterface::class, true)) {
return $className::createFromFormat('U.u', $this->rawFormat('U.u'))
->setTimezone($this->getTimezone());
}
throw new InvalidCastException("$className has not the instance() method needed to cast the date.");
}
return $className::instance($this);
}
}
File diff suppressed because it is too large Load Diff
+556
View File
@@ -0,0 +1,556 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
use Carbon\CarbonInterval;
use Carbon\CarbonPeriod;
use Carbon\CarbonPeriodImmutable;
use Carbon\Exceptions\UnitException;
use Closure;
use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
/**
* Trait Converter.
*
* Change date into different string formats and types and
* handle the string cast.
*
* Depends on the following methods:
*
* @method static copy()
*/
trait Converter
{
use ToStringFormat;
/**
* Returns the formatted date string on success or FALSE on failure.
*
* @see https://php.net/manual/en/datetime.format.php
*/
public function format(string $format): string
{
$function = $this->localFormatFunction
?? $this->getFactory()->getSettings()['formatFunction']
?? static::$formatFunction;
if (!$function) {
return $this->rawFormat($format);
}
if (\is_string($function) && method_exists($this, $function)) {
$function = [$this, $function];
}
return $function(...\func_get_args());
}
/**
* @see https://php.net/manual/en/datetime.format.php
*/
public function rawFormat(string $format): string
{
return parent::format($format);
}
/**
* Format the instance as a string using the set format
*
* @example
* ```
* echo Carbon::now(); // Carbon instances can be cast to string
* ```
*/
public function __toString(): string
{
$format = $this->localToStringFormat
?? $this->getFactory()->getSettings()['toStringFormat']
?? null;
return $format instanceof Closure
? $format($this)
: $this->rawFormat($format ?: (
\defined('static::DEFAULT_TO_STRING_FORMAT')
? static::DEFAULT_TO_STRING_FORMAT
: CarbonInterface::DEFAULT_TO_STRING_FORMAT
));
}
/**
* Format the instance as date
*
* @example
* ```
* echo Carbon::now()->toDateString();
* ```
*/
public function toDateString(): string
{
return $this->rawFormat('Y-m-d');
}
/**
* Format the instance as a readable date
*
* @example
* ```
* echo Carbon::now()->toFormattedDateString();
* ```
*/
public function toFormattedDateString(): string
{
return $this->rawFormat('M j, Y');
}
/**
* Format the instance with the day, and a readable date
*
* @example
* ```
* echo Carbon::now()->toFormattedDayDateString();
* ```
*/
public function toFormattedDayDateString(): string
{
return $this->rawFormat('D, M j, Y');
}
/**
* Format the instance as time
*
* @example
* ```
* echo Carbon::now()->toTimeString();
* ```
*/
public function toTimeString(string $unitPrecision = 'second'): string
{
return $this->rawFormat(static::getTimeFormatByPrecision($unitPrecision));
}
/**
* Format the instance as date and time
*
* @example
* ```
* echo Carbon::now()->toDateTimeString();
* ```
*/
public function toDateTimeString(string $unitPrecision = 'second'): string
{
return $this->rawFormat('Y-m-d '.static::getTimeFormatByPrecision($unitPrecision));
}
/**
* Return a format from H:i to H:i:s.u according to given unit precision.
*
* @param string $unitPrecision "minute", "second", "millisecond" or "microsecond"
*/
public static function getTimeFormatByPrecision(string $unitPrecision): string
{
return match (static::singularUnit($unitPrecision)) {
'minute' => 'H:i',
'second' => 'H:i:s',
'm', 'millisecond' => 'H:i:s.v',
'µ', 'microsecond' => 'H:i:s.u',
default => throw new UnitException('Precision unit expected among: minute, second, millisecond and microsecond.'),
};
}
/**
* Format the instance as date and time T-separated with no timezone
*
* @example
* ```
* echo Carbon::now()->toDateTimeLocalString();
* echo "\n";
* echo Carbon::now()->toDateTimeLocalString('minute'); // You can specify precision among: minute, second, millisecond and microsecond
* ```
*/
public function toDateTimeLocalString(string $unitPrecision = 'second'): string
{
return $this->rawFormat('Y-m-d\T'.static::getTimeFormatByPrecision($unitPrecision));
}
/**
* Format the instance with day, date and time
*
* @example
* ```
* echo Carbon::now()->toDayDateTimeString();
* ```
*/
public function toDayDateTimeString(): string
{
return $this->rawFormat('D, M j, Y g:i A');
}
/**
* Format the instance as ATOM
*
* @example
* ```
* echo Carbon::now()->toAtomString();
* ```
*/
public function toAtomString(): string
{
return $this->rawFormat(DateTime::ATOM);
}
/**
* Format the instance as COOKIE
*
* @example
* ```
* echo Carbon::now()->toCookieString();
* ```
*/
public function toCookieString(): string
{
return $this->rawFormat(DateTimeInterface::COOKIE);
}
/**
* Format the instance as ISO8601
*
* @example
* ```
* echo Carbon::now()->toIso8601String();
* ```
*/
public function toIso8601String(): string
{
return $this->toAtomString();
}
/**
* Format the instance as RFC822
*
* @example
* ```
* echo Carbon::now()->toRfc822String();
* ```
*/
public function toRfc822String(): string
{
return $this->rawFormat(DateTimeInterface::RFC822);
}
/**
* Convert the instance to UTC and return as Zulu ISO8601
*
* @example
* ```
* echo Carbon::now()->toIso8601ZuluString();
* ```
*/
public function toIso8601ZuluString(string $unitPrecision = 'second'): string
{
return $this->avoidMutation()
->utc()
->rawFormat('Y-m-d\T'.static::getTimeFormatByPrecision($unitPrecision).'\Z');
}
/**
* Format the instance as RFC850
*
* @example
* ```
* echo Carbon::now()->toRfc850String();
* ```
*/
public function toRfc850String(): string
{
return $this->rawFormat(DateTimeInterface::RFC850);
}
/**
* Format the instance as RFC1036
*
* @example
* ```
* echo Carbon::now()->toRfc1036String();
* ```
*/
public function toRfc1036String(): string
{
return $this->rawFormat(DateTimeInterface::RFC1036);
}
/**
* Format the instance as RFC1123
*
* @example
* ```
* echo Carbon::now()->toRfc1123String();
* ```
*/
public function toRfc1123String(): string
{
return $this->rawFormat(DateTimeInterface::RFC1123);
}
/**
* Format the instance as RFC2822
*
* @example
* ```
* echo Carbon::now()->toRfc2822String();
* ```
*/
public function toRfc2822String(): string
{
return $this->rawFormat(DateTimeInterface::RFC2822);
}
/**
* Format the instance as RFC3339.
*
* @example
* ```
* echo Carbon::now()->toRfc3339String() . "\n";
* echo Carbon::now()->toRfc3339String(true) . "\n";
* ```
*/
public function toRfc3339String(bool $extended = false): string
{
return $this->rawFormat($extended ? DateTimeInterface::RFC3339_EXTENDED : DateTimeInterface::RFC3339);
}
/**
* Format the instance as RSS
*
* @example
* ```
* echo Carbon::now()->toRssString();
* ```
*/
public function toRssString(): string
{
return $this->rawFormat(DateTimeInterface::RSS);
}
/**
* Format the instance as W3C
*
* @example
* ```
* echo Carbon::now()->toW3cString();
* ```
*/
public function toW3cString(): string
{
return $this->rawFormat(DateTimeInterface::W3C);
}
/**
* Format the instance as RFC7231
*
* @example
* ```
* echo Carbon::now()->toRfc7231String();
* ```
*/
public function toRfc7231String(): string
{
return $this->avoidMutation()
->setTimezone('GMT')
->rawFormat(\defined('static::RFC7231_FORMAT') ? static::RFC7231_FORMAT : CarbonInterface::RFC7231_FORMAT);
}
/**
* Get default array representation.
*
* @example
* ```
* var_dump(Carbon::now()->toArray());
* ```
*/
public function toArray(): array
{
return [
'year' => $this->year,
'month' => $this->month,
'day' => $this->day,
'dayOfWeek' => $this->dayOfWeek,
'dayOfYear' => $this->dayOfYear,
'hour' => $this->hour,
'minute' => $this->minute,
'second' => $this->second,
'micro' => $this->micro,
'timestamp' => $this->timestamp,
'formatted' => $this->rawFormat(\defined('static::DEFAULT_TO_STRING_FORMAT') ? static::DEFAULT_TO_STRING_FORMAT : CarbonInterface::DEFAULT_TO_STRING_FORMAT),
'timezone' => $this->timezone,
];
}
/**
* Get default object representation.
*
* @example
* ```
* var_dump(Carbon::now()->toObject());
* ```
*/
public function toObject(): object
{
return (object) $this->toArray();
}
/**
* Returns english human-readable complete date string.
*
* @example
* ```
* echo Carbon::now()->toString();
* ```
*/
public function toString(): string
{
return $this->avoidMutation()->locale('en')->isoFormat('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
}
/**
* Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z, if $keepOffset truthy, offset will be kept:
* 1977-04-22T01:00:00-05:00).
*
* @example
* ```
* echo Carbon::now('America/Toronto')->toISOString() . "\n";
* echo Carbon::now('America/Toronto')->toISOString(true) . "\n";
* ```
*
* @param bool $keepOffset Pass true to keep the date offset. Else forced to UTC.
*/
public function toISOString(bool $keepOffset = false): ?string
{
if (!$this->isValid()) {
return null;
}
$yearFormat = $this->year < 0 || $this->year > 9999 ? 'YYYYYY' : 'YYYY';
$timezoneFormat = $keepOffset ? 'Z' : '[Z]';
$date = $keepOffset ? $this : $this->avoidMutation()->utc();
return $date->isoFormat("$yearFormat-MM-DD[T]HH:mm:ss.SSSSSS$timezoneFormat");
}
/**
* Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z) with UTC timezone.
*
* @example
* ```
* echo Carbon::now('America/Toronto')->toJSON();
* ```
*/
public function toJSON(): ?string
{
return $this->toISOString();
}
/**
* Return native DateTime PHP object matching the current instance.
*
* @example
* ```
* var_dump(Carbon::now()->toDateTime());
* ```
*/
public function toDateTime(): DateTime
{
return DateTime::createFromFormat('U.u', $this->rawFormat('U.u'))
->setTimezone($this->getTimezone());
}
/**
* Return native toDateTimeImmutable PHP object matching the current instance.
*
* @example
* ```
* var_dump(Carbon::now()->toDateTimeImmutable());
* ```
*/
public function toDateTimeImmutable(): DateTimeImmutable
{
return DateTimeImmutable::createFromFormat('U.u', $this->rawFormat('U.u'))
->setTimezone($this->getTimezone());
}
/**
* @alias toDateTime
*
* Return native DateTime PHP object matching the current instance.
*
* @example
* ```
* var_dump(Carbon::now()->toDate());
* ```
*/
public function toDate(): DateTime
{
return $this->toDateTime();
}
/**
* Create a iterable CarbonPeriod object from current date to a given end date (and optional interval).
*
* @param \DateTimeInterface|Carbon|CarbonImmutable|int|null $end period end date or recurrences count if int
* @param int|\DateInterval|string|null $interval period default interval or number of the given $unit
* @param string|null $unit if specified, $interval must be an integer
*/
public function toPeriod($end = null, $interval = null, $unit = null): CarbonPeriod
{
if ($unit) {
$interval = CarbonInterval::make("$interval ".static::pluralUnit($unit));
}
$isDefaultInterval = !$interval;
$interval ??= CarbonInterval::day();
$class = $this->isMutable() ? CarbonPeriod::class : CarbonPeriodImmutable::class;
if (\is_int($end) || (\is_string($end) && ctype_digit($end))) {
$end = (int) $end;
}
$end ??= 1;
if (!\is_int($end)) {
$end = $this->resolveCarbon($end);
}
return new $class(
raw: [$this, CarbonInterval::make($interval), $end],
dateClass: static::class,
isDefaultInterval: $isDefaultInterval,
);
}
/**
* Create a iterable CarbonPeriod object from current date to a given end date (and optional interval).
*
* @param \DateTimeInterface|Carbon|CarbonImmutable|null $end period end date
* @param int|\DateInterval|string|null $interval period default interval or number of the given $unit
* @param string|null $unit if specified, $interval must be an integer
*/
public function range($end = null, $interval = null, $unit = null): CarbonPeriod
{
return $this->toPeriod($end, $interval, $unit);
}
}
+938
View File
@@ -0,0 +1,938 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
use Carbon\Exceptions\InvalidDateException;
use Carbon\Exceptions\InvalidFormatException;
use Carbon\Exceptions\InvalidTimeZoneException;
use Carbon\Exceptions\OutOfRangeException;
use Carbon\Exceptions\UnitException;
use Carbon\Month;
use Carbon\Translator;
use Carbon\WeekDay;
use Closure;
use DateMalformedStringException;
use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
use Exception;
use ReturnTypeWillChange;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Trait Creator.
*
* Static creators.
*
* Depends on the following methods:
*
* @method static Carbon|CarbonImmutable getTestNow()
*/
trait Creator
{
use ObjectInitialisation;
use LocalFactory;
/**
* The errors that can occur.
*/
protected static ?array $lastErrors = null;
/**
* Create a new Carbon instance.
*
* Please see the testing aids section (specifically static::setTestNow())
* for more on the possibility of this constructor returning a test instance.
*
* @throws InvalidFormatException
*/
public function __construct(
DateTimeInterface|WeekDay|Month|string|int|float|null $time = null,
DateTimeZone|string|int|null $timezone = null,
) {
$this->initLocalFactory();
if ($time instanceof Month) {
$time = $time->name.' 1';
} elseif ($time instanceof WeekDay) {
$time = $time->name;
} elseif ($time instanceof DateTimeInterface) {
$time = $this->constructTimezoneFromDateTime($time, $timezone)->format('Y-m-d H:i:s.u');
}
if (\is_string($time) && str_starts_with($time, '@')) {
$time = static::createFromTimestampUTC(substr($time, 1))->format('Y-m-d\TH:i:s.uP');
} elseif (is_numeric($time) && (!\is_string($time) || !preg_match('/^\d{1,14}$/', $time))) {
$time = static::createFromTimestampUTC($time)->format('Y-m-d\TH:i:s.uP');
}
// If the class has a test now set, and we are trying to create a now()
// instance then override as required
$isNow = \in_array($time, [null, '', 'now'], true);
$timezone = static::safeCreateDateTimeZone($timezone) ?? null;
if (
($this->clock || (
method_exists(static::class, 'hasTestNow') &&
method_exists(static::class, 'getTestNow') &&
static::hasTestNow()
)) &&
($isNow || static::hasRelativeKeywords($time))
) {
$this->mockConstructorParameters($time, $timezone);
}
try {
parent::__construct($time ?? 'now', $timezone);
} catch (Exception $exception) {
throw new InvalidFormatException($exception->getMessage(), 0, $exception);
}
$this->constructedObjectId = spl_object_hash($this);
self::setLastErrors(parent::getLastErrors());
}
/**
* Get timezone from a datetime instance.
*/
private function constructTimezoneFromDateTime(
DateTimeInterface $date,
DateTimeZone|string|int|null &$timezone,
): DateTimeInterface {
if ($timezone !== null) {
$safeTz = static::safeCreateDateTimeZone($timezone);
if ($safeTz) {
$date = ($date instanceof DateTimeImmutable ? $date : clone $date)->setTimezone($safeTz);
}
return $date;
}
$timezone = $date->getTimezone();
return $date;
}
/**
* Update constructedObjectId on cloned.
*/
public function __clone(): void
{
$this->constructedObjectId = spl_object_hash($this);
}
/**
* Create a Carbon instance from a DateTime one.
*/
public static function instance(DateTimeInterface $date): static
{
if ($date instanceof static) {
return clone $date;
}
$instance = parent::createFromFormat('U.u', $date->format('U.u'))
->setTimezone($date->getTimezone());
if ($date instanceof CarbonInterface) {
$settings = $date->getSettings();
if (!$date->hasLocalTranslator()) {
unset($settings['locale']);
}
$instance->settings($settings);
}
return $instance;
}
/**
* Create a carbon instance from a string.
*
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
*
* @throws InvalidFormatException
*/
public static function rawParse(
DateTimeInterface|WeekDay|Month|string|int|float|null $time,
DateTimeZone|string|int|null $timezone = null,
): static {
if ($time instanceof DateTimeInterface) {
return static::instance($time);
}
try {
return new static($time, $timezone);
} catch (Exception $exception) {
// @codeCoverageIgnoreStart
try {
$date = @static::now($timezone)->change($time);
} catch (DateMalformedStringException|InvalidFormatException) {
$date = null;
}
// @codeCoverageIgnoreEnd
return $date
?? throw new InvalidFormatException("Could not parse '$time': ".$exception->getMessage(), 0, $exception);
}
}
/**
* Create a carbon instance from a string.
*
* This is an alias for the constructor that allows better fluent syntax
* as it allows you to do Carbon::parse('Monday next week')->fn() rather
* than (new Carbon('Monday next week'))->fn().
*
* @throws InvalidFormatException
*/
public static function parse(
DateTimeInterface|WeekDay|Month|string|int|float|null $time,
DateTimeZone|string|int|null $timezone = null,
): static {
$function = static::$parseFunction;
if (!$function) {
return static::rawParse($time, $timezone);
}
if (\is_string($function) && method_exists(static::class, $function)) {
$function = [static::class, $function];
}
return $function(...\func_get_args());
}
/**
* Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
*
* @param string $time date/time string in the given language (may also contain English).
* @param string|null $locale if locale is null or not specified, current global locale will be
* used instead.
* @param DateTimeZone|string|int|null $timezone optional timezone for the new instance.
*
* @throws InvalidFormatException
*/
public static function parseFromLocale(
string $time,
?string $locale = null,
DateTimeZone|string|int|null $timezone = null,
): static {
return static::rawParse(static::translateTimeString($time, $locale, static::DEFAULT_LOCALE), $timezone);
}
/**
* Get a Carbon instance for the current date and time.
*/
public static function now(DateTimeZone|string|int|null $timezone = null): static
{
return new static(null, $timezone);
}
/**
* Create a Carbon instance for today.
*/
public static function today(DateTimeZone|string|int|null $timezone = null): static
{
return static::rawParse('today', $timezone);
}
/**
* Create a Carbon instance for tomorrow.
*/
public static function tomorrow(DateTimeZone|string|int|null $timezone = null): static
{
return static::rawParse('tomorrow', $timezone);
}
/**
* Create a Carbon instance for yesterday.
*/
public static function yesterday(DateTimeZone|string|int|null $timezone = null): static
{
return static::rawParse('yesterday', $timezone);
}
private static function assertBetween($unit, $value, $min, $max): void
{
if (static::isStrictModeEnabled() && ($value < $min || $value > $max)) {
throw new OutOfRangeException($unit, $min, $max, $value);
}
}
private static function createNowInstance($timezone)
{
if (!static::hasTestNow()) {
return static::now($timezone);
}
$now = static::getTestNow();
if ($now instanceof Closure) {
return $now(static::now($timezone));
}
$now = $now->avoidMutation();
return $timezone === null ? $now : $now->setTimezone($timezone);
}
/**
* Create a new Carbon instance from a specific date and time.
*
* If any of $year, $month or $day are set to null their now() values will
* be used.
*
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
*
* If $hour is not null then the default values for $minute and $second
* will be 0.
*
* @param DateTimeInterface|string|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|int|null $timezone
*
* @throws InvalidFormatException
*
* @return static|null
*/
public static function create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $timezone = null): ?self
{
$month = self::monthToInt($month);
if ((\is_string($year) && !is_numeric($year)) || $year instanceof DateTimeInterface) {
return static::parse($year, $timezone ?? (\is_string($month) || $month instanceof DateTimeZone ? $month : null));
}
$defaults = null;
$getDefault = function ($unit) use ($timezone, &$defaults) {
if ($defaults === null) {
$now = self::createNowInstance($timezone);
$defaults = array_combine([
'year',
'month',
'day',
'hour',
'minute',
'second',
], explode('-', $now->rawFormat('Y-n-j-G-i-s.u')));
}
return $defaults[$unit];
};
$year = $year ?? $getDefault('year');
$month = $month ?? $getDefault('month');
$day = $day ?? $getDefault('day');
$hour = $hour ?? $getDefault('hour');
$minute = $minute ?? $getDefault('minute');
$second = (float) ($second ?? $getDefault('second'));
self::assertBetween('month', $month, 0, 99);
self::assertBetween('day', $day, 0, 99);
self::assertBetween('hour', $hour, 0, 99);
self::assertBetween('minute', $minute, 0, 99);
self::assertBetween('second', $second, 0, 99);
$fixYear = null;
if ($year < 0) {
$fixYear = $year;
$year = 0;
} elseif ($year > 9999) {
$fixYear = $year - 9999;
$year = 9999;
}
$second = ($second < 10 ? '0' : '').number_format($second, 6);
$instance = static::rawCreateFromFormat('!Y-n-j G:i:s.u', \sprintf('%s-%s-%s %s:%02s:%02s', $year, $month, $day, $hour, $minute, $second), $timezone);
if ($instance && $fixYear !== null) {
$instance = $instance->addYears($fixYear);
}
return $instance ?? null;
}
/**
* Create a new safe Carbon instance from a specific date and time.
*
* If any of $year, $month or $day are set to null their now() values will
* be used.
*
* If $hour is null it will be set to its now() value and the default
* values for $minute and $second will be their now() values.
*
* If $hour is not null then the default values for $minute and $second
* will be 0.
*
* If one of the set values is not valid, an InvalidDateException
* will be thrown.
*
* @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|int|null $timezone
*
* @throws InvalidDateException
*
* @return static|null
*/
public static function createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null): ?self
{
$month = self::monthToInt($month);
$fields = static::getRangesByUnit();
foreach ($fields as $field => $range) {
if ($$field !== null && (!\is_int($$field) || $$field < $range[0] || $$field > $range[1])) {
if (static::isStrictModeEnabled()) {
throw new InvalidDateException($field, $$field);
}
return null;
}
}
$instance = static::create($year, $month, $day, $hour, $minute, $second, $timezone);
foreach (array_reverse($fields) as $field => $range) {
if ($$field !== null && (!\is_int($$field) || $$field !== $instance->$field)) {
if (static::isStrictModeEnabled()) {
throw new InvalidDateException($field, $$field);
}
return null;
}
}
return $instance;
}
/**
* Create a new Carbon instance from a specific date and time using strict validation.
*
* @see create()
*
* @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|int|null $timezone
*
* @throws InvalidFormatException
*
* @return static
*/
public static function createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $timezone = null): static
{
$initialStrictMode = static::isStrictModeEnabled();
static::useStrictMode(true);
try {
$date = static::create($year, $month, $day, $hour, $minute, $second, $timezone);
} finally {
static::useStrictMode($initialStrictMode);
}
return $date;
}
/**
* Create a Carbon instance from just a date. The time portion is set to now.
*
* @param int|null $year
* @param int|null $month
* @param int|null $day
* @param DateTimeZone|string|int|null $timezone
*
* @throws InvalidFormatException
*
* @return static
*/
public static function createFromDate($year = null, $month = null, $day = null, $timezone = null)
{
return static::create($year, $month, $day, null, null, null, $timezone);
}
/**
* Create a Carbon instance from just a date. The time portion is set to midnight.
*
* @param int|null $year
* @param int|null $month
* @param int|null $day
* @param DateTimeZone|string|int|null $timezone
*
* @throws InvalidFormatException
*
* @return static
*/
public static function createMidnightDate($year = null, $month = null, $day = null, $timezone = null)
{
return static::create($year, $month, $day, 0, 0, 0, $timezone);
}
/**
* Create a Carbon instance from just a time. The date portion is set to today.
*
* @param int|null $hour
* @param int|null $minute
* @param int|null $second
* @param DateTimeZone|string|int|null $timezone
*
* @throws InvalidFormatException
*
* @return static
*/
public static function createFromTime($hour = 0, $minute = 0, $second = 0, $timezone = null): static
{
return static::create(null, null, null, $hour, $minute, $second, $timezone);
}
/**
* Create a Carbon instance from a time string. The date portion is set to today.
*
* @throws InvalidFormatException
*/
public static function createFromTimeString(string $time, DateTimeZone|string|int|null $timezone = null): static
{
return static::today($timezone)->setTimeFromTimeString($time);
}
private static function createFromFormatAndTimezone(
string $format,
string $time,
DateTimeZone|string|int|null $originalTimezone,
): ?DateTimeInterface {
if ($originalTimezone === null) {
return parent::createFromFormat($format, $time) ?: null;
}
$timezone = \is_int($originalTimezone) ? self::getOffsetTimezone($originalTimezone) : $originalTimezone;
$timezone = static::safeCreateDateTimeZone($timezone, $originalTimezone);
return parent::createFromFormat($format, $time, $timezone) ?: null;
}
private static function getOffsetTimezone(int $offset): string
{
$minutes = (int) ($offset * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE);
return @timezone_name_from_abbr('', $minutes, 1) ?: throw new InvalidTimeZoneException(
"Invalid offset timezone $offset",
);
}
/**
* Create a Carbon instance from a specific format.
*
* @param string $format Datetime format
* @param string $time
* @param DateTimeZone|string|int|null $timezone
*
* @throws InvalidFormatException
*
* @return static|null
*/
public static function rawCreateFromFormat(string $format, string $time, $timezone = null): ?self
{
// Work-around for https://bugs.php.net/bug.php?id=80141
$format = preg_replace('/(?<!\\\\)((?:\\\\{2})*)c/', '$1Y-m-d\TH:i:sP', $format);
if (preg_match('/(?<!\\\\)(?:\\\\{2})*(a|A)/', $format, $aMatches, PREG_OFFSET_CAPTURE) &&
preg_match('/(?<!\\\\)(?:\\\\{2})*(h|g|H|G)/', $format, $hMatches, PREG_OFFSET_CAPTURE) &&
$aMatches[1][1] < $hMatches[1][1] &&
preg_match('/(am|pm|AM|PM)/', $time)
) {
$format = preg_replace('/^(.*)(?<!\\\\)((?:\\\\{2})*)(a|A)(.*)$/U', '$1$2$4 $3', $format);
$time = preg_replace('/^(.*)(am|pm|AM|PM)(.*)$/U', '$1$3 $2', $time);
}
if ($timezone === false) {
$timezone = null;
}
// First attempt to create an instance, so that error messages are based on the unmodified format.
$date = self::createFromFormatAndTimezone($format, $time, $timezone);
$lastErrors = parent::getLastErrors();
/** @var \Carbon\CarbonImmutable|\Carbon\Carbon|null $mock */
$mock = static::getMockedTestNow($timezone);
if ($mock && $date instanceof DateTimeInterface) {
// Set timezone from mock if custom timezone was neither given directly nor as a part of format.
// First let's skip the part that will be ignored by the parser.
$nonEscaped = '(?<!\\\\)(\\\\{2})*';
$nonIgnored = preg_replace("/^.*{$nonEscaped}!/s", '', $format);
if ($timezone === null && !preg_match("/{$nonEscaped}[eOPT]/", $nonIgnored)) {
$timezone = clone $mock->getTimezone();
}
$mock = $mock->copy();
// Prepend mock datetime only if the format does not contain non escaped unix epoch reset flag.
if (!preg_match("/{$nonEscaped}[!|]/", $format)) {
if (preg_match('/[HhGgisvuB]/', $format)) {
$mock = $mock->setTime(0, 0);
}
$format = static::MOCK_DATETIME_FORMAT.' '.$format;
$time = ($mock instanceof self ? $mock->rawFormat(static::MOCK_DATETIME_FORMAT) : $mock->format(static::MOCK_DATETIME_FORMAT)).' '.$time;
}
// Regenerate date from the modified format to base result on the mocked instance instead of now.
$date = self::createFromFormatAndTimezone($format, $time, $timezone);
}
if ($date instanceof DateTimeInterface) {
$instance = static::instance($date);
$instance::setLastErrors($lastErrors);
return $instance;
}
if (static::isStrictModeEnabled()) {
throw new InvalidFormatException(implode(PHP_EOL, (array) $lastErrors['errors']));
}
return null;
}
/**
* Create a Carbon instance from a specific format.
*
* @param string $format Datetime format
* @param string $time
* @param DateTimeZone|string|int|null $timezone
*
* @throws InvalidFormatException
*
* @return static|null
*/
#[ReturnTypeWillChange]
public static function createFromFormat($format, $time, $timezone = null): ?self
{
$function = static::$createFromFormatFunction;
// format is a single numeric unit
if (\is_int($time) && \in_array(ltrim($format, '!'), ['U', 'Y', 'y', 'X', 'x', 'm', 'n', 'd', 'j', 'w', 'W', 'H', 'h', 'G', 'g', 'i', 's', 'u', 'z', 'v'], true)) {
$time = (string) $time;
}
if (!\is_string($time)) {
@trigger_error(
'createFromFormat() $time parameter will only accept string or integer for 1-letter format representing a numeric unit in the next version',
\E_USER_DEPRECATED,
);
$time = (string) $time;
}
if (!$function) {
return static::rawCreateFromFormat($format, $time, $timezone);
}
if (\is_string($function) && method_exists(static::class, $function)) {
$function = [static::class, $function];
}
return $function(...\func_get_args());
}
/**
* Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
*
* @param string $format Datetime format
* @param string $time
* @param DateTimeZone|string|int|null $timezone optional timezone
* @param string|null $locale locale to be used for LTS, LT, LL, LLL, etc. macro-formats (en by fault, unneeded if no such macro-format in use)
* @param TranslatorInterface|null $translator optional custom translator to use for macro-formats
*
* @throws InvalidFormatException
*
* @return static|null
*/
public static function createFromIsoFormat(
string $format,
string $time,
$timezone = null,
?string $locale = self::DEFAULT_LOCALE,
?TranslatorInterface $translator = null
): ?self {
$format = preg_replace_callback('/(?<!\\\\)(\\\\{2})*(LTS|LT|[Ll]{1,4})/', function ($match) use ($locale, $translator) {
[$code] = $match;
static $formats = null;
if ($formats === null) {
$translator ??= Translator::get($locale);
$formats = [
'LT' => static::getTranslationMessageWith($translator, 'formats.LT', $locale),
'LTS' => static::getTranslationMessageWith($translator, 'formats.LTS', $locale),
'L' => static::getTranslationMessageWith($translator, 'formats.L', $locale),
'LL' => static::getTranslationMessageWith($translator, 'formats.LL', $locale),
'LLL' => static::getTranslationMessageWith($translator, 'formats.LLL', $locale),
'LLLL' => static::getTranslationMessageWith($translator, 'formats.LLLL', $locale),
];
}
return $formats[$code] ?? preg_replace_callback(
'/MMMM|MM|DD|dddd/',
static fn (array $code) => mb_substr($code[0], 1),
$formats[strtoupper($code)] ?? '',
);
}, $format);
$format = preg_replace_callback('/(?<!\\\\)(\\\\{2})*('.CarbonInterface::ISO_FORMAT_REGEXP.'|[A-Za-z])/', function ($match) {
[$code] = $match;
static $replacements = null;
if ($replacements === null) {
$replacements = [
'OD' => 'd',
'OM' => 'M',
'OY' => 'Y',
'OH' => 'G',
'Oh' => 'g',
'Om' => 'i',
'Os' => 's',
'D' => 'd',
'DD' => 'd',
'Do' => 'd',
'd' => '!',
'dd' => '!',
'ddd' => 'D',
'dddd' => 'D',
'DDD' => 'z',
'DDDD' => 'z',
'DDDo' => 'z',
'e' => '!',
'E' => '!',
'H' => 'G',
'HH' => 'H',
'h' => 'g',
'hh' => 'h',
'k' => 'G',
'kk' => 'G',
'hmm' => 'gi',
'hmmss' => 'gis',
'Hmm' => 'Gi',
'Hmmss' => 'Gis',
'm' => 'i',
'mm' => 'i',
'a' => 'a',
'A' => 'a',
's' => 's',
'ss' => 's',
'S' => '*',
'SS' => '*',
'SSS' => '*',
'SSSS' => '*',
'SSSSS' => '*',
'SSSSSS' => 'u',
'SSSSSSS' => 'u*',
'SSSSSSSS' => 'u*',
'SSSSSSSSS' => 'u*',
'M' => 'm',
'MM' => 'm',
'MMM' => 'M',
'MMMM' => 'M',
'Mo' => 'm',
'Q' => '!',
'Qo' => '!',
'G' => '!',
'GG' => '!',
'GGG' => '!',
'GGGG' => '!',
'GGGGG' => '!',
'g' => '!',
'gg' => '!',
'ggg' => '!',
'gggg' => '!',
'ggggg' => '!',
'W' => '!',
'WW' => '!',
'Wo' => '!',
'w' => '!',
'ww' => '!',
'wo' => '!',
'x' => 'U???',
'X' => 'U',
'Y' => 'Y',
'YY' => 'y',
'YYYY' => 'Y',
'YYYYY' => 'Y',
'YYYYYY' => 'Y',
'z' => 'e',
'zz' => 'e',
'Z' => 'e',
'ZZ' => 'e',
];
}
$format = $replacements[$code] ?? '?';
if ($format === '!') {
throw new InvalidFormatException("Format $code not supported for creation.");
}
return $format;
}, $format);
return static::rawCreateFromFormat($format, $time, $timezone);
}
/**
* Create a Carbon instance from a specific format and a string in a given language.
*
* @param string $format Datetime format
* @param string $locale
* @param string $time
* @param DateTimeZone|string|int|null $timezone
*
* @throws InvalidFormatException
*
* @return static|null
*/
public static function createFromLocaleFormat(string $format, string $locale, string $time, $timezone = null): ?self
{
$format = preg_replace_callback(
'/(?:\\\\[a-zA-Z]|[bfkqCEJKQRV]){2,}/',
static function (array $match) use ($locale): string {
$word = str_replace('\\', '', $match[0]);
$translatedWord = static::translateTimeString($word, $locale, static::DEFAULT_LOCALE);
return $word === $translatedWord
? $match[0]
: preg_replace('/[a-zA-Z]/', '\\\\$0', $translatedWord);
},
$format
);
return static::rawCreateFromFormat($format, static::translateTimeString($time, $locale, static::DEFAULT_LOCALE), $timezone);
}
/**
* Create a Carbon instance from a specific ISO format and a string in a given language.
*
* @param string $format Datetime ISO format
* @param string $locale
* @param string $time
* @param DateTimeZone|string|int|null $timezone
*
* @throws InvalidFormatException
*
* @return static|null
*/
public static function createFromLocaleIsoFormat(string $format, string $locale, string $time, $timezone = null): ?self
{
$time = static::translateTimeString($time, $locale, static::DEFAULT_LOCALE, CarbonInterface::TRANSLATE_MONTHS | CarbonInterface::TRANSLATE_DAYS | CarbonInterface::TRANSLATE_MERIDIEM);
return static::createFromIsoFormat($format, $time, $timezone, $locale);
}
/**
* Make a Carbon instance from given variable if possible.
*
* Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
* and recurrences). Throw an exception for invalid format, but otherwise return null.
*
* @param mixed $var
*
* @throws InvalidFormatException
*
* @return static|null
*/
public static function make($var, DateTimeZone|string|null $timezone = null): ?self
{
if ($var instanceof DateTimeInterface) {
return static::instance($var);
}
$date = null;
if (\is_string($var)) {
$var = trim($var);
if (!preg_match('/^P[\dT]/', $var) &&
!preg_match('/^R\d/', $var) &&
preg_match('/[a-z\d]/i', $var)
) {
$date = static::parse($var, $timezone);
}
}
return $date;
}
/**
* Set last errors.
*
* @param array|bool $lastErrors
*
* @return void
*/
private static function setLastErrors($lastErrors): void
{
if (\is_array($lastErrors) || $lastErrors === false) {
static::$lastErrors = \is_array($lastErrors) ? $lastErrors : [
'warning_count' => 0,
'warnings' => [],
'error_count' => 0,
'errors' => [],
];
}
}
/**
* {@inheritdoc}
*/
public static function getLastErrors(): array|false
{
return static::$lastErrors ?? false;
}
private static function monthToInt(mixed $value, string $unit = 'month'): mixed
{
if ($value instanceof Month) {
if ($unit !== 'month') {
throw new UnitException("Month enum cannot be used to set $unit");
}
return Month::int($value);
}
return $value;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,83 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\CarbonInterface;
use Carbon\CarbonInterval;
trait DeprecatedPeriodProperties
{
/**
* Period start in PHP < 8.2.
*
* @var CarbonInterface
*
* @deprecated PHP 8.2 this property is no longer in sync with the actual period start.
*/
public $start;
/**
* Period end in PHP < 8.2.
*
* @var CarbonInterface|null
*
* @deprecated PHP 8.2 this property is no longer in sync with the actual period end.
*/
public $end;
/**
* Period current iterated date in PHP < 8.2.
*
* @var CarbonInterface|null
*
* @deprecated PHP 8.2 this property is no longer in sync with the actual period current iterated date.
*/
public $current;
/**
* Period interval in PHP < 8.2.
*
* @var CarbonInterval|null
*
* @deprecated PHP 8.2 this property is no longer in sync with the actual period interval.
*/
public $interval;
/**
* Period recurrences in PHP < 8.2.
*
* @var int|float|null
*
* @deprecated PHP 8.2 this property is no longer in sync with the actual period recurrences.
*/
public $recurrences;
/**
* Period start included option in PHP < 8.2.
*
* @var bool
*
* @deprecated PHP 8.2 this property is no longer in sync with the actual period start included option.
*/
public $include_start_date;
/**
* Period end included option in PHP < 8.2.
*
* @var bool
*
* @deprecated PHP 8.2 this property is no longer in sync with the actual period end included option.
*/
public $include_end_date;
}
+855
View File
@@ -0,0 +1,855 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
use Carbon\CarbonInterval;
use Carbon\CarbonPeriod;
use Carbon\Exceptions\UnknownUnitException;
use Carbon\Unit;
use Closure;
use DateInterval;
use DateTimeInterface;
/**
* Trait Difference.
*
* Depends on the following methods:
*
* @method bool lessThan($date)
* @method static copy()
* @method static resolveCarbon($date = null)
*/
trait Difference
{
/**
* Get the difference as a DateInterval instance.
* Return relative interval (negative if $absolute flag is not set to true and the given date is before
* current one).
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return DateInterval
*/
public function diffAsDateInterval($date = null, bool $absolute = false): DateInterval
{
$other = $this->resolveCarbon($date);
// Work-around for https://bugs.php.net/bug.php?id=81458
// It was initially introduced for https://bugs.php.net/bug.php?id=80998
// The very specific case of 80998 was fixed in PHP 8.1beta3, but it introduced 81458
// So we still need to keep this for now
if ($other->tz !== $this->tz) {
$other = $other->avoidMutation()->setTimezone($this->tz);
}
return parent::diff($other, $absolute);
}
/**
* Get the difference as a CarbonInterval instance.
* Return relative interval (negative if $absolute flag is not set to true and the given date is before
* current one).
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return CarbonInterval
*/
public function diffAsCarbonInterval($date = null, bool $absolute = false, array $skip = []): CarbonInterval
{
return CarbonInterval::diff($this, $this->resolveCarbon($date), $absolute, $skip)
->setLocalTranslator($this->getLocalTranslator());
}
/**
* @alias diffAsCarbonInterval
*
* Get the difference as a DateInterval instance.
* Return relative interval (negative if $absolute flag is not set to true and the given date is before
* current one).
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return CarbonInterval
*/
public function diff($date = null, bool $absolute = false, array $skip = []): CarbonInterval
{
return $this->diffAsCarbonInterval($date, $absolute, $skip);
}
/**
* @param Unit|string $unit microsecond, millisecond, second, minute,
* hour, day, week, month, quarter, year,
* century, millennium
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
* @param bool $utc Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)
*
* @return float
*/
public function diffInUnit(Unit|string $unit, $date = null, bool $absolute = false, bool $utc = false): float
{
$unit = static::pluralUnit($unit instanceof Unit ? $unit->value : rtrim($unit, 'z'));
$method = 'diffIn'.$unit;
if (!method_exists($this, $method)) {
throw new UnknownUnitException($unit);
}
return $this->$method($date, $absolute, $utc);
}
/**
* Get the difference in years
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
* @param bool $utc Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)
*
* @return float
*/
public function diffInYears($date = null, bool $absolute = false, bool $utc = false): float
{
$start = $this;
$end = $this->resolveCarbon($date);
if ($utc) {
$start = $start->avoidMutation()->utc();
$end = $end->avoidMutation()->utc();
}
$ascending = ($start <= $end);
$sign = $absolute || $ascending ? 1 : -1;
if (!$ascending) {
[$start, $end] = [$end, $start];
}
$yearsDiff = (int) $start->diff($end, $absolute)->format('%r%y');
/** @var Carbon|CarbonImmutable $floorEnd */
$floorEnd = $start->avoidMutation()->addYears($yearsDiff);
if ($floorEnd >= $end) {
return $sign * $yearsDiff;
}
/** @var Carbon|CarbonImmutable $ceilEnd */
$ceilEnd = $start->avoidMutation()->addYears($yearsDiff + 1);
$daysToFloor = $floorEnd->diffInDays($end);
$daysToCeil = $end->diffInDays($ceilEnd);
return $sign * ($yearsDiff + $daysToFloor / ($daysToCeil + $daysToFloor));
}
/**
* Get the difference in quarters.
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
* @param bool $utc Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)
*
* @return float
*/
public function diffInQuarters($date = null, bool $absolute = false, bool $utc = false): float
{
return $this->diffInMonths($date, $absolute, $utc) / static::MONTHS_PER_QUARTER;
}
/**
* Get the difference in months.
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
* @param bool $utc Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)
*
* @return float
*/
public function diffInMonths($date = null, bool $absolute = false, bool $utc = false): float
{
$start = $this;
$end = $this->resolveCarbon($date);
// Compare using UTC
if ($utc || ($end->timezoneName !== $start->timezoneName)) {
$start = $start->avoidMutation()->utc();
$end = $end->avoidMutation()->utc();
}
[$yearStart, $monthStart, $dayStart] = explode('-', $start->format('Y-m-dHisu'));
[$yearEnd, $monthEnd, $dayEnd] = explode('-', $end->format('Y-m-dHisu'));
$monthsDiff = (((int) $yearEnd) - ((int) $yearStart)) * static::MONTHS_PER_YEAR +
((int) $monthEnd) - ((int) $monthStart);
if ($monthsDiff > 0) {
$monthsDiff -= ($dayStart > $dayEnd ? 1 : 0);
} elseif ($monthsDiff < 0) {
$monthsDiff += ($dayStart < $dayEnd ? 1 : 0);
}
$ascending = ($start <= $end);
$sign = $absolute || $ascending ? 1 : -1;
$monthsDiff = abs($monthsDiff);
if (!$ascending) {
[$start, $end] = [$end, $start];
}
/** @var Carbon|CarbonImmutable $floorEnd */
$floorEnd = $start->avoidMutation()->addMonths($monthsDiff);
if ($floorEnd >= $end) {
return $sign * $monthsDiff;
}
/** @var Carbon|CarbonImmutable $ceilEnd */
$ceilEnd = $start->avoidMutation()->addMonths($monthsDiff + 1);
$daysToFloor = $floorEnd->diffInDays($end);
$daysToCeil = $end->diffInDays($ceilEnd);
return $sign * ($monthsDiff + $daysToFloor / ($daysToCeil + $daysToFloor));
}
/**
* Get the difference in weeks.
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
* @param bool $utc Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)
*
* @return float
*/
public function diffInWeeks($date = null, bool $absolute = false, bool $utc = false): float
{
return $this->diffInDays($date, $absolute, $utc) / static::DAYS_PER_WEEK;
}
/**
* Get the difference in days.
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
* @param bool $utc Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)
*
* @return float
*/
public function diffInDays($date = null, bool $absolute = false, bool $utc = false): float
{
$date = $this->resolveCarbon($date);
$current = $this;
// Compare using UTC
if ($utc || ($date->timezoneName !== $current->timezoneName)) {
$date = $date->avoidMutation()->utc();
$current = $current->avoidMutation()->utc();
}
$negative = ($date < $current);
[$start, $end] = $negative ? [$date, $current] : [$current, $date];
$interval = $start->diffAsDateInterval($end);
$daysA = $this->getIntervalDayDiff($interval);
$floorEnd = $start->avoidMutation()->addDays($daysA);
$daysB = $daysA + ($floorEnd <= $end ? 1 : -1);
$ceilEnd = $start->avoidMutation()->addDays($daysB);
$microsecondsBetween = $floorEnd->diffInMicroseconds($ceilEnd);
$microsecondsToEnd = $floorEnd->diffInMicroseconds($end);
return ($negative && !$absolute ? -1 : 1)
* ($daysA * ($microsecondsBetween - $microsecondsToEnd) + $daysB * $microsecondsToEnd)
/ $microsecondsBetween;
}
/**
* Get the difference in days using a filter closure.
*
* @param Closure $callback
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
public function diffInDaysFiltered(Closure $callback, $date = null, bool $absolute = false): int
{
return $this->diffFiltered(CarbonInterval::day(), $callback, $date, $absolute);
}
/**
* Get the difference in hours using a filter closure.
*
* @param Closure $callback
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
public function diffInHoursFiltered(Closure $callback, $date = null, bool $absolute = false): int
{
return $this->diffFiltered(CarbonInterval::hour(), $callback, $date, $absolute);
}
/**
* Get the difference by the given interval using a filter closure.
*
* @param CarbonInterval $ci An interval to traverse by
* @param Closure $callback
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
public function diffFiltered(CarbonInterval $ci, Closure $callback, $date = null, bool $absolute = false): int
{
$start = $this;
$end = $this->resolveCarbon($date);
$inverse = false;
if ($end < $start) {
$start = $end;
$end = $this;
$inverse = true;
}
$options = CarbonPeriod::EXCLUDE_END_DATE | ($this->isMutable() ? 0 : CarbonPeriod::IMMUTABLE);
$diff = $ci->toPeriod($start, $end, $options)->filter($callback)->count();
return $inverse && !$absolute ? -$diff : $diff;
}
/**
* Get the difference in weekdays.
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
public function diffInWeekdays($date = null, bool $absolute = false): int
{
return $this->diffInDaysFiltered(
static fn (CarbonInterface $date) => $date->isWeekday(),
$this->resolveCarbon($date)->avoidMutation()->modify($this->format('H:i:s.u')),
$absolute,
);
}
/**
* Get the difference in weekend days using a filter.
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return int
*/
public function diffInWeekendDays($date = null, bool $absolute = false): int
{
return $this->diffInDaysFiltered(
static fn (CarbonInterface $date) => $date->isWeekend(),
$this->resolveCarbon($date)->avoidMutation()->modify($this->format('H:i:s.u')),
$absolute,
);
}
/**
* Get the difference in hours.
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return float
*/
public function diffInHours($date = null, bool $absolute = false): float
{
return $this->diffInMinutes($date, $absolute) / static::MINUTES_PER_HOUR;
}
/**
* Get the difference in minutes.
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return float
*/
public function diffInMinutes($date = null, bool $absolute = false): float
{
return $this->diffInSeconds($date, $absolute) / static::SECONDS_PER_MINUTE;
}
/**
* Get the difference in seconds.
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return float
*/
public function diffInSeconds($date = null, bool $absolute = false): float
{
return $this->diffInMilliseconds($date, $absolute) / static::MILLISECONDS_PER_SECOND;
}
/**
* Get the difference in microseconds.
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return float
*/
public function diffInMicroseconds($date = null, bool $absolute = false): float
{
/** @var CarbonInterface $date */
$date = $this->resolveCarbon($date);
$value = ($date->timestamp - $this->timestamp) * static::MICROSECONDS_PER_SECOND +
$date->micro - $this->micro;
return $absolute ? abs($value) : $value;
}
/**
* Get the difference in milliseconds.
*
* @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date
* @param bool $absolute Get the absolute of the difference
*
* @return float
*/
public function diffInMilliseconds($date = null, bool $absolute = false): float
{
return $this->diffInMicroseconds($date, $absolute) / static::MICROSECONDS_PER_MILLISECOND;
}
/**
* The number of seconds since midnight.
*
* @return float
*/
public function secondsSinceMidnight(): float
{
return $this->diffInSeconds($this->copy()->startOfDay(), true);
}
/**
* The number of seconds until 23:59:59.
*
* @return float
*/
public function secondsUntilEndOfDay(): float
{
return $this->diffInSeconds($this->copy()->endOfDay(), true);
}
/**
* Get the difference in a human readable format in the current locale from current instance to an other
* instance given (or now if null given).
*
* @example
* ```
* echo Carbon::tomorrow()->diffForHumans() . "\n";
* echo Carbon::tomorrow()->diffForHumans(['parts' => 2]) . "\n";
* echo Carbon::tomorrow()->diffForHumans(['parts' => 3, 'join' => true]) . "\n";
* echo Carbon::tomorrow()->diffForHumans(Carbon::yesterday()) . "\n";
* echo Carbon::tomorrow()->diffForHumans(Carbon::yesterday(), ['short' => true]) . "\n";
* ```
*
* @param Carbon|DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below;
* if null passed, now will be used as comparison reference;
* if any other type, it will be converted to date and used as reference.
* @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains:
* ⦿ 'syntax' entry (see below)
* ⦿ 'short' entry (see below)
* ⦿ 'parts' entry (see below)
* ⦿ 'options' entry (see below)
* ⦿ 'skip' entry, list of units to skip (array of strings or a single string,
* ` it can be the unit name (singular or plural) or its shortcut
* ` (y, m, w, d, h, min, s, ms, µs).
* ⦿ 'aUnit' entry, prefer "an hour" over "1 hour" if true
* ⦿ 'altNumbers' entry, use alternative numbers if available
* ` (from the current language if true is passed, from the given language(s)
* ` if array or string is passed)
* ⦿ 'join' entry determines how to join multiple parts of the string
* ` - if $join is a string, it's used as a joiner glue
* ` - if $join is a callable/closure, it get the list of string and should return a string
* ` - if $join is an array, the first item will be the default glue, and the second item
* ` will be used instead of the glue for the last item
* ` - if $join is true, it will be guessed from the locale ('list' translation file entry)
* ` - if $join is missing, a space will be used as glue
* ⦿ 'other' entry (see above)
* ⦿ 'minimumUnit' entry determines the smallest unit of time to display can be long or
* ` short form of the units, e.g. 'hour' or 'h' (default value: s)
* ⦿ 'locale' language in which the diff should be output (has no effect if 'translator' key is set)
* ⦿ 'translator' a custom translator to use to translator the output.
* if int passed, it adds modifiers:
* Possible values:
* - CarbonInterface::DIFF_ABSOLUTE no modifiers
* - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
* - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier
* Default value: CarbonInterface::DIFF_ABSOLUTE
* @param bool $short displays short format of time units
* @param int $parts maximum number of parts to display (default value: 1: single unit)
* @param int $options human diff options
*/
public function diffForHumans($other = null, $syntax = null, $short = false, $parts = 1, $options = null): string
{
/* @var CarbonInterface $this */
if (\is_array($other)) {
$other['syntax'] = \array_key_exists('syntax', $other) ? $other['syntax'] : $syntax;
$syntax = $other;
$other = $syntax['other'] ?? null;
}
$intSyntax = &$syntax;
if (\is_array($syntax)) {
$syntax['syntax'] = $syntax['syntax'] ?? null;
$intSyntax = &$syntax['syntax'];
}
$intSyntax = (int) ($intSyntax ?? static::DIFF_RELATIVE_AUTO);
$intSyntax = $intSyntax === static::DIFF_RELATIVE_AUTO && $other === null ? static::DIFF_RELATIVE_TO_NOW : $intSyntax;
$parts = min(7, max(1, (int) $parts));
$skip = \is_array($syntax) ? ($syntax['skip'] ?? []) : [];
$options ??= $this->localHumanDiffOptions ?? $this->transmitFactory(
static fn () => static::getHumanDiffOptions(),
);
return $this->diff($other, skip: (array) $skip)->forHumans($syntax, (bool) $short, $parts, $options);
}
/**
* @alias diffForHumans
*
* Get the difference in a human readable format in the current locale from current instance to an other
* instance given (or now if null given).
*
* @param Carbon|\DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below;
* if null passed, now will be used as comparison reference;
* if any other type, it will be converted to date and used as reference.
* @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains:
* - 'syntax' entry (see below)
* - 'short' entry (see below)
* - 'parts' entry (see below)
* - 'options' entry (see below)
* - 'join' entry determines how to join multiple parts of the string
* ` - if $join is a string, it's used as a joiner glue
* ` - if $join is a callable/closure, it get the list of string and should return a string
* ` - if $join is an array, the first item will be the default glue, and the second item
* ` will be used instead of the glue for the last item
* ` - if $join is true, it will be guessed from the locale ('list' translation file entry)
* ` - if $join is missing, a space will be used as glue
* - 'other' entry (see above)
* if int passed, it add modifiers:
* Possible values:
* - CarbonInterface::DIFF_ABSOLUTE no modifiers
* - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
* - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier
* Default value: CarbonInterface::DIFF_ABSOLUTE
* @param bool $short displays short format of time units
* @param int $parts maximum number of parts to display (default value: 1: single unit)
* @param int $options human diff options
*
* @return string
*/
public function from($other = null, $syntax = null, $short = false, $parts = 1, $options = null)
{
return $this->diffForHumans($other, $syntax, $short, $parts, $options);
}
/**
* @alias diffForHumans
*
* Get the difference in a human readable format in the current locale from current instance to an other
* instance given (or now if null given).
*/
public function since($other = null, $syntax = null, $short = false, $parts = 1, $options = null)
{
return $this->diffForHumans($other, $syntax, $short, $parts, $options);
}
/**
* Get the difference in a human readable format in the current locale from an other
* instance given (or now if null given) to current instance.
*
* When comparing a value in the past to default now:
* 1 hour from now
* 5 months from now
*
* When comparing a value in the future to default now:
* 1 hour ago
* 5 months ago
*
* When comparing a value in the past to another value:
* 1 hour after
* 5 months after
*
* When comparing a value in the future to another value:
* 1 hour before
* 5 months before
*
* @param Carbon|\DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below;
* if null passed, now will be used as comparison reference;
* if any other type, it will be converted to date and used as reference.
* @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains:
* - 'syntax' entry (see below)
* - 'short' entry (see below)
* - 'parts' entry (see below)
* - 'options' entry (see below)
* - 'join' entry determines how to join multiple parts of the string
* ` - if $join is a string, it's used as a joiner glue
* ` - if $join is a callable/closure, it get the list of string and should return a string
* ` - if $join is an array, the first item will be the default glue, and the second item
* ` will be used instead of the glue for the last item
* ` - if $join is true, it will be guessed from the locale ('list' translation file entry)
* ` - if $join is missing, a space will be used as glue
* - 'other' entry (see above)
* if int passed, it add modifiers:
* Possible values:
* - CarbonInterface::DIFF_ABSOLUTE no modifiers
* - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
* - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier
* Default value: CarbonInterface::DIFF_ABSOLUTE
* @param bool $short displays short format of time units
* @param int $parts maximum number of parts to display (default value: 1: single unit)
* @param int $options human diff options
*
* @return string
*/
public function to($other = null, $syntax = null, $short = false, $parts = 1, $options = null)
{
if (!$syntax && !$other) {
$syntax = CarbonInterface::DIFF_RELATIVE_TO_NOW;
}
return $this->resolveCarbon($other)->diffForHumans($this, $syntax, $short, $parts, $options);
}
/**
* @alias to
*
* Get the difference in a human readable format in the current locale from an other
* instance given (or now if null given) to current instance.
*
* @param Carbon|\DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below;
* if null passed, now will be used as comparison reference;
* if any other type, it will be converted to date and used as reference.
* @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains:
* - 'syntax' entry (see below)
* - 'short' entry (see below)
* - 'parts' entry (see below)
* - 'options' entry (see below)
* - 'join' entry determines how to join multiple parts of the string
* ` - if $join is a string, it's used as a joiner glue
* ` - if $join is a callable/closure, it get the list of string and should return a string
* ` - if $join is an array, the first item will be the default glue, and the second item
* ` will be used instead of the glue for the last item
* ` - if $join is true, it will be guessed from the locale ('list' translation file entry)
* ` - if $join is missing, a space will be used as glue
* - 'other' entry (see above)
* if int passed, it add modifiers:
* Possible values:
* - CarbonInterface::DIFF_ABSOLUTE no modifiers
* - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
* - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier
* Default value: CarbonInterface::DIFF_ABSOLUTE
* @param bool $short displays short format of time units
* @param int $parts maximum number of parts to display (default value: 1: single unit)
* @param int $options human diff options
*
* @return string
*/
public function until($other = null, $syntax = null, $short = false, $parts = 1, $options = null)
{
return $this->to($other, $syntax, $short, $parts, $options);
}
/**
* Get the difference in a human readable format in the current locale from current
* instance to now.
*
* @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains:
* - 'syntax' entry (see below)
* - 'short' entry (see below)
* - 'parts' entry (see below)
* - 'options' entry (see below)
* - 'join' entry determines how to join multiple parts of the string
* ` - if $join is a string, it's used as a joiner glue
* ` - if $join is a callable/closure, it get the list of string and should return a string
* ` - if $join is an array, the first item will be the default glue, and the second item
* ` will be used instead of the glue for the last item
* ` - if $join is true, it will be guessed from the locale ('list' translation file entry)
* ` - if $join is missing, a space will be used as glue
* if int passed, it add modifiers:
* Possible values:
* - CarbonInterface::DIFF_ABSOLUTE no modifiers
* - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
* - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier
* Default value: CarbonInterface::DIFF_ABSOLUTE
* @param bool $short displays short format of time units
* @param int $parts maximum number of parts to display (default value: 1: single unit)
* @param int $options human diff options
*
* @return string
*/
public function fromNow($syntax = null, $short = false, $parts = 1, $options = null)
{
$other = null;
if ($syntax instanceof DateTimeInterface) {
[$other, $syntax, $short, $parts, $options] = array_pad(\func_get_args(), 5, null);
}
return $this->from($other, $syntax, $short, $parts, $options);
}
/**
* Get the difference in a human readable format in the current locale from an other
* instance given to now
*
* @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains:
* - 'syntax' entry (see below)
* - 'short' entry (see below)
* - 'parts' entry (see below)
* - 'options' entry (see below)
* - 'join' entry determines how to join multiple parts of the string
* ` - if $join is a string, it's used as a joiner glue
* ` - if $join is a callable/closure, it get the list of string and should return a string
* ` - if $join is an array, the first item will be the default glue, and the second item
* ` will be used instead of the glue for the last item
* ` - if $join is true, it will be guessed from the locale ('list' translation file entry)
* ` - if $join is missing, a space will be used as glue
* if int passed, it add modifiers:
* Possible values:
* - CarbonInterface::DIFF_ABSOLUTE no modifiers
* - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
* - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier
* Default value: CarbonInterface::DIFF_ABSOLUTE
* @param bool $short displays short format of time units
* @param int $parts maximum number of parts to display (default value: 1: single part)
* @param int $options human diff options
*
* @return string
*/
public function toNow($syntax = null, $short = false, $parts = 1, $options = null)
{
return $this->to(null, $syntax, $short, $parts, $options);
}
/**
* Get the difference in a human readable format in the current locale from an other
* instance given to now
*
* @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains:
* - 'syntax' entry (see below)
* - 'short' entry (see below)
* - 'parts' entry (see below)
* - 'options' entry (see below)
* - 'join' entry determines how to join multiple parts of the string
* ` - if $join is a string, it's used as a joiner glue
* ` - if $join is a callable/closure, it get the list of string and should return a string
* ` - if $join is an array, the first item will be the default glue, and the second item
* ` will be used instead of the glue for the last item
* ` - if $join is true, it will be guessed from the locale ('list' translation file entry)
* ` - if $join is missing, a space will be used as glue
* if int passed, it add modifiers:
* Possible values:
* - CarbonInterface::DIFF_ABSOLUTE no modifiers
* - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
* - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier
* Default value: CarbonInterface::DIFF_ABSOLUTE
* @param bool $short displays short format of time units
* @param int $parts maximum number of parts to display (default value: 1: single part)
* @param int $options human diff options
*
* @return string
*/
public function ago($syntax = null, $short = false, $parts = 1, $options = null)
{
$other = null;
if ($syntax instanceof DateTimeInterface) {
[$other, $syntax, $short, $parts, $options] = array_pad(\func_get_args(), 5, null);
}
return $this->from($other, $syntax, $short, $parts, $options);
}
/**
* Get the difference in a human-readable format in the current locale from current instance to another
* instance given (or now if null given).
*
* @return string
*/
public function timespan($other = null, $timezone = null): string
{
if (\is_string($other)) {
$other = $this->transmitFactory(static fn () => static::parse($other, $timezone));
}
return $this->diffForHumans($other, [
'join' => ', ',
'syntax' => CarbonInterface::DIFF_ABSOLUTE,
'parts' => INF,
]);
}
/**
* Returns either day of week + time (e.g. "Last Friday at 3:30 PM") if reference time is within 7 days,
* or a calendar date (e.g. "10/29/2017") otherwise.
*
* Language, date and time formats will change according to the current locale.
*
* @param Carbon|\DateTimeInterface|string|null $referenceTime
* @param array $formats
*
* @return string
*/
public function calendar($referenceTime = null, array $formats = [])
{
/** @var CarbonInterface $current */
$current = $this->avoidMutation()->startOfDay();
/** @var CarbonInterface $other */
$other = $this->resolveCarbon($referenceTime)->avoidMutation()->setTimezone($this->getTimezone())->startOfDay();
$diff = $other->diffInDays($current, false);
$format = $diff <= -static::DAYS_PER_WEEK ? 'sameElse' : (
$diff < -1 ? 'lastWeek' : (
$diff < 0 ? 'lastDay' : (
$diff < 1 ? 'sameDay' : (
$diff < 2 ? 'nextDay' : (
$diff < static::DAYS_PER_WEEK ? 'nextWeek' : 'sameElse'
)
)
)
)
);
$format = array_merge($this->getCalendarFormats(), $formats)[$format];
if ($format instanceof Closure) {
$format = $format($current, $other) ?? '';
}
return $this->isoFormat((string) $format);
}
private function getIntervalDayDiff(DateInterval $interval): int
{
return (int) $interval->format('%r%a');
}
}
@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\CarbonInterval;
use Carbon\Exceptions\InvalidIntervalException;
use DateInterval;
/**
* Trait to call rounding methods to interval or the interval of a period.
*/
trait IntervalRounding
{
protected function callRoundMethod(string $method, array $parameters): ?static
{
$action = substr($method, 0, 4);
if ($action !== 'ceil') {
$action = substr($method, 0, 5);
}
if (\in_array($action, ['round', 'floor', 'ceil'])) {
return $this->{$action.'Unit'}(substr($method, \strlen($action)), ...$parameters);
}
return null;
}
protected function roundWith(DateInterval|string|float|int $precision, callable|string $function): ?static
{
$unit = 'second';
if ($precision instanceof DateInterval) {
$precision = CarbonInterval::instance($precision)->forHumans(['locale' => 'en']);
}
if (\is_string($precision) && preg_match('/^\s*(?<precision>\d+)?\s*(?<unit>\w+)(?<other>\W.*)?$/', $precision, $match)) {
if (trim($match['other'] ?? '') !== '') {
throw new InvalidIntervalException('Rounding is only possible with single unit intervals.');
}
$precision = (int) ($match['precision'] ?: 1);
$unit = $match['unit'];
}
return $this->roundUnit($unit, $precision, $function);
}
}
+94
View File
@@ -0,0 +1,94 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\Callback;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
use Closure;
use DateTimeImmutable;
use DateTimeInterface;
trait IntervalStep
{
/**
* Step to apply instead of a fixed interval to get the new date.
*
* @var Closure|null
*/
protected $step;
/**
* Get the dynamic step in use.
*
* @return Closure
*/
public function getStep(): ?Closure
{
return $this->step;
}
/**
* Set a step to apply instead of a fixed interval to get the new date.
*
* Or pass null to switch to fixed interval.
*
* @param Closure|null $step
*/
public function setStep(?Closure $step): void
{
$this->step = $step;
}
/**
* Take a date and apply either the step if set, or the current interval else.
*
* The interval/step is applied negatively (typically subtraction instead of addition) if $negated is true.
*
* @param DateTimeInterface $dateTime
* @param bool $negated
*
* @return CarbonInterface
*/
public function convertDate(DateTimeInterface $dateTime, bool $negated = false): CarbonInterface
{
/** @var CarbonInterface $carbonDate */
$carbonDate = $dateTime instanceof CarbonInterface ? $dateTime : $this->resolveCarbon($dateTime);
if ($this->step) {
$carbonDate = Callback::parameter($this->step, $carbonDate->avoidMutation());
return $carbonDate->modify(($this->step)($carbonDate, $negated)->format('Y-m-d H:i:s.u e O'));
}
if ($negated) {
return $carbonDate->rawSub($this);
}
return $carbonDate->rawAdd($this);
}
/**
* Convert DateTimeImmutable instance to CarbonImmutable instance and DateTime instance to Carbon instance.
*/
private function resolveCarbon(DateTimeInterface $dateTime): Carbon|CarbonImmutable
{
if ($dateTime instanceof DateTimeImmutable) {
return CarbonImmutable::instance($dateTime);
}
return Carbon::instance($dateTime);
}
}
+67
View File
@@ -0,0 +1,67 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\Factory;
use Carbon\FactoryImmutable;
use Carbon\WrapperClock;
use Closure;
/**
* Remember the factory that was the current at the creation of the object.
*/
trait LocalFactory
{
/**
* The clock that generated the current instance (or FactoryImmutable::getDefaultInstance() if none)
*/
private ?WrapperClock $clock = null;
public function getClock(): ?WrapperClock
{
return $this->clock;
}
private function initLocalFactory(): void
{
$this->clock = FactoryImmutable::getCurrentClock();
}
/**
* Trigger the given action using the local factory of the object, so it will be transmitted
* to any object also using this trait and calling initLocalFactory() in its constructor.
*
* @template T
*
* @param Closure(): T $action
*
* @return T
*/
private function transmitFactory(Closure $action): mixed
{
$previousClock = FactoryImmutable::getCurrentClock();
FactoryImmutable::setCurrentClock($this->clock);
try {
return $action();
} finally {
FactoryImmutable::setCurrentClock($previousClock);
}
}
private function getFactory(): Factory
{
return $this->getClock()?->getFactory() ?? FactoryImmutable::getDefaultInstance();
}
}
+728
View File
@@ -0,0 +1,728 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\CarbonInterface;
use Carbon\Exceptions\InvalidTypeException;
use Carbon\Exceptions\NotLocaleAwareException;
use Carbon\Language;
use Carbon\Translator;
use Carbon\TranslatorStrongTypeInterface;
use Closure;
use Symfony\Component\Translation\TranslatorBagInterface;
use Symfony\Contracts\Translation\LocaleAwareInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Trait Localization.
*
* Embed default and locale translators and translation base methods.
*/
trait Localization
{
use StaticLocalization;
/**
* Specific translator of the current instance.
*/
protected ?TranslatorInterface $localTranslator = null;
/**
* Return true if the current instance has its own translator.
*/
public function hasLocalTranslator(): bool
{
return isset($this->localTranslator);
}
/**
* Get the translator of the current instance or the default if none set.
*/
public function getLocalTranslator(): TranslatorInterface
{
return $this->localTranslator ?? $this->transmitFactory(static fn () => static::getTranslator());
}
/**
* Set the translator for the current instance.
*/
public function setLocalTranslator(TranslatorInterface $translator): self
{
$this->localTranslator = $translator;
return $this;
}
/**
* Returns raw translation message for a given key.
*
* @param TranslatorInterface|null $translator the translator to use
* @param string $key key to find
* @param string|null $locale current locale used if null
* @param string|null $default default value if translation returns the key
*
* @return string|Closure|null
*/
public static function getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null)
{
if (!($translator instanceof TranslatorBagInterface && $translator instanceof TranslatorInterface)) {
throw new InvalidTypeException(
'Translator does not implement '.TranslatorInterface::class.' and '.TranslatorBagInterface::class.'. '.
(\is_object($translator) ? \get_class($translator) : \gettype($translator)).' has been given.',
);
}
if (!$locale && $translator instanceof LocaleAwareInterface) {
$locale = $translator->getLocale();
}
$result = self::getFromCatalogue($translator, $translator->getCatalogue($locale), $key);
return $result === $key ? $default : $result;
}
/**
* Returns raw translation message for a given key.
*
* @param string $key key to find
* @param string|null $locale current locale used if null
* @param string|null $default default value if translation returns the key
* @param TranslatorInterface $translator an optional translator to use
*
* @return string
*/
public function getTranslationMessage(string $key, ?string $locale = null, ?string $default = null, $translator = null)
{
return static::getTranslationMessageWith($translator ?? $this->getLocalTranslator(), $key, $locale, $default);
}
/**
* Translate using translation string or callback available.
*
* @param TranslatorInterface $translator an optional translator to use
* @param string $key key to find
* @param array $parameters replacement parameters
* @param int|float|null $number number if plural
*
* @return string
*/
public static function translateWith(TranslatorInterface $translator, string $key, array $parameters = [], $number = null): string
{
$message = static::getTranslationMessageWith($translator, $key, null, $key);
if ($message instanceof Closure) {
return (string) $message(...array_values($parameters));
}
if ($number !== null) {
$parameters['%count%'] = $number;
}
if (isset($parameters['%count%'])) {
$parameters[':count'] = $parameters['%count%'];
}
return (string) $translator->trans($key, $parameters);
}
/**
* Translate using translation string or callback available.
*
* @param string $key key to find
* @param array $parameters replacement parameters
* @param string|int|float|null $number number if plural
* @param TranslatorInterface|null $translator an optional translator to use
* @param bool $altNumbers pass true to use alternative numbers
*
* @return string
*/
public function translate(
string $key,
array $parameters = [],
string|int|float|null $number = null,
?TranslatorInterface $translator = null,
bool $altNumbers = false,
): string {
$translation = static::translateWith($translator ?? $this->getLocalTranslator(), $key, $parameters, $number);
if ($number !== null && $altNumbers) {
return str_replace((string) $number, $this->translateNumber((int) $number), $translation);
}
return $translation;
}
/**
* Returns the alternative number for a given integer if available in the current locale.
*
* @param int $number
*
* @return string
*/
public function translateNumber(int $number): string
{
$translateKey = "alt_numbers.$number";
$symbol = $this->translate($translateKey);
if ($symbol !== $translateKey) {
return $symbol;
}
if ($number > 99 && $this->translate('alt_numbers.99') !== 'alt_numbers.99') {
$start = '';
foreach ([10000, 1000, 100] as $exp) {
$key = "alt_numbers_pow.$exp";
if ($number >= $exp && $number < $exp * 10 && ($pow = $this->translate($key)) !== $key) {
$unit = floor($number / $exp);
$number -= $unit * $exp;
$start .= ($unit > 1 ? $this->translate("alt_numbers.$unit") : '').$pow;
}
}
$result = '';
while ($number) {
$chunk = $number % 100;
$result = $this->translate("alt_numbers.$chunk").$result;
$number = floor($number / 100);
}
return "$start$result";
}
if ($number > 9 && $this->translate('alt_numbers.9') !== 'alt_numbers.9') {
$result = '';
while ($number) {
$chunk = $number % 10;
$result = $this->translate("alt_numbers.$chunk").$result;
$number = floor($number / 10);
}
return $result;
}
return (string) $number;
}
/**
* Translate a time string from a locale to an other.
*
* @param string $timeString date/time/duration string to translate (may also contain English)
* @param string|null $from input locale of the $timeString parameter (`Carbon::getLocale()` by default)
* @param string|null $to output locale of the result returned (`"en"` by default)
* @param int $mode specify what to translate with options:
* - CarbonInterface::TRANSLATE_ALL (default)
* - CarbonInterface::TRANSLATE_MONTHS
* - CarbonInterface::TRANSLATE_DAYS
* - CarbonInterface::TRANSLATE_UNITS
* - CarbonInterface::TRANSLATE_MERIDIEM
* You can use pipe to group: CarbonInterface::TRANSLATE_MONTHS | CarbonInterface::TRANSLATE_DAYS
*
* @return string
*/
public static function translateTimeString(
string $timeString,
?string $from = null,
?string $to = null,
int $mode = CarbonInterface::TRANSLATE_ALL,
): string {
// Fallback source and destination locales
$from = $from ?: static::getLocale();
$to = $to ?: CarbonInterface::DEFAULT_LOCALE;
if ($from === $to) {
return $timeString;
}
// Standardize apostrophe
$timeString = strtr($timeString, ['' => "'"]);
$fromTranslations = [];
$toTranslations = [];
foreach (['from', 'to'] as $key) {
$language = $$key;
$translator = Translator::get($language);
$translations = $translator->getMessages();
if (!isset($translations[$language])) {
return $timeString;
}
$translationKey = $key.'Translations';
$messages = $translations[$language];
$months = $messages['months'] ?? [];
$weekdays = $messages['weekdays'] ?? [];
$meridiem = $messages['meridiem'] ?? ['AM', 'PM'];
if (isset($messages['ordinal_words'])) {
$timeString = self::replaceOrdinalWords(
$timeString,
$key === 'from' ? array_flip($messages['ordinal_words']) : $messages['ordinal_words']
);
}
if ($key === 'from') {
foreach (['months', 'weekdays'] as $variable) {
$list = $messages[$variable.'_standalone'] ?? null;
if ($list) {
foreach ($$variable as $index => &$name) {
$name .= '|'.$messages[$variable.'_standalone'][$index];
}
}
}
}
$$translationKey = array_merge(
$mode & CarbonInterface::TRANSLATE_MONTHS ? static::getTranslationArray($months, static::MONTHS_PER_YEAR, $timeString) : [],
$mode & CarbonInterface::TRANSLATE_MONTHS ? static::getTranslationArray($messages['months_short'] ?? [], static::MONTHS_PER_YEAR, $timeString) : [],
$mode & CarbonInterface::TRANSLATE_DAYS ? static::getTranslationArray($weekdays, static::DAYS_PER_WEEK, $timeString) : [],
$mode & CarbonInterface::TRANSLATE_DAYS ? static::getTranslationArray($messages['weekdays_short'] ?? [], static::DAYS_PER_WEEK, $timeString) : [],
$mode & CarbonInterface::TRANSLATE_DIFF ? static::translateWordsByKeys([
'diff_now',
'diff_today',
'diff_yesterday',
'diff_tomorrow',
'diff_before_yesterday',
'diff_after_tomorrow',
], $messages, $key) : [],
$mode & CarbonInterface::TRANSLATE_UNITS ? static::translateWordsByKeys([
'year',
'month',
'week',
'day',
'hour',
'minute',
'second',
], $messages, $key) : [],
$mode & CarbonInterface::TRANSLATE_MERIDIEM ? array_map(function ($hour) use ($meridiem) {
if (\is_array($meridiem)) {
return $meridiem[$hour < static::HOURS_PER_DAY / 2 ? 0 : 1];
}
return $meridiem($hour, 0, false);
}, range(0, 23)) : [],
);
}
return substr(preg_replace_callback('/(?<=[\d\s+.\/,_-])('.implode('|', $fromTranslations).')(?=[\d\s+.\/,_-])/iu', function ($match) use ($fromTranslations, $toTranslations) {
[$chunk] = $match;
foreach ($fromTranslations as $index => $word) {
if (preg_match("/^$word\$/iu", $chunk)) {
return $toTranslations[$index] ?? '';
}
}
return $chunk; // @codeCoverageIgnore
}, " $timeString "), 1, -1);
}
/**
* Translate a time string from the current locale (`$date->locale()`) to an other.
*
* @param string $timeString time string to translate
* @param string|null $to output locale of the result returned ("en" by default)
*
* @return string
*/
public function translateTimeStringTo(string $timeString, ?string $to = null): string
{
return static::translateTimeString($timeString, $this->getTranslatorLocale(), $to);
}
/**
* Get/set the locale for the current instance.
*
* @param string|null $locale
* @param string ...$fallbackLocales
*
* @return $this|string
*/
public function locale(?string $locale = null, string ...$fallbackLocales): static|string
{
if ($locale === null) {
return $this->getTranslatorLocale();
}
if (!$this->localTranslator || $this->getTranslatorLocale($this->localTranslator) !== $locale) {
$translator = Translator::get($locale);
if (!empty($fallbackLocales)) {
$translator->setFallbackLocales($fallbackLocales);
foreach ($fallbackLocales as $fallbackLocale) {
$messages = Translator::get($fallbackLocale)->getMessages();
if (isset($messages[$fallbackLocale])) {
$translator->setMessages($fallbackLocale, $messages[$fallbackLocale]);
}
}
}
$this->localTranslator = $translator;
}
return $this;
}
/**
* Get the current translator locale.
*
* @return string
*/
public static function getLocale(): string
{
return static::getLocaleAwareTranslator()->getLocale();
}
/**
* Set the current translator locale and indicate if the source locale file exists.
* Pass 'auto' as locale to use the closest language to the current LC_TIME locale.
*
* @param string $locale locale ex. en
*/
public static function setLocale(string $locale): void
{
static::getLocaleAwareTranslator()->setLocale($locale);
}
/**
* Set the fallback locale.
*
* @see https://symfony.com/doc/current/components/translation.html#fallback-locales
*
* @param string $locale
*/
public static function setFallbackLocale(string $locale): void
{
$translator = static::getTranslator();
if (method_exists($translator, 'setFallbackLocales')) {
$translator->setFallbackLocales([$locale]);
if ($translator instanceof Translator) {
$preferredLocale = $translator->getLocale();
$translator->setMessages($preferredLocale, array_replace_recursive(
$translator->getMessages()[$locale] ?? [],
Translator::get($locale)->getMessages()[$locale] ?? [],
$translator->getMessages($preferredLocale),
));
}
}
}
/**
* Get the fallback locale.
*
* @see https://symfony.com/doc/current/components/translation.html#fallback-locales
*/
public static function getFallbackLocale(): ?string
{
$translator = static::getTranslator();
if (method_exists($translator, 'getFallbackLocales')) {
return $translator->getFallbackLocales()[0] ?? null;
}
return null;
}
/**
* Set the current locale to the given, execute the passed function, reset the locale to previous one,
* then return the result of the closure (or null if the closure was void).
*
* @param string $locale locale ex. en
* @param callable $func
*
* @return mixed
*/
public static function executeWithLocale(string $locale, callable $func): mixed
{
$currentLocale = static::getLocale();
static::setLocale($locale);
$newLocale = static::getLocale();
$result = $func(
$newLocale === 'en' && strtolower(substr((string) $locale, 0, 2)) !== 'en'
? false
: $newLocale,
static::getTranslator(),
);
static::setLocale($currentLocale);
return $result;
}
/**
* Returns true if the given locale is internally supported and has short-units support.
* Support is considered enabled if either year, day or hour has a short variant translated.
*
* @param string $locale locale ex. en
*
* @return bool
*/
public static function localeHasShortUnits(string $locale): bool
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
return ($newLocale && (($y = static::translateWith($translator, 'y')) !== 'y' && $y !== static::translateWith($translator, 'year'))) || (
($y = static::translateWith($translator, 'd')) !== 'd' &&
$y !== static::translateWith($translator, 'day')
) || (
($y = static::translateWith($translator, 'h')) !== 'h' &&
$y !== static::translateWith($translator, 'hour')
);
});
}
/**
* Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
* Support is considered enabled if the 4 sentences are translated in the given locale.
*
* @param string $locale locale ex. en
*
* @return bool
*/
public static function localeHasDiffSyntax(string $locale): bool
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
if (!$newLocale) {
return false;
}
foreach (['ago', 'from_now', 'before', 'after'] as $key) {
if ($translator instanceof TranslatorBagInterface &&
self::getFromCatalogue($translator, $translator->getCatalogue($newLocale), $key) instanceof Closure
) {
continue;
}
if ($translator->trans($key) === $key) {
return false;
}
}
return true;
});
}
/**
* Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
* Support is considered enabled if the 3 words are translated in the given locale.
*
* @param string $locale locale ex. en
*
* @return bool
*/
public static function localeHasDiffOneDayWords(string $locale): bool
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
return $newLocale &&
$translator->trans('diff_now') !== 'diff_now' &&
$translator->trans('diff_yesterday') !== 'diff_yesterday' &&
$translator->trans('diff_tomorrow') !== 'diff_tomorrow';
});
}
/**
* Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
* Support is considered enabled if the 2 words are translated in the given locale.
*
* @param string $locale locale ex. en
*
* @return bool
*/
public static function localeHasDiffTwoDayWords(string $locale): bool
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
return $newLocale &&
$translator->trans('diff_before_yesterday') !== 'diff_before_yesterday' &&
$translator->trans('diff_after_tomorrow') !== 'diff_after_tomorrow';
});
}
/**
* Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
* Support is considered enabled if the 4 sentences are translated in the given locale.
*
* @param string $locale locale ex. en
*
* @return bool
*/
public static function localeHasPeriodSyntax($locale)
{
return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
return $newLocale &&
$translator->trans('period_recurrences') !== 'period_recurrences' &&
$translator->trans('period_interval') !== 'period_interval' &&
$translator->trans('period_start_date') !== 'period_start_date' &&
$translator->trans('period_end_date') !== 'period_end_date';
});
}
/**
* Returns the list of internally available locales and already loaded custom locales.
* (It will ignore custom translator dynamic loading.)
*
* @return array
*/
public static function getAvailableLocales()
{
$translator = static::getLocaleAwareTranslator();
return $translator instanceof Translator
? $translator->getAvailableLocales()
: [$translator->getLocale()];
}
/**
* Returns list of Language object for each available locale. This object allow you to get the ISO name, native
* name, region and variant of the locale.
*
* @return Language[]
*/
public static function getAvailableLocalesInfo()
{
$languages = [];
foreach (static::getAvailableLocales() as $id) {
$languages[$id] = new Language($id);
}
return $languages;
}
/**
* Get the locale of a given translator.
*
* If null or omitted, current local translator is used.
* If no local translator is in use, current global translator is used.
*/
protected function getTranslatorLocale($translator = null): ?string
{
if (\func_num_args() === 0) {
$translator = $this->getLocalTranslator();
}
$translator = static::getLocaleAwareTranslator($translator);
return $translator?->getLocale();
}
/**
* Throw an error if passed object is not LocaleAwareInterface.
*
* @param LocaleAwareInterface|null $translator
*
* @return LocaleAwareInterface|null
*/
protected static function getLocaleAwareTranslator($translator = null)
{
if (\func_num_args() === 0) {
$translator = static::getTranslator();
}
if ($translator && !($translator instanceof LocaleAwareInterface || method_exists($translator, 'getLocale'))) {
throw new NotLocaleAwareException($translator); // @codeCoverageIgnore
}
return $translator;
}
/**
* @param mixed $translator
* @param \Symfony\Component\Translation\MessageCatalogueInterface $catalogue
*
* @return mixed
*/
private static function getFromCatalogue($translator, $catalogue, string $id, string $domain = 'messages')
{
return $translator instanceof TranslatorStrongTypeInterface
? $translator->getFromCatalogue($catalogue, $id, $domain)
: $catalogue->get($id, $domain); // @codeCoverageIgnore
}
/**
* Return the word cleaned from its translation codes.
*
* @param string $word
*
* @return string
*/
private static function cleanWordFromTranslationString($word)
{
$word = str_replace([':count', '%count', ':time'], '', $word);
$word = strtr($word, ['' => "'"]);
$word = preg_replace('/({\d+(,(\d+|Inf))?}|[\[\]]\d+(,(\d+|Inf))?[\[\]])/', '', $word);
return trim($word);
}
/**
* Translate a list of words.
*
* @param string[] $keys keys to translate.
* @param string[] $messages messages bag handling translations.
* @param string $key 'to' (to get the translation) or 'from' (to get the detection RegExp pattern).
*
* @return string[]
*/
private static function translateWordsByKeys($keys, $messages, $key): array
{
return array_map(function ($wordKey) use ($messages, $key) {
$message = $key === 'from' && isset($messages[$wordKey.'_regexp'])
? $messages[$wordKey.'_regexp']
: ($messages[$wordKey] ?? null);
if (!$message) {
return '>>DO NOT REPLACE<<';
}
$parts = explode('|', $message);
return $key === 'to'
? self::cleanWordFromTranslationString(end($parts))
: '(?:'.implode('|', array_map([static::class, 'cleanWordFromTranslationString'], $parts)).')';
}, $keys);
}
/**
* Get an array of translations based on the current date.
*
* @param callable $translation
* @param int $length
* @param string $timeString
*
* @return string[]
*/
private static function getTranslationArray($translation, $length, $timeString): array
{
$filler = '>>DO NOT REPLACE<<';
if (\is_array($translation)) {
return array_pad($translation, $length, $filler);
}
$list = [];
$date = static::now();
for ($i = 0; $i < $length; $i++) {
$list[] = $translation($date, $timeString, $i) ?? $filler;
}
return $list;
}
private static function replaceOrdinalWords(string $timeString, array $ordinalWords): string
{
return preg_replace_callback('/(?<![a-z])[a-z]+(?![a-z])/i', function (array $match) use ($ordinalWords) {
return $ordinalWords[mb_strtolower($match[0])] ?? $match[0];
}, $timeString);
}
}
+109
View File
@@ -0,0 +1,109 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
use Carbon\FactoryImmutable;
/**
* Trait Macros.
*
* Allows users to register macros within the Carbon class.
*/
trait Macro
{
use Mixin;
/**
* Register a custom macro.
*
* Pass null macro to remove it.
*
* @example
* ```
* $userSettings = [
* 'locale' => 'pt',
* 'timezone' => 'America/Sao_Paulo',
* ];
* Carbon::macro('userFormat', function () use ($userSettings) {
* return $this->copy()->locale($userSettings['locale'])->tz($userSettings['timezone'])->calendar();
* });
* echo Carbon::yesterday()->hours(11)->userFormat();
* ```
*/
public static function macro(string $name, ?callable $macro): void
{
FactoryImmutable::getDefaultInstance()->macro($name, $macro);
}
/**
* Remove all macros and generic macros.
*/
public static function resetMacros(): void
{
FactoryImmutable::getDefaultInstance()->resetMacros();
}
/**
* Register a custom macro.
*
* @param callable $macro
* @param int $priority marco with higher priority is tried first
*
* @return void
*/
public static function genericMacro(callable $macro, int $priority = 0): void
{
FactoryImmutable::getDefaultInstance()->genericMacro($macro, $priority);
}
/**
* Checks if macro is registered globally.
*
* @param string $name
*
* @return bool
*/
public static function hasMacro(string $name): bool
{
return FactoryImmutable::getInstance()->hasMacro($name);
}
/**
* Get the raw callable macro registered globally for a given name.
*/
public static function getMacro(string $name): ?callable
{
return FactoryImmutable::getInstance()->getMacro($name);
}
/**
* Checks if macro is registered globally or locally.
*/
public function hasLocalMacro(string $name): bool
{
return ($this->localMacros && isset($this->localMacros[$name])) || $this->transmitFactory(
static fn () => static::hasMacro($name),
);
}
/**
* Get the raw callable macro registered globally or locally for a given name.
*/
public function getLocalMacro(string $name): ?callable
{
return ($this->localMacros ?? [])[$name] ?? $this->transmitFactory(
static fn () => static::getMacro($name),
);
}
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\Traits;
/**
* Trait MagicParameter.
*
* Allows to retrieve parameter in magic calls by index or name.
*/
trait MagicParameter
{
private function getMagicParameter(array $parameters, int $index, string $key, $default)
{
if (\array_key_exists($index, $parameters)) {
return $parameters[$index];
}
if (\array_key_exists($key, $parameters)) {
return $parameters[$key];
}
return $default;
}
}

Some files were not shown because too many files have changed in this diff Show More