repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/SrLatnXkTest.php
tests/Localization/SrLatnXkTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class SrLatnXkTest extends LocalizationTestCase { public const LOCALE = 'sr_Latn_XK'; // Serbian public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tomorrow at 12:00 AM' 'sutra u 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Saturday at 12:00 AM' 'u subotu u 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Sunday at 12:00 AM' 'u nedelju u 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Monday at 12:00 AM' 'u ponedeljak u 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tuesday at 12:00 AM' 'u utorak u 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Wednesday at 12:00 AM' 'u sredu u 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) // 'Thursday at 12:00 AM' 'u četvrtak u 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) // 'Friday at 12:00 AM' 'u petak u 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'u utorak u 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Wednesday at 12:00 AM' 'u sredu u 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Thursday at 12:00 AM' 'u četvrtak u 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Friday at 12:00 AM' 'u petak u 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Saturday at 12:00 AM' 'u subotu u 00:00', // Carbon::now()->subDays(2)->calendar() // 'Last Sunday at 8:49 PM' 'prošle nedelje u 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 10:00 PM' 'juče u 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) // 'Today at 10:00 AM' 'danas u 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Today at 2:00 AM' 'danas u 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) // 'Tomorrow at 1:00 AM' 'sutra u 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'u utorak u 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) // 'Yesterday at 12:00 AM' 'juče u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 12:00 AM' 'juče u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Tuesday at 12:00 AM' 'prošlog utorka u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Monday at 12:00 AM' 'prošlog ponedeljka u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Sunday at 12:00 AM' 'prošle nedelje u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Saturday at 12:00 AM' 'prošle subote u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Friday at 12:00 AM' 'prošlog petka u 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) // 'Last Thursday at 12:00 AM' 'prošlog četvrtka u 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) // 'Last Wednesday at 12:00 AM' 'prošle srede u 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Last Friday at 12:00 AM' 'prošlog petka u 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') // '1st 1st 1st 1st 1st' '1. 1. 1. 1. 1.', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') // '2nd 1st' '2. 1.', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') // '3rd 1st' '3. 1.', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') // '4th 1st' '4. 1.', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') // '5th 1st' '5. 1.', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') // '6th 1st' '6. 1.', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') // '7th 1st' '7. 1.', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') // '11th 2nd' '11. 2.', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') // '40th' '40.', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') // '41st' '41.', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') // '100th' '100.', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') // '12:00 am CET' '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 AM, 12:00 am' '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') // '1:30 AM, 1:30 am' '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') // '2:00 AM, 2:00 am' '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') // '6:00 AM, 6:00 am' '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') // '10:00 AM, 10:00 am' '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 PM, 12:00 pm' '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') // '5:00 PM, 5:00 pm' '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') // '9:30 PM, 9:30 pm' '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') // '11:00 PM, 11:00 pm' '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') // '0th' '0.', // Carbon::now()->subSeconds(1)->diffForHumans() // '1 second ago' 'pre 1 sekundu', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) // '1s ago' 'pre 1 sek.', // Carbon::now()->subSeconds(2)->diffForHumans() // '2 seconds ago' 'pre 2 sekunde', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) // '2s ago' 'pre 2 sek.', // Carbon::now()->subMinutes(1)->diffForHumans() // '1 minute ago' 'pre 1 minut', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) // '1m ago' 'pre 1 min.', // Carbon::now()->subMinutes(2)->diffForHumans() // '2 minutes ago' 'pre 2 minuta', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) // '2m ago' 'pre 2 min.', // Carbon::now()->subHours(1)->diffForHumans() // '1 hour ago' 'pre 1 sat', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) // '1h ago' 'pre 1 č.', // Carbon::now()->subHours(2)->diffForHumans() // '2 hours ago' 'pre 2 sata', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) // '2h ago' 'pre 2 č.', // Carbon::now()->subDays(1)->diffForHumans() // '1 day ago' 'pre 1 dan', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) // '1d ago' 'pre 1 d.', // Carbon::now()->subDays(2)->diffForHumans() // '2 days ago' 'pre 2 dana', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) // '2d ago' 'pre 2 d.', // Carbon::now()->subWeeks(1)->diffForHumans() // '1 week ago' 'pre 1 nedelju', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) // '1w ago' 'pre 1 ned.', // Carbon::now()->subWeeks(2)->diffForHumans() // '2 weeks ago' 'pre 2 nedelje', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) // '2w ago' 'pre 2 ned.', // Carbon::now()->subMonths(1)->diffForHumans() // '1 month ago' 'pre 1 mesec', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) // '1mo ago' 'pre 1 mes.', // Carbon::now()->subMonths(2)->diffForHumans() // '2 months ago' 'pre 2 meseca', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) // '2mos ago' 'pre 2 mes.', // Carbon::now()->subYears(1)->diffForHumans() // '1 year ago' 'pre 1 godinu', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) // '1yr ago' 'pre 1 g.', // Carbon::now()->subYears(2)->diffForHumans() // '2 years ago' 'pre 2 godine', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) // '2yrs ago' 'pre 2 g.', // Carbon::now()->addSecond()->diffForHumans() // '1 second from now' 'za 1 sekundu', // Carbon::now()->addSecond()->diffForHumans(null, false, true) // '1s from now' 'za 1 sek.', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) // '1 second after' 'nakon 1 sekundu', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) // '1s after' 'nakon 1 sek.', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) // '1 second before' 'pre 1 sekundu', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) // '1s before' 'pre 1 sek.', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) // '1 second' '1 sekundu', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) // '1s' '1 sek.', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) // '2 seconds' '2 sekunde', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) // '2s' '2 sek.', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) // '1s from now' 'za 1 sek.', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) // '1 minute 1 second' '1 minut 1 sekundu', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) // '2yrs 3mos 1d 1s' '2 g. 3 mes. 1 d. 1 sek.', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) // '3 years from now' 'za 3 godine', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) // '5mos ago' 'pre 5 mes.', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) // '2yrs 3mos 1d 1s ago' 'pre 2 g. 3 mes. 1 d. 1 sek.', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) // '1 week 10 hours' '1 nedelja 10 sati', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1 nedelja 6 dana', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1 nedelja 6 dana', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) // '1 week and 6 days from now' 'za 1 nedelju i 6 dana', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) // '2 weeks 1 hour' '2 nedelje 1 sat', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) // 'an hour from now' 'za 1 sat', // CarbonInterval::days(2)->forHumans() // '2 days' '2 dana', // CarbonInterval::create('P1DT3H')->forHumans(true) // '1d 3h' '1 d. 3 č.', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/EnPnTest.php
tests/Localization/EnPnTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class EnPnTest extends LocalizationTestCase { public const LOCALE = 'en_PN'; // English public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Saturday at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last Sunday at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Thursday at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/TetTest.php
tests/Localization/TetTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class TetTest extends LocalizationTestCase { public const LOCALE = 'tet'; // Tetum public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Aban iha 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sabadu iha 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Domingu iha 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Segunda iha 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tersa iha 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Kuarta iha 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Kinta iha 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Sesta iha 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tersa iha 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Kuarta iha 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Kinta iha 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Sesta iha 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Sabadu iha 00:00', // Carbon::now()->subDays(2)->calendar() 'Domingu semana kotuk iha 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Horiseik iha 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Ohin iha 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Ohin iha 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Aban iha 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tersa iha 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Horiseik iha 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Horiseik iha 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tersa semana kotuk iha 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Segunda semana kotuk iha 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Domingu semana kotuk iha 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sabadu semana kotuk iha 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sesta semana kotuk iha 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Kinta semana kotuk iha 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Kuarta semana kotuk iha 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Sesta semana kotuk iha 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1º 1º 1º 1º 1º', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2º 1º', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3º 1º', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4º 1º', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5º 1º', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6º 1º', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7º 1º', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11º 2º', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40º', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41º', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100º', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0º', // Carbon::now()->subSeconds(1)->diffForHumans() 'segundu 1 liuba', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'segundu 1 liuba', // Carbon::now()->subSeconds(2)->diffForHumans() 'segundu 2 liuba', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'segundu 2 liuba', // Carbon::now()->subMinutes(1)->diffForHumans() 'minutu 1 liuba', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'minutu 1 liuba', // Carbon::now()->subMinutes(2)->diffForHumans() 'minutu 2 liuba', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'minutu 2 liuba', // Carbon::now()->subHours(1)->diffForHumans() 'oras 1 liuba', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'oras 1 liuba', // Carbon::now()->subHours(2)->diffForHumans() 'oras 2 liuba', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'oras 2 liuba', // Carbon::now()->subDays(1)->diffForHumans() 'loron 1 liuba', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'loron 1 liuba', // Carbon::now()->subDays(2)->diffForHumans() 'loron 2 liuba', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'loron 2 liuba', // Carbon::now()->subWeeks(1)->diffForHumans() 'semana 1 liuba', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'semana 1 liuba', // Carbon::now()->subWeeks(2)->diffForHumans() 'semana 2 liuba', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'semana 2 liuba', // Carbon::now()->subMonths(1)->diffForHumans() 'fulan 1 liuba', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'fulan 1 liuba', // Carbon::now()->subMonths(2)->diffForHumans() 'fulan 2 liuba', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'fulan 2 liuba', // Carbon::now()->subYears(1)->diffForHumans() 'tinan 1 liuba', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'tinan 1 liuba', // Carbon::now()->subYears(2)->diffForHumans() 'tinan 2 liuba', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'tinan 2 liuba', // Carbon::now()->addSecond()->diffForHumans() 'iha segundu 1', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'iha segundu 1', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) 'after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) 'before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) 'before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) 'segundu 1', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) 'segundu 1', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) 'segundu 2', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) 'segundu 2', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'iha segundu 1', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) 'minutu 1 segundu 1', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) 'tinan 2 fulan 3 loron 1 segundu 1', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'iha tinan 3', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'fulan 5 liuba', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'tinan 2 fulan 3 loron 1 segundu 1 liuba', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) 'semana 1 oras 10', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'semana 1 loron 6', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'semana 1 loron 6', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'iha semana 1 loron 6', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) 'semana 2 oras 1', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'iha oras ida', // CarbonInterval::days(2)->forHumans() 'loron 2', // CarbonInterval::create('P1DT3H')->forHumans(true) 'loron 1 oras 3', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/EnAuTest.php
tests/Localization/EnAuTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class EnAuTest extends LocalizationTestCase { public const LOCALE = 'en_AU'; // English public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Saturday at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last Sunday at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Thursday at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() 'in 1 second', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'in 1s', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'in 1s', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'in 3 years', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'in 1 week and 6 days', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'in an hour', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/EnZmTest.php
tests/Localization/EnZmTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class EnZmTest extends LocalizationTestCase { public const LOCALE = 'en_ZM'; // English public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Saturday at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last Sunday at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Thursday at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/HaNeTest.php
tests/Localization/HaNeTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class HaNeTest extends LocalizationTestCase { public const LOCALE = 'ha_NE'; // Hausa public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Asabar at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Lahadi at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Litini at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Talata at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Laraba at 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Alhamis at 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Jumaʼa at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Talata at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Laraba at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Alhamis at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jumaʼa at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Asabar at 00:00', // Carbon::now()->subDays(2)->calendar() 'Last Lahadi at 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Talata at 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Talata at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Litini at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Lahadi at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Asabar at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jumaʼa at 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Alhamis at 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Laraba at 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Jumaʼa at 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 ná bíyú ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 ná bíyú ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 ná bíyú ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 ná bíyú ago', // Carbon::now()->subMinutes(1)->diffForHumans() 'minti 1 ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'minti 1 ago', // Carbon::now()->subMinutes(2)->diffForHumans() 'minti 2 ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'minti 2 ago', // Carbon::now()->subHours(1)->diffForHumans() '1 áwàa ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 áwàa ago', // Carbon::now()->subHours(2)->diffForHumans() '2 áwàa ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 áwàa ago', // Carbon::now()->subDays(1)->diffForHumans() '1 rana ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 rana ago', // Carbon::now()->subDays(2)->diffForHumans() '2 rana ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 rana ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 mako ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 mako ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 mako ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 mako ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 wátàa ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 wátàa ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 wátàa ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 wátàa ago', // Carbon::now()->subYears(1)->diffForHumans() 'shekara 1 ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'shekara 1 ago', // Carbon::now()->subYears(2)->diffForHumans() 'shekara 2 ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'shekara 2 ago', // Carbon::now()->addSecond()->diffForHumans() '1 ná bíyú from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1 ná bíyú from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 ná bíyú after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 ná bíyú after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 ná bíyú before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 ná bíyú before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 ná bíyú', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 ná bíyú', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 ná bíyú', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 ná bíyú', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1 ná bíyú from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) 'minti 1 1 ná bíyú', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) 'shekara 2 3 wátàa 1 rana 1 ná bíyú', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'shekara 3 from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 wátàa ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'shekara 2 3 wátàa 1 rana 1 ná bíyú ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 mako 10 áwàa', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 mako 6 rana', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 mako 6 rana', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 mako and 6 rana from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 mako 1 áwàa', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '1 áwàa from now', // CarbonInterval::days(2)->forHumans() '2 rana', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 rana 3 áwàa', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/GuTest.php
tests/Localization/GuTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class GuTest extends LocalizationTestCase { public const LOCALE = 'gu'; // Gujarati public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'કાલે રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'શનિવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'રવિવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'સોમવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'મંગળવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'બુધ્વાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'ગુરુવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'શુક્રવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'મંગળવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'બુધ્વાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ગુરુવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'શુક્રવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'શનિવાર, રાત 12:00 વાગ્યે', // Carbon::now()->subDays(2)->calendar() 'પાછલા રવિવાર, રાત 8:49 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ગઇકાલે રાત 10:00 વાગ્યે', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'આજ બપોર 10:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'આજ રાત 2:00 વાગ્યે', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'કાલે રાત 1:00 વાગ્યે', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'મંગળવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'ગઇકાલે રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ગઇકાલે રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'પાછલા મંગળવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'પાછલા સોમવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'પાછલા રવિવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'પાછલા શનિવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'પાછલા શુક્રવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'પાછલા ગુરુવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'પાછલા બુધ્વાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'પાછલા શુક્રવાર, રાત 12:00 વાગ્યે', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1 1 1 1 1', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2 1', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3 1', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4 1', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5 1', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6 1', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7 2', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11 2', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 રાત CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 રાત, 12:00 રાત', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 રાત, 1:30 રાત', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 રાત, 2:00 રાત', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 સવાર, 6:00 સવાર', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 બપોર, 10:00 બપોર', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 બપોર, 12:00 બપોર', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 સાંજ, 5:00 સાંજ', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 રાત, 9:30 રાત', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 રાત, 11:00 રાત', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0', // Carbon::now()->subSeconds(1)->diffForHumans() 'અમુક પળો પેહલા', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1સે. પેહલા', // Carbon::now()->subSeconds(2)->diffForHumans() '2 સેકંડ પેહલા', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2સે. પેહલા', // Carbon::now()->subMinutes(1)->diffForHumans() 'એક મિનિટ પેહલા', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1મિ. પેહલા', // Carbon::now()->subMinutes(2)->diffForHumans() '2 મિનિટ પેહલા', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2મિ. પેહલા', // Carbon::now()->subHours(1)->diffForHumans() 'એક કલાક પેહલા', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1ક. પેહલા', // Carbon::now()->subHours(2)->diffForHumans() '2 કલાક પેહલા', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2ક. પેહલા', // Carbon::now()->subDays(1)->diffForHumans() 'એક દિવસ પેહલા', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1દિ. પેહલા', // Carbon::now()->subDays(2)->diffForHumans() '2 દિવસ પેહલા', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2દિ. પેહલા', // Carbon::now()->subWeeks(1)->diffForHumans() '1 અઠવાડિયું પેહલા', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1અઠ. પેહલા', // Carbon::now()->subWeeks(2)->diffForHumans() '2 અઠવાડિયા પેહલા', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2અઠ. પેહલા', // Carbon::now()->subMonths(1)->diffForHumans() 'એક મહિનો પેહલા', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1મહિનો પેહલા', // Carbon::now()->subMonths(2)->diffForHumans() '2 મહિના પેહલા', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2મહિના પેહલા', // Carbon::now()->subYears(1)->diffForHumans() 'એક વર્ષ પેહલા', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1વર્ષ પેહલા', // Carbon::now()->subYears(2)->diffForHumans() '2 વર્ષ પેહલા', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2વર્ષો પેહલા', // Carbon::now()->addSecond()->diffForHumans() 'અમુક પળો મા', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1સે. મા', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'અમુક પળો પછી', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1સે. પછી', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) 'અમુક પળો પહેલા', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1સે. પહેલા', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) 'અમુક પળો', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1સે.', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 સેકંડ', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2સે.', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1સે. મા', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) 'એક મિનિટ અમુક પળો', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2વર્ષો 3મહિના 1દિ. 1સે.', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 વર્ષ મા', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5મહિના પેહલા', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2વર્ષો 3મહિના 1દિ. 1સે. પેહલા', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 અઠવાડિયું 10 કલાક', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 અઠવાડિયું 6 દિવસ', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 અઠવાડિયું 6 દિવસ', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 અઠવાડિયું અને 6 દિવસ મા', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 અઠવાડિયા એક કલાક', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'એક કલાક મા', // CarbonInterval::days(2)->forHumans() '2 દિવસ', // CarbonInterval::create('P1DT3H')->forHumans(true) '1દિ. 3ક.', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/HuTest.php
tests/Localization/HuTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class HuTest extends LocalizationTestCase { public const LOCALE = 'hu'; // Hungarian public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'holnap 0:00-kor', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'szombaton 0:00-kor', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'vasárnap 0:00-kor', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'hétfőn 0:00-kor', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'kedden 0:00-kor', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'szerdán 0:00-kor', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'csütörtökön 0:00-kor', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'pénteken 0:00-kor', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'kedden 0:00-kor', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'szerdán 0:00-kor', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'csütörtökön 0:00-kor', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'pénteken 0:00-kor', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'szombaton 0:00-kor', // Carbon::now()->subDays(2)->calendar() 'múlt vasárnap 20:49-kor', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'tegnap 22:00-kor', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'ma 10:00-kor', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ma 2:00-kor', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'holnap 1:00-kor', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'kedden 0:00-kor', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'tegnap 0:00-kor', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'tegnap 0:00-kor', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'múlt kedden 0:00-kor', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'múlt hétfőn 0:00-kor', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'múlt vasárnap 0:00-kor', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'múlt szombaton 0:00-kor', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'múlt pénteken 0:00-kor', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'múlt csütörtökön 0:00-kor', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'múlt szerdán 0:00-kor', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'múlt pénteken 0:00-kor', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1. 1. 1. 1. 1.', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2. 1.', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3. 1.', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4. 1.', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5. 1.', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6. 1.', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7. 1.', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11. 2.', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40.', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41.', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100.', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 de CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 DE, 12:00 de', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 DE, 1:30 de', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 DE, 2:00 de', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 DE, 6:00 de', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 DE, 10:00 de', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 DU, 12:00 du', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 DU, 5:00 du', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 DU, 9:30 du', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 DU, 11:00 du', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0.', // Carbon::now()->subSeconds(1)->diffForHumans() '1 másodperce', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 másodperce', // Carbon::now()->subSeconds(2)->diffForHumans() '2 másodperce', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 másodperce', // Carbon::now()->subMinutes(1)->diffForHumans() '1 perce', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1 perce', // Carbon::now()->subMinutes(2)->diffForHumans() '2 perce', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2 perce', // Carbon::now()->subHours(1)->diffForHumans() '1 órája', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 órája', // Carbon::now()->subHours(2)->diffForHumans() '2 órája', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 órája', // Carbon::now()->subDays(1)->diffForHumans() '1 napja', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 napja', // Carbon::now()->subDays(2)->diffForHumans() '2 napja', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 napja', // Carbon::now()->subWeeks(1)->diffForHumans() '1 hete', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 hete', // Carbon::now()->subWeeks(2)->diffForHumans() '2 hete', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 hete', // Carbon::now()->subMonths(1)->diffForHumans() '1 hónapja', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 hónapja', // Carbon::now()->subMonths(2)->diffForHumans() '2 hónapja', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 hónapja', // Carbon::now()->subYears(1)->diffForHumans() '1 éve', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 éve', // Carbon::now()->subYears(2)->diffForHumans() '2 éve', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 éve', // Carbon::now()->addSecond()->diffForHumans() '1 másodperc múlva', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1 másodperc múlva', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 másodperccel később', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 másodperccel később', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 másodperccel korábban', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 másodperccel korábban', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 másodperc', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 másodperc', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 másodperc', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 másodperc', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1 másodperc múlva', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 perc 1 másodperc', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 év 3 hónap 1 nap 1 másodperc', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 év múlva', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 hónapja', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 éve 3 hónapja 1 napja 1 másodperce', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 hét 10 óra', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 hét 6 nap', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 hét 6 nap', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 hét és 6 nap múlva', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 hét 1 óra', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '1 óra múlva', // CarbonInterval::days(2)->forHumans() '2 nap', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 nap 3 óra', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/EnVcTest.php
tests/Localization/EnVcTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class EnVcTest extends LocalizationTestCase { public const LOCALE = 'en_VC'; // English public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Saturday at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last Sunday at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Thursday at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/IuCaTest.php
tests/Localization/IuCaTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class IuCaTest extends LocalizationTestCase { public const LOCALE = 'iu_CA'; // Inuktitut public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ᓯᕙᑖᕕᒃ at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ᓈᑦᑎᖑᔭᕐᕕᒃ at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ᓇᒡᒐᔾᔭᐅ at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ᓇᒡᒐᔾᔭᐅᓕᖅᑭᑦ at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ᐱᖓᓲᓕᖅᓯᐅᑦ at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'ᕿᑎᖅᑰᑦ at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'ᐅᓪᓗᕈᓘᑐᐃᓇᖅ at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ᓇᒡᒐᔾᔭᐅᓕᖅᑭᑦ at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ᐱᖓᓲᓕᖅᓯᐅᑦ at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ᕿᑎᖅᑰᑦ at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ᐅᓪᓗᕈᓘᑐᐃᓇᖅ at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ᓯᕙᑖᕕᒃ at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last ᓈᑦᑎᖑᔭᕐᕕᒃ at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ᓇᒡᒐᔾᔭᐅᓕᖅᑭᑦ at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ᓇᒡᒐᔾᔭᐅᓕᖅᑭᑦ at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ᓇᒡᒐᔾᔭᐅ at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ᓈᑦᑎᖑᔭᕐᕕᒃ at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ᓯᕙᑖᕕᒃ at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ᐅᓪᓗᕈᓘᑐᐃᓇᖅ at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last ᕿᑎᖅᑰᑦ at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last ᐱᖓᓲᓕᖅᓯᐅᑦ at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last ᐅᓪᓗᕈᓘᑐᐃᓇᖅ at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 marluk ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 marluk ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 marluk ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 marluk ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 titiqqaralaaq ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1 titiqqaralaaq ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 titiqqaralaaq ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2 titiqqaralaaq ago', // Carbon::now()->subHours(1)->diffForHumans() '1 ikarraq ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 ikarraq ago', // Carbon::now()->subHours(2)->diffForHumans() '2 ikarraq ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 ikarraq ago', // Carbon::now()->subDays(1)->diffForHumans() '1 ulloq ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 ulloq ago', // Carbon::now()->subDays(2)->diffForHumans() '2 ulloq ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 ulloq ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 sapaatip akunnera ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 sapaatip akunnera ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 sapaatip akunnera ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 sapaatip akunnera ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 qaammat ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 qaammat ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 qaammat ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 qaammat ago', // Carbon::now()->subYears(1)->diffForHumans() '1 ᐅᑭᐅᖅ ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 ᐅᑭᐅᖅ ago', // Carbon::now()->subYears(2)->diffForHumans() '2 ᐅᑭᐅᖅ ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 ᐅᑭᐅᖅ ago', // Carbon::now()->addSecond()->diffForHumans() '1 marluk from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1 marluk from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 marluk after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 marluk after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 marluk before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 marluk before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 marluk', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 marluk', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 marluk', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 marluk', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1 marluk from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 titiqqaralaaq 1 marluk', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 ᐅᑭᐅᖅ 3 qaammat 1 ulloq 1 marluk', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 ᐅᑭᐅᖅ from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 qaammat ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 ᐅᑭᐅᖅ 3 qaammat 1 ulloq 1 marluk ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 sapaatip akunnera 10 ikarraq', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 sapaatip akunnera 6 ulloq', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 sapaatip akunnera 6 ulloq', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 sapaatip akunnera and 6 ulloq from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 sapaatip akunnera 1 ikarraq', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '1 ikarraq from now', // CarbonInterval::days(2)->forHumans() '2 ulloq', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 ulloq 3 ikarraq', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/FrMaTest.php
tests/Localization/FrMaTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class FrMaTest extends LocalizationTestCase { public const LOCALE = 'fr_MA'; // French public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Demain à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'samedi à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'dimanche à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'lundi à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mardi à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mercredi à 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'jeudi à 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'vendredi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'mardi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'mercredi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'jeudi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'vendredi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'samedi à 00:00', // Carbon::now()->subDays(2)->calendar() 'dimanche dernier à 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hier à 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Aujourd’hui à 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Aujourd’hui à 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Demain à 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'mardi à 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Hier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mardi dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'lundi dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'dimanche dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'samedi dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'vendredi dernier à 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'jeudi dernier à 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'mercredi dernier à 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'vendredi dernier à 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1er 1er 1er 1re 1re', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2 1re', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3 1re', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4 1re', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5 1re', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6 2e', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7 2e', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11 2e', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40e', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41e', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100e', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0e', // Carbon::now()->subSeconds(1)->diffForHumans() 'il y a 1 seconde', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'il y a 1 s', // Carbon::now()->subSeconds(2)->diffForHumans() 'il y a 2 secondes', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'il y a 2 s', // Carbon::now()->subMinutes(1)->diffForHumans() 'il y a 1 minute', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'il y a 1 min', // Carbon::now()->subMinutes(2)->diffForHumans() 'il y a 2 minutes', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'il y a 2 min', // Carbon::now()->subHours(1)->diffForHumans() 'il y a 1 heure', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'il y a 1 h', // Carbon::now()->subHours(2)->diffForHumans() 'il y a 2 heures', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'il y a 2 h', // Carbon::now()->subDays(1)->diffForHumans() 'il y a 1 jour', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'il y a 1 j', // Carbon::now()->subDays(2)->diffForHumans() 'il y a 2 jours', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'il y a 2 j', // Carbon::now()->subWeeks(1)->diffForHumans() 'il y a 1 semaine', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'il y a 1 sem.', // Carbon::now()->subWeeks(2)->diffForHumans() 'il y a 2 semaines', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'il y a 2 sem.', // Carbon::now()->subMonths(1)->diffForHumans() 'il y a 1 mois', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'il y a 1 mois', // Carbon::now()->subMonths(2)->diffForHumans() 'il y a 2 mois', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'il y a 2 mois', // Carbon::now()->subYears(1)->diffForHumans() 'il y a 1 an', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'il y a 1 an', // Carbon::now()->subYears(2)->diffForHumans() 'il y a 2 ans', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'il y a 2 ans', // Carbon::now()->addSecond()->diffForHumans() 'dans 1 seconde', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'dans 1 s', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 seconde après', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 s après', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 seconde avant', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 s avant', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 seconde', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 secondes', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'dans 1 s', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 seconde', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 ans 3 mois 1 j 1 s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'dans 3 ans', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'il y a 5 mois', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'il y a 2 ans 3 mois 1 j 1 s', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 semaine 10 heures', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semaine 6 jours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semaine 6 jours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'dans 1 semaine et 6 jours', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 semaines 1 heure', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'dans une heure', // CarbonInterval::days(2)->forHumans() '2 jours', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 j 3 h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/ZhHantTwTest.php
tests/Localization/ZhHantTwTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class ZhHantTwTest extends LocalizationTestCase { public const LOCALE = 'zh_Hant_TW'; // Chinese public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tomorrow at 12:00 AM' '明天 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Saturday at 12:00 AM' '下星期六 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Sunday at 12:00 AM' '下星期日 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Monday at 12:00 AM' '下星期一 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tuesday at 12:00 AM' '下星期二 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Wednesday at 12:00 AM' '下星期三 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) // 'Thursday at 12:00 AM' '下星期四 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) // 'Friday at 12:00 AM' '下星期五 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' '下星期二 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Wednesday at 12:00 AM' '下星期三 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Thursday at 12:00 AM' '下星期四 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Friday at 12:00 AM' '下星期五 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Saturday at 12:00 AM' '下星期六 00:00', // Carbon::now()->subDays(2)->calendar() // 'Last Sunday at 8:49 PM' '上星期日 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 10:00 PM' '昨天 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) // 'Today at 10:00 AM' '今天 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Today at 2:00 AM' '今天 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) // 'Tomorrow at 1:00 AM' '明天 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' '下星期二 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) // 'Yesterday at 12:00 AM' '昨天 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 12:00 AM' '昨天 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Tuesday at 12:00 AM' '上星期二 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Monday at 12:00 AM' '上星期一 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Sunday at 12:00 AM' '上星期日 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Saturday at 12:00 AM' '上星期六 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Friday at 12:00 AM' '上星期五 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) // 'Last Thursday at 12:00 AM' '上星期四 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) // 'Last Wednesday at 12:00 AM' '上星期三 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Last Friday at 12:00 AM' '上星期五 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') // '1st 1st 1st 1st 1st' '1月 1月 1日 1周 1周', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') // '2nd 1st' '2日 1周', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') // '3rd 1st' '3日 1周', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') // '4th 1st' '4日 1周', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') // '5th 1st' '5日 1周', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') // '6th 1st' '6日 1周', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') // '7th 2nd' '7日 1周', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') // '11th 2nd' '11日 2周', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') // '40th' '40日', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') // '41st' '41日', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') // '100th' '100日', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') // '12:00 am CET' '12:00 凌晨 CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 AM, 12:00 am' '12:00 凌晨, 12:00 凌晨', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') // '1:30 AM, 1:30 am' '1:30 凌晨, 1:30 凌晨', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') // '2:00 AM, 2:00 am' '2:00 凌晨, 2:00 凌晨', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') // '6:00 AM, 6:00 am' '6:00 早上, 6:00 早上', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') // '10:00 AM, 10:00 am' '10:00 上午, 10:00 上午', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 PM, 12:00 pm' '12:00 中午, 12:00 中午', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') // '5:00 PM, 5:00 pm' '5:00 下午, 5:00 下午', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') // '9:30 PM, 9:30 pm' '9:30 晚上, 9:30 晚上', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') // '11:00 PM, 11:00 pm' '11:00 晚上, 11:00 晚上', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') // '0th' '0', // Carbon::now()->subSeconds(1)->diffForHumans() // '1 second ago' '1秒前', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) // '1s ago' '1秒前', // Carbon::now()->subSeconds(2)->diffForHumans() // '2 seconds ago' '2秒前', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) // '2s ago' '2秒前', // Carbon::now()->subMinutes(1)->diffForHumans() // '1 minute ago' '1分鐘前', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) // '1m ago' '1分鐘前', // Carbon::now()->subMinutes(2)->diffForHumans() // '2 minutes ago' '2分鐘前', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) // '2m ago' '2分鐘前', // Carbon::now()->subHours(1)->diffForHumans() // '1 hour ago' '1小時前', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) // '1h ago' '1小時前', // Carbon::now()->subHours(2)->diffForHumans() // '2 hours ago' '2小時前', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) // '2h ago' '2小時前', // Carbon::now()->subDays(1)->diffForHumans() // '1 day ago' '1天前', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) // '1d ago' '1天前', // Carbon::now()->subDays(2)->diffForHumans() // '2 days ago' '2天前', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) // '2d ago' '2天前', // Carbon::now()->subWeeks(1)->diffForHumans() // '1 week ago' '1週前', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) // '1w ago' '1週前', // Carbon::now()->subWeeks(2)->diffForHumans() // '2 weeks ago' '2週前', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) // '2w ago' '2週前', // Carbon::now()->subMonths(1)->diffForHumans() // '1 month ago' '1個月前', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) // '1mo ago' '1月前', // Carbon::now()->subMonths(2)->diffForHumans() // '2 months ago' '2個月前', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) // '2mos ago' '2月前', // Carbon::now()->subYears(1)->diffForHumans() // '1 year ago' '1年前', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) // '1yr ago' '1年前', // Carbon::now()->subYears(2)->diffForHumans() // '2 years ago' '2年前', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) // '2yrs ago' '2年前', // Carbon::now()->addSecond()->diffForHumans() // '1 second from now' '1秒後', // Carbon::now()->addSecond()->diffForHumans(null, false, true) // '1s from now' '1秒後', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) // '1 second after' '1秒後', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) // '1s after' '1秒後', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) // '1 second before' '1秒前', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) // '1s before' '1秒前', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) // '1 second' '1秒', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) // '1s' '1秒', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) // '2 seconds' '2秒', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) // '2s' '2秒', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) // '1s from now' '1秒後', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) // '1 minute 1 second' '1分鐘1秒', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) // '2yrs 3mos 1d 1s' '2年3月1天1秒', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) // '3 years from now' '3年後', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) // '5mos ago' '5月前', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) // '2yrs 3mos 1d 1s ago' '2年3月1天1秒前', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) // '1 week 10 hours' '1週10小時', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1週6天', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1週6天', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) // '1 week and 6 days from now' '1週6天後', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) // '2 weeks 1 hour' '2週1小時', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) // 'an hour from now' '1小時後', // CarbonInterval::days(2)->forHumans() // '2 days' '2天', // CarbonInterval::create('P1DT3H')->forHumans(true) // '1d 3h' '1天3小時', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/ZhHantMoTest.php
tests/Localization/ZhHantMoTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class ZhHantMoTest extends LocalizationTestCase { public const LOCALE = 'zh_Hant_MO'; // Chinese public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tomorrow at 12:00 AM' '明天 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Saturday at 12:00 AM' '下星期六 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Sunday at 12:00 AM' '下星期日 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Monday at 12:00 AM' '下星期一 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tuesday at 12:00 AM' '下星期二 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Wednesday at 12:00 AM' '下星期三 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) // 'Thursday at 12:00 AM' '下星期四 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) // 'Friday at 12:00 AM' '下星期五 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' '下星期二 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Wednesday at 12:00 AM' '下星期三 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Thursday at 12:00 AM' '下星期四 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Friday at 12:00 AM' '下星期五 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Saturday at 12:00 AM' '下星期六 00:00', // Carbon::now()->subDays(2)->calendar() // 'Last Sunday at 8:49 PM' '上星期日 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 10:00 PM' '昨天 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) // 'Today at 10:00 AM' '今天 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Today at 2:00 AM' '今天 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) // 'Tomorrow at 1:00 AM' '明天 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' '下星期二 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) // 'Yesterday at 12:00 AM' '昨天 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 12:00 AM' '昨天 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Tuesday at 12:00 AM' '上星期二 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Monday at 12:00 AM' '上星期一 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Sunday at 12:00 AM' '上星期日 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Saturday at 12:00 AM' '上星期六 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Friday at 12:00 AM' '上星期五 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) // 'Last Thursday at 12:00 AM' '上星期四 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) // 'Last Wednesday at 12:00 AM' '上星期三 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Last Friday at 12:00 AM' '上星期五 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') // '1st 1st 1st 1st 1st' '1月 1月 1日 1周 1周', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') // '2nd 1st' '2日 1周', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') // '3rd 1st' '3日 1周', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') // '4th 1st' '4日 1周', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') // '5th 1st' '5日 1周', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') // '6th 1st' '6日 1周', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') // '7th 2nd' '7日 1周', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') // '11th 2nd' '11日 2周', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') // '40th' '40日', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') // '41st' '41日', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') // '100th' '100日', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') // '12:00 am CET' '12:00 凌晨 CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 AM, 12:00 am' '12:00 凌晨, 12:00 凌晨', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') // '1:30 AM, 1:30 am' '1:30 凌晨, 1:30 凌晨', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') // '2:00 AM, 2:00 am' '2:00 凌晨, 2:00 凌晨', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') // '6:00 AM, 6:00 am' '6:00 早上, 6:00 早上', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') // '10:00 AM, 10:00 am' '10:00 上午, 10:00 上午', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 PM, 12:00 pm' '12:00 中午, 12:00 中午', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') // '5:00 PM, 5:00 pm' '5:00 下午, 5:00 下午', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') // '9:30 PM, 9:30 pm' '9:30 晚上, 9:30 晚上', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') // '11:00 PM, 11:00 pm' '11:00 晚上, 11:00 晚上', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') // '0th' '0', // Carbon::now()->subSeconds(1)->diffForHumans() // '1 second ago' '1秒前', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) // '1s ago' '1秒前', // Carbon::now()->subSeconds(2)->diffForHumans() // '2 seconds ago' '2秒前', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) // '2s ago' '2秒前', // Carbon::now()->subMinutes(1)->diffForHumans() // '1 minute ago' '1分鐘前', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) // '1m ago' '1分鐘前', // Carbon::now()->subMinutes(2)->diffForHumans() // '2 minutes ago' '2分鐘前', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) // '2m ago' '2分鐘前', // Carbon::now()->subHours(1)->diffForHumans() // '1 hour ago' '1小時前', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) // '1h ago' '1小時前', // Carbon::now()->subHours(2)->diffForHumans() // '2 hours ago' '2小時前', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) // '2h ago' '2小時前', // Carbon::now()->subDays(1)->diffForHumans() // '1 day ago' '1天前', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) // '1d ago' '1天前', // Carbon::now()->subDays(2)->diffForHumans() // '2 days ago' '2天前', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) // '2d ago' '2天前', // Carbon::now()->subWeeks(1)->diffForHumans() // '1 week ago' '1週前', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) // '1w ago' '1週前', // Carbon::now()->subWeeks(2)->diffForHumans() // '2 weeks ago' '2週前', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) // '2w ago' '2週前', // Carbon::now()->subMonths(1)->diffForHumans() // '1 month ago' '1個月前', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) // '1mo ago' '1月前', // Carbon::now()->subMonths(2)->diffForHumans() // '2 months ago' '2個月前', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) // '2mos ago' '2月前', // Carbon::now()->subYears(1)->diffForHumans() // '1 year ago' '1年前', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) // '1yr ago' '1年前', // Carbon::now()->subYears(2)->diffForHumans() // '2 years ago' '2年前', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) // '2yrs ago' '2年前', // Carbon::now()->addSecond()->diffForHumans() // '1 second from now' '1秒後', // Carbon::now()->addSecond()->diffForHumans(null, false, true) // '1s from now' '1秒後', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) // '1 second after' '1秒後', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) // '1s after' '1秒後', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) // '1 second before' '1秒前', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) // '1s before' '1秒前', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) // '1 second' '1秒', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) // '1s' '1秒', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) // '2 seconds' '2秒', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) // '2s' '2秒', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) // '1s from now' '1秒後', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) // '1 minute 1 second' '1分鐘1秒', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) // '2yrs 3mos 1d 1s' '2年3月1天1秒', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) // '3 years from now' '3年後', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) // '5mos ago' '5月前', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) // '2yrs 3mos 1d 1s ago' '2年3月1天1秒前', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) // '1 week 10 hours' '1週10小時', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1週6天', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1週6天', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) // '1 week and 6 days from now' '1週6天後', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) // '2 weeks 1 hour' '2週1小時', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) // 'an hour from now' '1小時後', // CarbonInterval::days(2)->forHumans() // '2 days' '2天', // CarbonInterval::create('P1DT3H')->forHumans(true) // '1d 3h' '1天3小時', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/FrHtTest.php
tests/Localization/FrHtTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class FrHtTest extends LocalizationTestCase { public const LOCALE = 'fr_HT'; // French public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Demain à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'samedi à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'dimanche à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'lundi à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mardi à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mercredi à 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'jeudi à 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'vendredi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'mardi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'mercredi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'jeudi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'vendredi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'samedi à 00:00', // Carbon::now()->subDays(2)->calendar() 'dimanche dernier à 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hier à 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Aujourd’hui à 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Aujourd’hui à 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Demain à 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'mardi à 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Hier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mardi dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'lundi dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'dimanche dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'samedi dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'vendredi dernier à 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'jeudi dernier à 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'mercredi dernier à 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'vendredi dernier à 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1er 1er 1er 1re 1re', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2 1re', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3 1re', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4 1re', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5 1re', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6 1re', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7 1re', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11 2e', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40e', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41e', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100e', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0e', // Carbon::now()->subSeconds(1)->diffForHumans() 'il y a 1 seconde', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'il y a 1 s', // Carbon::now()->subSeconds(2)->diffForHumans() 'il y a 2 secondes', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'il y a 2 s', // Carbon::now()->subMinutes(1)->diffForHumans() 'il y a 1 minute', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'il y a 1 min', // Carbon::now()->subMinutes(2)->diffForHumans() 'il y a 2 minutes', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'il y a 2 min', // Carbon::now()->subHours(1)->diffForHumans() 'il y a 1 heure', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'il y a 1 h', // Carbon::now()->subHours(2)->diffForHumans() 'il y a 2 heures', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'il y a 2 h', // Carbon::now()->subDays(1)->diffForHumans() 'il y a 1 jour', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'il y a 1 j', // Carbon::now()->subDays(2)->diffForHumans() 'il y a 2 jours', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'il y a 2 j', // Carbon::now()->subWeeks(1)->diffForHumans() 'il y a 1 semaine', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'il y a 1 sem.', // Carbon::now()->subWeeks(2)->diffForHumans() 'il y a 2 semaines', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'il y a 2 sem.', // Carbon::now()->subMonths(1)->diffForHumans() 'il y a 1 mois', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'il y a 1 mois', // Carbon::now()->subMonths(2)->diffForHumans() 'il y a 2 mois', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'il y a 2 mois', // Carbon::now()->subYears(1)->diffForHumans() 'il y a 1 an', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'il y a 1 an', // Carbon::now()->subYears(2)->diffForHumans() 'il y a 2 ans', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'il y a 2 ans', // Carbon::now()->addSecond()->diffForHumans() 'dans 1 seconde', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'dans 1 s', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 seconde après', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 s après', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 seconde avant', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 s avant', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 seconde', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 secondes', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'dans 1 s', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 seconde', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 ans 3 mois 1 j 1 s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'dans 3 ans', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'il y a 5 mois', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'il y a 2 ans 3 mois 1 j 1 s', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 semaine 10 heures', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semaine 6 jours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semaine 6 jours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'dans 1 semaine et 6 jours', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 semaines 1 heure', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'dans une heure', // CarbonInterval::days(2)->forHumans() '2 jours', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 j 3 h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/KoKpTest.php
tests/Localization/KoKpTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class KoKpTest extends LocalizationTestCase { public const LOCALE = 'ko_KP'; // Korean public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) '내일 오전 12:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) '토요일 오전 12:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) '일요일 오전 12:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) '월요일 오전 12:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) '화요일 오전 12:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) '수요일 오전 12:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) '목요일 오전 12:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) '금요일 오전 12:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) '화요일 오전 12:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) '수요일 오전 12:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) '목요일 오전 12:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) '금요일 오전 12:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) '토요일 오전 12:00', // Carbon::now()->subDays(2)->calendar() '지난주 일요일 오후 8:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) '어제 오후 10:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) '오늘 오전 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) '오늘 오전 2:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) '내일 오전 1:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) '화요일 오전 12:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) '어제 오전 12:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) '어제 오전 12:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) '지난주 화요일 오전 12:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) '지난주 월요일 오전 12:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) '지난주 일요일 오전 12:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) '지난주 토요일 오전 12:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) '지난주 금요일 오전 12:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) '지난주 목요일 오전 12:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) '지난주 수요일 오전 12:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) '지난주 금요일 오전 12:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1월 1월 1일 1주 1주', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2일 1주', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3일 1주', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4일 1주', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5일 1주', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6일 1주', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7일 1주', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11일 2주', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40일', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41일', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100일', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 오전 CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 오전, 12:00 오전', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 오전, 1:30 오전', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 오전, 2:00 오전', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 오전, 6:00 오전', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 오전, 10:00 오전', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 오후, 12:00 오후', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 오후, 5:00 오후', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 오후, 9:30 오후', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 오후, 11:00 오후', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0', // Carbon::now()->subSeconds(1)->diffForHumans() '1초 전', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1초 전', // Carbon::now()->subSeconds(2)->diffForHumans() '2초 전', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2초 전', // Carbon::now()->subMinutes(1)->diffForHumans() '1분 전', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1분 전', // Carbon::now()->subMinutes(2)->diffForHumans() '2분 전', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2분 전', // Carbon::now()->subHours(1)->diffForHumans() '1시간 전', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1시간 전', // Carbon::now()->subHours(2)->diffForHumans() '2시간 전', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2시간 전', // Carbon::now()->subDays(1)->diffForHumans() '1일 전', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1일 전', // Carbon::now()->subDays(2)->diffForHumans() '2일 전', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2일 전', // Carbon::now()->subWeeks(1)->diffForHumans() '1주 전', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1주일 전', // Carbon::now()->subWeeks(2)->diffForHumans() '2주 전', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2주일 전', // Carbon::now()->subMonths(1)->diffForHumans() '1개월 전', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1개월 전', // Carbon::now()->subMonths(2)->diffForHumans() '2개월 전', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2개월 전', // Carbon::now()->subYears(1)->diffForHumans() '1년 전', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1년 전', // Carbon::now()->subYears(2)->diffForHumans() '2년 전', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2년 전', // Carbon::now()->addSecond()->diffForHumans() '1초 후', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1초 후', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1초 후', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1초 후', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1초 전', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1초 전', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1초', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1초', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2초', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2초', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1초 후', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1분 1초', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2년 3개월 1일 1초', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3년 후', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5개월 전', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2년 3개월 1일 1초 전', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1주 10시간', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1주 6일', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1주 6일', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1주 6일 후', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2주 1시간', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '한시간 후', // CarbonInterval::days(2)->forHumans() '2일', // CarbonInterval::create('P1DT3H')->forHumans(true) '1일 3시간', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/TtRuIqtelifTest.php
tests/Localization/TtRuIqtelifTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class TtRuIqtelifTest extends LocalizationTestCase { public const LOCALE = 'tt_RU@iqtelif'; // Tatar public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tomorrow at 12:00 AM' 'Tomorrow at 12:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Saturday at 12:00 AM' 'Şimbe at 12:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Sunday at 12:00 AM' 'Yekşembí at 12:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Monday at 12:00 AM' 'Düşembí at 12:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tuesday at 12:00 AM' 'Sişembí at 12:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Wednesday at 12:00 AM' 'Çerşembí at 12:00 ÖA', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) // 'Thursday at 12:00 AM' 'Pencíşembí at 12:00 ÖA', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) // 'Friday at 12:00 AM' 'Comğa at 12:00 ÖA', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'Sişembí at 12:00 ÖA', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Wednesday at 12:00 AM' 'Çerşembí at 12:00 ÖA', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Thursday at 12:00 AM' 'Pencíşembí at 12:00 ÖA', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Friday at 12:00 AM' 'Comğa at 12:00 ÖA', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Saturday at 12:00 AM' 'Şimbe at 12:00 ÖA', // Carbon::now()->subDays(2)->calendar() // 'Last Sunday at 8:49 PM' 'Last Yekşembí at 8:49 ÖS', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 10:00 PM' 'Yesterday at 10:00 ÖS', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) // 'Today at 10:00 AM' 'Today at 10:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Today at 2:00 AM' 'Today at 2:00 ÖA', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) // 'Tomorrow at 1:00 AM' 'Tomorrow at 1:00 ÖA', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'Sişembí at 12:00 ÖA', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) // 'Yesterday at 12:00 AM' 'Yesterday at 12:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 12:00 AM' 'Yesterday at 12:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Tuesday at 12:00 AM' 'Last Sişembí at 12:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Monday at 12:00 AM' 'Last Düşembí at 12:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Sunday at 12:00 AM' 'Last Yekşembí at 12:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Saturday at 12:00 AM' 'Last Şimbe at 12:00 ÖA', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Friday at 12:00 AM' 'Last Comğa at 12:00 ÖA', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) // 'Last Thursday at 12:00 AM' 'Last Pencíşembí at 12:00 ÖA', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) // 'Last Wednesday at 12:00 AM' 'Last Çerşembí at 12:00 ÖA', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Last Friday at 12:00 AM' 'Last Comğa at 12:00 ÖA', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') // '1st 1st 1st 1st 1st' '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') // '2nd 1st' '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') // '3rd 1st' '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') // '4th 1st' '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') // '5th 1st' '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') // '6th 1st' '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') // '7th 1st' '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') // '11th 2nd' '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') // '40th' '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') // '41st' '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') // '100th' '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') // '12:00 am CET' '12:00 öa CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 AM, 12:00 am' '12:00 ÖA, 12:00 öa', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') // '1:30 AM, 1:30 am' '1:30 ÖA, 1:30 öa', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') // '2:00 AM, 2:00 am' '2:00 ÖA, 2:00 öa', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') // '6:00 AM, 6:00 am' '6:00 ÖA, 6:00 öa', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') // '10:00 AM, 10:00 am' '10:00 ÖA, 10:00 öa', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 PM, 12:00 pm' '12:00 ÖS, 12:00 ös', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') // '5:00 PM, 5:00 pm' '5:00 ÖS, 5:00 ös', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') // '9:30 PM, 9:30 pm' '9:30 ÖS, 9:30 ös', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') // '11:00 PM, 11:00 pm' '11:00 ÖS, 11:00 ös', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') // '0th' '0th', // Carbon::now()->subSeconds(1)->diffForHumans() // '1 second ago' '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) // '1s ago' '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() // '2 seconds ago' '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) // '2s ago' '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() // '1 minute ago' '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) // '1m ago' '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() // '2 minutes ago' '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) // '2m ago' '2m ago', // Carbon::now()->subHours(1)->diffForHumans() // '1 hour ago' '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) // '1h ago' '1h ago', // Carbon::now()->subHours(2)->diffForHumans() // '2 hours ago' '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) // '2h ago' '2h ago', // Carbon::now()->subDays(1)->diffForHumans() // '1 day ago' '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) // '1d ago' '1d ago', // Carbon::now()->subDays(2)->diffForHumans() // '2 days ago' '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) // '2d ago' '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() // '1 week ago' '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) // '1w ago' '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() // '2 weeks ago' '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) // '2w ago' '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() // '1 month ago' '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) // '1mo ago' '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() // '2 months ago' '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) // '2mos ago' '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() // '1 year ago' '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) // '1yr ago' '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() // '2 years ago' '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) // '2yrs ago' '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() // '1 second from now' '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) // '1s from now' '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) // '1 second after' '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) // '1s after' '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) // '1 second before' '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) // '1s before' '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) // '1 second' '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) // '1s' '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) // '2 seconds' '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) // '2s' '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) // '1s from now' '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) // '1 minute 1 second' '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) // '2yrs 3mos 1d 1s' '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) // '3 years from now' '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) // '5mos ago' '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) // '2yrs 3mos 1d 1s ago' '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) // '1 week 10 hours' '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) // '1 week and 6 days from now' '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) // '2 weeks 1 hour' '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) // 'an hour from now' 'an hour from now', // CarbonInterval::days(2)->forHumans() // '2 days' '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) // '1d 3h' '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/LtLtTest.php
tests/Localization/LtLtTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class LtLtTest extends LocalizationTestCase { public const LOCALE = 'lt_LT'; // Lithuanian public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tomorrow at 12:00 AM' 'Rytoj 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Saturday at 12:00 AM' 'šeštadienį 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Sunday at 12:00 AM' 'sekmadienį 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Monday at 12:00 AM' 'pirmadienį 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tuesday at 12:00 AM' 'antradienį 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Wednesday at 12:00 AM' 'trečiadienį 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) // 'Thursday at 12:00 AM' 'ketvirtadienį 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) // 'Friday at 12:00 AM' 'penktadienį 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'antradienį 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Wednesday at 12:00 AM' 'trečiadienį 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Thursday at 12:00 AM' 'ketvirtadienį 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Friday at 12:00 AM' 'penktadienį 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Saturday at 12:00 AM' 'šeštadienį 00:00', // Carbon::now()->subDays(2)->calendar() // 'Last Sunday at 8:49 PM' 'Paskutinį sekmadienį 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 10:00 PM' 'Vakar 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) // 'Today at 10:00 AM' 'Šiandien 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Today at 2:00 AM' 'Šiandien 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) // 'Tomorrow at 1:00 AM' 'Rytoj 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'antradienį 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) // 'Yesterday at 12:00 AM' 'Vakar 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 12:00 AM' 'Vakar 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Tuesday at 12:00 AM' 'Paskutinį antradienį 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Monday at 12:00 AM' 'Paskutinį pirmadienį 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Sunday at 12:00 AM' 'Paskutinį sekmadienį 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Saturday at 12:00 AM' 'Paskutinį šeštadienį 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Friday at 12:00 AM' 'Paskutinį penktadienį 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) // 'Last Thursday at 12:00 AM' 'Paskutinį ketvirtadienį 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) // 'Last Wednesday at 12:00 AM' 'Paskutinį trečiadienį 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Last Friday at 12:00 AM' 'Paskutinį penktadienį 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') // '1st 1st 1st 1st 1st' '1-as 1-as 1-as 1-as 1-as', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') // '2nd 1st' '2-as 1-as', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') // '3rd 1st' '3-ias 1-as', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') // '4th 1st' '4-as 1-as', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') // '5th 1st' '5-as 1-as', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') // '6th 1st' '6-as 1-as', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') // '7th 1st' '7-as 1-as', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') // '11th 2nd' '11-as 2-as', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') // '40th' '40-as', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') // '41st' '41-as', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') // '100th' '100-as', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') // '12:00 am CET' '12:00 priešpiet CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 AM, 12:00 am' '12:00 priešpiet, 12:00 priešpiet', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') // '1:30 AM, 1:30 am' '1:30 priešpiet, 1:30 priešpiet', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') // '2:00 AM, 2:00 am' '2:00 priešpiet, 2:00 priešpiet', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') // '6:00 AM, 6:00 am' '6:00 priešpiet, 6:00 priešpiet', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') // '10:00 AM, 10:00 am' '10:00 priešpiet, 10:00 priešpiet', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 PM, 12:00 pm' '12:00 popiet, 12:00 popiet', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') // '5:00 PM, 5:00 pm' '5:00 popiet, 5:00 popiet', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') // '9:30 PM, 9:30 pm' '9:30 popiet, 9:30 popiet', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') // '11:00 PM, 11:00 pm' '11:00 popiet, 11:00 popiet', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') // '0th' '0-is', // Carbon::now()->subSeconds(1)->diffForHumans() // '1 second ago' 'prieš 1 sekundę', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) // '1s ago' 'prieš 1 sek.', // Carbon::now()->subSeconds(2)->diffForHumans() // '2 seconds ago' 'prieš 2 sekundes', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) // '2s ago' 'prieš 2 sek.', // Carbon::now()->subMinutes(1)->diffForHumans() // '1 minute ago' 'prieš 1 minutę', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) // '1m ago' 'prieš 1 min.', // Carbon::now()->subMinutes(2)->diffForHumans() // '2 minutes ago' 'prieš 2 minutes', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) // '2m ago' 'prieš 2 min.', // Carbon::now()->subHours(1)->diffForHumans() // '1 hour ago' 'prieš 1 valandą', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) // '1h ago' 'prieš 1 val.', // Carbon::now()->subHours(2)->diffForHumans() // '2 hours ago' 'prieš 2 valandas', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) // '2h ago' 'prieš 2 val.', // Carbon::now()->subDays(1)->diffForHumans() // '1 day ago' 'prieš 1 dieną', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) // '1d ago' 'prieš 1 d.', // Carbon::now()->subDays(2)->diffForHumans() // '2 days ago' 'prieš 2 dienas', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) // '2d ago' 'prieš 2 d.', // Carbon::now()->subWeeks(1)->diffForHumans() // '1 week ago' 'prieš 1 savaitę', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) // '1w ago' 'prieš 1 sav.', // Carbon::now()->subWeeks(2)->diffForHumans() // '2 weeks ago' 'prieš 2 savaites', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) // '2w ago' 'prieš 2 sav.', // Carbon::now()->subMonths(1)->diffForHumans() // '1 month ago' 'prieš 1 mėnesį', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) // '1mo ago' 'prieš 1 mėn.', // Carbon::now()->subMonths(2)->diffForHumans() // '2 months ago' 'prieš 2 mėnesius', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) // '2mos ago' 'prieš 2 mėn.', // Carbon::now()->subYears(1)->diffForHumans() // '1 year ago' 'prieš 1 metus', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) // '1yr ago' 'prieš 1 m.', // Carbon::now()->subYears(2)->diffForHumans() // '2 years ago' 'prieš 2 metus', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) // '2yrs ago' 'prieš 2 m.', // Carbon::now()->addSecond()->diffForHumans() // '1 second from now' '1 sekundė nuo dabar', // Carbon::now()->addSecond()->diffForHumans(null, false, true) // '1s from now' '1 sek. nuo dabar', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) // '1 second after' 'po 1 sekundė', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) // '1s after' 'po 1 sek.', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) // '1 second before' 'už 1 sekundės', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) // '1s before' 'už 1 sek.', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) // '1 second' '1 sekundė', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) // '1s' '1 sek.', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) // '2 seconds' '2 sekundės', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) // '2s' '2 sek.', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) // '1s from now' '1 sek. nuo dabar', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) // '1 minute 1 second' '1 minutė 1 sekundė', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) // '2yrs 3mos 1d 1s' '2 m. 3 mėn. 1 d. 1 sek.', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) // '3 years from now' '3 metai nuo dabar', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) // '5mos ago' 'prieš 5 mėn.', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) // '2yrs 3mos 1d 1s ago' 'prieš 2 m. 3 mėn. 1 d. 1 sek.', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) // '1 week 10 hours' '1 savaitė 10 valandų', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1 savaitė 6 dienos', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1 savaitė 6 dienos', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) // '1 week and 6 days from now' '1 savaitė ir 6 dienos nuo dabar', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) // '2 weeks 1 hour' '2 savaitės 1 valanda', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) // 'an hour from now' '1 valanda nuo dabar', // CarbonInterval::days(2)->forHumans() // '2 days' '2 dienos', // CarbonInterval::create('P1DT3H')->forHumans(true) // '1d 3h' '1 d. 3 val.', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/VaiVaiiTest.php
tests/Localization/VaiVaiiTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class VaiVaiiTest extends LocalizationTestCase { public const LOCALE = 'vai_Vaii'; // Vai public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 am', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ꔻꔬꔳ at 12:00 am', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ꕞꕌꔵ at 12:00 am', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ꗳꗡꘉ at 12:00 am', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ꕚꕞꕚ at 12:00 am', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ꕉꕞꕒ at 12:00 am', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'ꕉꔤꕆꕢ at 12:00 am', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'ꕉꔤꕀꕮ at 12:00 am', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ꕚꕞꕚ at 12:00 am', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ꕉꕞꕒ at 12:00 am', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ꕉꔤꕆꕢ at 12:00 am', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ꕉꔤꕀꕮ at 12:00 am', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ꔻꔬꔳ at 12:00 am', // Carbon::now()->subDays(2)->calendar() 'Last ꕞꕌꔵ at 8:49 pm', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 pm', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 am', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 am', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 am', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ꕚꕞꕚ at 12:00 am', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 am', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 am', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ꕚꕞꕚ at 12:00 am', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ꗳꗡꘉ at 12:00 am', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ꕞꕌꔵ at 12:00 am', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ꔻꔬꔳ at 12:00 am', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ꕉꔤꕀꕮ at 12:00 am', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last ꕉꔤꕆꕢ at 12:00 am', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last ꕉꕞꕒ at 12:00 am', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last ꕉꔤꕀꕮ at 12:00 am', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 ꗱꕞꕯꕊ ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 ꗱꕞꕯꕊ ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 ꗱꕞꕯꕊ ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 ꗱꕞꕯꕊ ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 ꕀ ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 ꕀ ago', // Carbon::now()->subYears(2)->diffForHumans() '2 ꕀ ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 ꕀ ago', // Carbon::now()->addSecond()->diffForHumans() '1 ꗱꕞꕯꕊ from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1 ꗱꕞꕯꕊ from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 ꗱꕞꕯꕊ after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 ꗱꕞꕯꕊ after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 ꗱꕞꕯꕊ before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 ꗱꕞꕯꕊ before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 ꗱꕞꕯꕊ', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 ꗱꕞꕯꕊ', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 ꗱꕞꕯꕊ', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 ꗱꕞꕯꕊ', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1 ꗱꕞꕯꕊ from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 ꗱꕞꕯꕊ', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 ꕀ 3mos 1d 1 ꗱꕞꕯꕊ', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 ꕀ from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 ꕀ 3mos 1d 1 ꗱꕞꕯꕊ ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/BsCyrlTest.php
tests/Localization/BsCyrlTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class BsCyrlTest extends LocalizationTestCase { public const LOCALE = 'bs_Cyrl'; // Bosnian public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'sutra u 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'u subotu u 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'u nedjelju u 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'u понедјељак u 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'u уторак u 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'u srijedu u 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'u четвртак u 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'u петак u 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u уторак u 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u srijedu u 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u четвртак u 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u петак u 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u subotu u 00:00', // Carbon::now()->subDays(2)->calendar() 'prošlu недјеља u 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'jučer u 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'danas u 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'danas u 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'sutra u 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u уторак u 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'jučer u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'jučer u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'prošli уторак u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'prošli понедјељак u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'prošlu недјеља u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'prošle subote u 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'prošli петак u 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'prošli четвртак u 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'prošlu сриједа u 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'prošli петак u 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1. 1. 1. 1. 1.', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2. 1.', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3. 1.', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4. 1.', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5. 1.', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6. 1.', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7. 1.', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11. 2.', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40.', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41.', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100.', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 пре подне CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 пре подне, 12:00 пре подне', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 пре подне, 1:30 пре подне', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 пре подне, 2:00 пре подне', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 пре подне, 6:00 пре подне', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 пре подне, 10:00 пре подне', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 поподне, 12:00 поподне', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 поподне, 5:00 поподне', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 поподне, 9:30 поподне', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 поподне, 11:00 поподне', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0.', // Carbon::now()->subSeconds(1)->diffForHumans() 'prije 1 sekund', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'prije 1 sekund', // Carbon::now()->subSeconds(2)->diffForHumans() 'prije 2 sekunda', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'prije 2 sekunda', // Carbon::now()->subMinutes(1)->diffForHumans() 'prije 1 minut', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'prije 1 minut', // Carbon::now()->subMinutes(2)->diffForHumans() 'prije 2 minuta', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'prije 2 minuta', // Carbon::now()->subHours(1)->diffForHumans() 'prije 1 sat', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'prije 1 sat', // Carbon::now()->subHours(2)->diffForHumans() 'prije 2 sata', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'prije 2 sata', // Carbon::now()->subDays(1)->diffForHumans() 'prije 1 dan', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'prije 1 dan', // Carbon::now()->subDays(2)->diffForHumans() 'prije 2 dana', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'prije 2 dana', // Carbon::now()->subWeeks(1)->diffForHumans() 'prije 1 sedmicu', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'prije 1 sedmica', // Carbon::now()->subWeeks(2)->diffForHumans() 'prije 2 sedmice', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'prije 2 sedmice', // Carbon::now()->subMonths(1)->diffForHumans() 'prije 1 mjesec', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'prije 1 mjesec', // Carbon::now()->subMonths(2)->diffForHumans() 'prije 2 mjeseca', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'prije 2 mjeseca', // Carbon::now()->subYears(1)->diffForHumans() 'prije 1 godinu', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'prije 1 godina', // Carbon::now()->subYears(2)->diffForHumans() 'prije 2 godine', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'prije 2 godine', // Carbon::now()->addSecond()->diffForHumans() 'za 1 sekund', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'za 1 sekund', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'nakon 1 sekund', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) 'nakon 1 sekund', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 sekund ranije', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 sekund ranije', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 sekund', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 sekund', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 sekunda', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 sekunda', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'za 1 sekund', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minut 1 sekund', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 godine 3 mjeseca 1 dan 1 sekund', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'za 3 godine', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'prije 5 mjeseci', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'prije 2 godine 3 mjeseca 1 dan 1 sekund', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 sedmica 10 sati', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 sedmica 6 dana', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 sedmica 6 dana', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'za 1 sedmicu i 6 dana', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 sedmice 1 sat', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'za 1 sat', // CarbonInterval::days(2)->forHumans() '2 dana', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 dan 3 sata', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/AnTest.php
tests/Localization/AnTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class AnTest extends LocalizationTestCase { public const LOCALE = 'an'; // Aragonese public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'sabado at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'domingo at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'luns at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'martes at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mierques at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'chueves at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'viernes at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'martes at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'mierques at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'chueves at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'viernes at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'sabado at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last domingo at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'martes at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last martes at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last luns at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last domingo at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last sabado at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last viernes at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last chueves at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last mierques at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last viernes at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 segundo ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 segundo ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 segundo ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 segundo ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minuto ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1 minuto ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minuto ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2 minuto ago', // Carbon::now()->subHours(1)->diffForHumans() '1 reloch ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 reloch ago', // Carbon::now()->subHours(2)->diffForHumans() '2 reloch ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 reloch ago', // Carbon::now()->subDays(1)->diffForHumans() '1 día ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 día ago', // Carbon::now()->subDays(2)->diffForHumans() '2 día ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 día ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 semana ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 semana ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 semana ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 semana ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 mes ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 mes ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 mes ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 mes ago', // Carbon::now()->subYears(1)->diffForHumans() '1 año ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 año ago', // Carbon::now()->subYears(2)->diffForHumans() '2 año ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 año ago', // Carbon::now()->addSecond()->diffForHumans() '1 segundo from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1 segundo from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 segundo after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 segundo after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 segundo before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 segundo before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 segundo', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 segundo', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 segundo', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 segundo', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1 segundo from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minuto 1 segundo', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 año 3 mes 1 día 1 segundo', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 año from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 mes ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 año 3 mes 1 día 1 segundo ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 semana 10 reloch', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semana 6 día', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semana 6 día', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 semana and 6 día from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 semana 1 reloch', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '1 reloch from now', // CarbonInterval::days(2)->forHumans() '2 día', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 día 3 reloch', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/EnTtTest.php
tests/Localization/EnTtTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class EnTtTest extends LocalizationTestCase { public const LOCALE = 'en_TT'; // English public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Saturday at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last Sunday at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Thursday at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/MasTest.php
tests/Localization/MasTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class MasTest extends LocalizationTestCase { public const LOCALE = 'mas'; // Masai public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jumamósi at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jumapílí at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jumatátu at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jumane at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jumatánɔ at 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Alaámisi at 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Jumáa at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jumane at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jumatánɔ at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Alaámisi at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jumáa at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jumamósi at 00:00', // Carbon::now()->subDays(2)->calendar() 'Last Jumapílí at 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jumane at 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jumane at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jumatátu at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jumapílí at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jumamósi at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jumáa at 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Alaámisi at 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Jumatánɔ at 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Jumáa at 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 ɛnkakɛnyá CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 Ɛnkakɛnyá, 12:00 ɛnkakɛnyá', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 Ɛnkakɛnyá, 1:30 ɛnkakɛnyá', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 Ɛnkakɛnyá, 2:00 ɛnkakɛnyá', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 Ɛnkakɛnyá, 6:00 ɛnkakɛnyá', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 Ɛnkakɛnyá, 10:00 ɛnkakɛnyá', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 Ɛndámâ, 12:00 ɛndámâ', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 Ɛndámâ, 5:00 ɛndámâ', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 Ɛndámâ, 9:30 ɛndámâ', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 Ɛndámâ, 11:00 ɛndámâ', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 are ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 are ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 are ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 are ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 esahabu ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 esahabu ago', // Carbon::now()->subHours(2)->diffForHumans() '2 esahabu ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 esahabu ago', // Carbon::now()->subDays(1)->diffForHumans() '1 enkolongʼ ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 enkolongʼ ago', // Carbon::now()->subDays(2)->diffForHumans() '2 enkolongʼ ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 enkolongʼ ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 engolongeare orwiki ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 engolongeare orwiki ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 engolongeare orwiki ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 engolongeare orwiki ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 olapa ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 olapa ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 olapa ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 olapa ago', // Carbon::now()->subYears(1)->diffForHumans() '1 olameyu ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 olameyu ago', // Carbon::now()->subYears(2)->diffForHumans() '2 olameyu ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 olameyu ago', // Carbon::now()->addSecond()->diffForHumans() '1 are from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1 are from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 are after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 are after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 are before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 are before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 are', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 are', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 are', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 are', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1 are from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 are', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 olameyu 3 olapa 1 enkolongʼ 1 are', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 olameyu from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 olapa ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 olameyu 3 olapa 1 enkolongʼ 1 are ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 engolongeare orwiki 10 esahabu', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 engolongeare orwiki 6 enkolongʼ', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 engolongeare orwiki 6 enkolongʼ', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 engolongeare orwiki and 6 enkolongʼ from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 engolongeare orwiki 1 esahabu', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '1 esahabu from now', // CarbonInterval::days(2)->forHumans() '2 enkolongʼ', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 enkolongʼ 3 esahabu', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/RuKgTest.php
tests/Localization/RuKgTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class RuKgTest extends LocalizationTestCase { public const LOCALE = 'ru_KG'; // Russian public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Завтра, в 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'В субботу, в 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'В воскресенье, в 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'В следующий понедельник, в 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'В следующий вторник, в 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'В следующую среду, в 0:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'В следующий четверг, в 0:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'В следующую пятницу, в 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'В следующий вторник, в 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'В следующую среду, в 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'В следующий четверг, в 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'В следующую пятницу, в 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'В следующую субботу, в 0:00', // Carbon::now()->subDays(2)->calendar() 'В прошлое воскресенье, в 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Вчера, в 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Сегодня, в 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Сегодня, в 2:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Завтра, в 1:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'В следующий вторник, в 0:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Вчера, в 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Вчера, в 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Во вторник, в 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'В понедельник, в 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'В прошлое воскресенье, в 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'В прошлую субботу, в 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'В прошлую пятницу, в 0:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'В прошлый четверг, в 0:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'В прошлую среду, в 0:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'В пятницу, в 0:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1-й 1-й 1-го 1-я 1-я', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2-го 1-я', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3-го 1-я', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4-го 1-я', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5-го 1-я', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6-го 1-я', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7-го 1-я', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11-го 2-я', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40-й', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41-й', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100-й', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 ночи CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 ночи, 12:00 ночи', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 ночи, 1:30 ночи', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 ночи, 2:00 ночи', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 утра, 6:00 утра', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 утра, 10:00 утра', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 дня, 12:00 дня', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 вечера, 5:00 вечера', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 вечера, 9:30 вечера', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 вечера, 11:00 вечера', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0', // Carbon::now()->subSeconds(1)->diffForHumans() '1 секунду назад', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 сек. назад', // Carbon::now()->subSeconds(2)->diffForHumans() '2 секунды назад', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 сек. назад', // Carbon::now()->subMinutes(1)->diffForHumans() '1 минуту назад', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1 мин. назад', // Carbon::now()->subMinutes(2)->diffForHumans() '2 минуты назад', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2 мин. назад', // Carbon::now()->subHours(1)->diffForHumans() '1 час назад', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 ч. назад', // Carbon::now()->subHours(2)->diffForHumans() '2 часа назад', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 ч. назад', // Carbon::now()->subDays(1)->diffForHumans() '1 день назад', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 д. назад', // Carbon::now()->subDays(2)->diffForHumans() '2 дня назад', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 д. назад', // Carbon::now()->subWeeks(1)->diffForHumans() '1 неделю назад', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 нед. назад', // Carbon::now()->subWeeks(2)->diffForHumans() '2 недели назад', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 нед. назад', // Carbon::now()->subMonths(1)->diffForHumans() '1 месяц назад', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 мес. назад', // Carbon::now()->subMonths(2)->diffForHumans() '2 месяца назад', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 мес. назад', // Carbon::now()->subYears(1)->diffForHumans() '1 год назад', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 г. назад', // Carbon::now()->subYears(2)->diffForHumans() '2 года назад', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 г. назад', // Carbon::now()->addSecond()->diffForHumans() 'через 1 секунду', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'через 1 сек.', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 секунду после', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 сек. после', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 секунду до', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 сек. до', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 секунда', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 сек.', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 секунды', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 сек.', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'через 1 сек.', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 минута 1 секунда', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 г. 3 мес. 1 д. 1 сек.', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'через 3 года', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 мес. назад', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 г. 3 мес. 1 д. 1 сек. назад', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 неделя 10 часов', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 неделя 6 дней', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 неделя 6 дней', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'через 1 неделю и 6 дней', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 недели 1 час', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'через час', // CarbonInterval::days(2)->forHumans() '2 дня', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 д. 3 ч.', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/KsbTest.php
tests/Localization/KsbTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class KsbTest extends LocalizationTestCase { public const LOCALE = 'ksb'; // Shambala public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jumaamosi at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jumaapii at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jumaatatu at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jumaane at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jumaatano at 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Alhamisi at 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Ijumaa at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jumaane at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jumaatano at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Alhamisi at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Ijumaa at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jumaamosi at 00:00', // Carbon::now()->subDays(2)->calendar() 'Last Jumaapii at 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jumaane at 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jumaane at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jumaatatu at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jumaapii at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jumaamosi at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Ijumaa at 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Alhamisi at 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Jumaatano at 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Ijumaa at 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 makeo CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 makeo, 12:00 makeo', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 makeo, 1:30 makeo', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 makeo, 2:00 makeo', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 makeo, 6:00 makeo', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 makeo, 10:00 makeo', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 nyiaghuo, 12:00 nyiaghuo', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 nyiaghuo, 5:00 nyiaghuo', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 nyiaghuo, 9:30 nyiaghuo', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 nyiaghuo, 11:00 nyiaghuo', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/PsAfTest.php
tests/Localization/PsAfTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class PsAfTest extends LocalizationTestCase { public const LOCALE = 'ps_AF'; // Pashto public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'خالي at 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'اتوار at 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ګل at 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'نهه at 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'شورو at 0:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'زيارت at 0:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'جمعه at 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'نهه at 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'شورو at 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'زيارت at 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'جمعه at 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'خالي at 0:00', // Carbon::now()->subDays(2)->calendar() 'Last اتوار at 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'نهه at 0:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last نهه at 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ګل at 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last اتوار at 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last خالي at 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last جمعه at 0:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last زيارت at 0:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last شورو at 0:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last جمعه at 0:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1 1 1 1 1', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2 1', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3 1', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4 1', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5 1', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6 2', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7 2', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11 2', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 غ.م. CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 غ.م., 12:00 غ.م.', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 غ.م., 1:30 غ.م.', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 غ.م., 2:00 غ.م.', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 غ.م., 6:00 غ.م.', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 غ.م., 10:00 غ.م.', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 غ.و., 12:00 غ.و.', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 غ.و., 5:00 غ.و.', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 غ.و., 9:30 غ.و.', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 غ.و., 11:00 غ.و.', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0', // Carbon::now()->subSeconds(1)->diffForHumans() '1 ثانيه دمخه', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1ثانيه دمخه', // Carbon::now()->subSeconds(2)->diffForHumans() '2 ثانيې دمخه', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2ثانيې دمخه', // Carbon::now()->subMinutes(1)->diffForHumans() '1 دقيقه دمخه', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1دقيقه دمخه', // Carbon::now()->subMinutes(2)->diffForHumans() '2 دقيقې دمخه', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2دقيقې دمخه', // Carbon::now()->subHours(1)->diffForHumans() '1 ساعت دمخه', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1ساعت دمخه', // Carbon::now()->subHours(2)->diffForHumans() '2 ساعته دمخه', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2ساعته دمخه', // Carbon::now()->subDays(1)->diffForHumans() '1 ورځ دمخه', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1ورځ دمخه', // Carbon::now()->subDays(2)->diffForHumans() '2 ورځي دمخه', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2ورځي دمخه', // Carbon::now()->subWeeks(1)->diffForHumans() '1 اونۍ دمخه', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1اونۍ دمخه', // Carbon::now()->subWeeks(2)->diffForHumans() '2 اونۍ دمخه', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2اونۍ دمخه', // Carbon::now()->subMonths(1)->diffForHumans() '1 مياشت دمخه', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1مياشت دمخه', // Carbon::now()->subMonths(2)->diffForHumans() '2 مياشتي دمخه', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2مياشتي دمخه', // Carbon::now()->subYears(1)->diffForHumans() '1 کال دمخه', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1کال دمخه', // Carbon::now()->subYears(2)->diffForHumans() '2 کاله دمخه', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2کاله دمخه', // Carbon::now()->addSecond()->diffForHumans() '1 ثانيه له اوس څخه', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1ثانيه له اوس څخه', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 ثانيه وروسته', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1ثانيه وروسته', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 ثانيه دمخه', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1ثانيه دمخه', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 ثانيه', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1ثانيه', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 ثانيې', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2ثانيې', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1ثانيه له اوس څخه', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 دقيقه 1 ثانيه', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2کاله 3مياشتي 1ورځ 1ثانيه', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 کاله له اوس څخه', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5مياشتي دمخه', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2کاله 3مياشتي 1ورځ 1ثانيه دمخه', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 اونۍ 10 ساعته', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 اونۍ 6 ورځي', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 اونۍ 6 ورځي', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 اونۍ او 6 ورځي له اوس څخه', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 اونۍ 1 ساعت', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '1 ساعت له اوس څخه', // CarbonInterval::days(2)->forHumans() '2 ورځي', // CarbonInterval::create('P1DT3H')->forHumans(true) '1ورځ 3ساعته', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/AaTest.php
tests/Localization/AaTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class AaTest extends LocalizationTestCase { public const LOCALE = 'aa'; // Afar public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sabti at 12:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Acaada at 12:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Etleeni at 12:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Talaata at 12:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Arbaqa at 12:00 saaku', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Kamiisi at 12:00 saaku', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Gumqata at 12:00 saaku', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Talaata at 12:00 saaku', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Arbaqa at 12:00 saaku', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Kamiisi at 12:00 saaku', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Gumqata at 12:00 saaku', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Sabti at 12:00 saaku', // Carbon::now()->subDays(2)->calendar() 'Last Acaada at 8:49 carra', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 carra', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 saaku', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 saaku', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Talaata at 12:00 saaku', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Talaata at 12:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Etleeni at 12:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Acaada at 12:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Sabti at 12:00 saaku', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Gumqata at 12:00 saaku', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Kamiisi at 12:00 saaku', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Arbaqa at 12:00 saaku', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Gumqata at 12:00 saaku', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 2nd', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 saaku CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 saaku, 12:00 saaku', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 saaku, 1:30 saaku', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 saaku, 2:00 saaku', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 saaku, 6:00 saaku', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 saaku, 10:00 saaku', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 carra, 12:00 carra', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 carra, 5:00 carra', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 carra, 9:30 carra', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 carra, 11:00 carra', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 ayti ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 ayti ago', // Carbon::now()->subHours(2)->diffForHumans() '2 ayti ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 ayti ago', // Carbon::now()->subDays(1)->diffForHumans() '1 saaku ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 saaku ago', // Carbon::now()->subDays(2)->diffForHumans() '2 saaku ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 saaku ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 àlsa ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 àlsa ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 àlsa ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 àlsa ago', // Carbon::now()->subYears(1)->diffForHumans() '1 gaqambo ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 gaqambo ago', // Carbon::now()->subYears(2)->diffForHumans() '2 gaqambo ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 gaqambo ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 gaqambo 3 àlsa 1 saaku 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 gaqambo from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 àlsa ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 gaqambo 3 àlsa 1 saaku 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 ayti', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 saaku', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 saaku', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 saaku from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 ayti', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '1 ayti from now', // CarbonInterval::days(2)->forHumans() '2 saaku', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 saaku 3 ayti', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/EnSlTest.php
tests/Localization/EnSlTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class EnSlTest extends LocalizationTestCase { public const LOCALE = 'en_SL'; // English public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Saturday at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last Sunday at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Thursday at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/OrInTest.php
tests/Localization/OrInTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class OrInTest extends LocalizationTestCase { public const LOCALE = 'or_IN'; // Oriya public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tomorrow at 12:00 AM', 'Tomorrow at ୧୨:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Saturday at 12:00 AM', 'ଶନିବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Sunday at 12:00 AM', 'ରବିବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Monday at 12:00 AM', 'ସୋମବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tuesday at 12:00 AM', 'ମଙ୍ଗଳବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Wednesday at 12:00 AM', 'ବୁଧବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) // 'Thursday at 12:00 AM', 'ଗୁରୁବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) // 'Friday at 12:00 AM', 'ଶୁକ୍ରବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM', 'ମଙ୍ଗଳବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Wednesday at 12:00 AM', 'ବୁଧବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Thursday at 12:00 AM', 'ଗୁରୁବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Friday at 12:00 AM', 'ଶୁକ୍ରବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Saturday at 12:00 AM', 'ଶନିବାର at ୧୨:୦ AM', // Carbon::now()->subDays(2)->calendar() // 'Last Sunday at 8:49 PM', 'Last ରବିବାର at ୮:୪୯ PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 10:00 PM', 'Yesterday at ୧୦:୦ PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) // 'Today at 10:00 AM', 'Today at ୧୦:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Today at 2:00 AM', 'Today at ୨:୦ AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) // 'Tomorrow at 1:00 AM', 'Tomorrow at ୧:୦ AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM', 'ମଙ୍ଗଳବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) // 'Yesterday at 12:00 AM', 'Yesterday at ୧୨:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 12:00 AM', 'Yesterday at ୧୨:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Tuesday at 12:00 AM', 'Last ମଙ୍ଗଳବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Monday at 12:00 AM', 'Last ସୋମବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Sunday at 12:00 AM', 'Last ରବିବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Saturday at 12:00 AM', 'Last ଶନିବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Friday at 12:00 AM', 'Last ଶୁକ୍ରବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) // 'Last Thursday at 12:00 AM', 'Last ଗୁରୁବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) // 'Last Wednesday at 12:00 AM', 'Last ବୁଧବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Last Friday at 12:00 AM', 'Last ଶୁକ୍ରବାର at ୧୨:୦ AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') // '1st 1st 1st 1st 1st', '1 1 1 1 1', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') // '2nd 1st', '2 1', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') // '3rd 1st', '3 1', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') // '4th 1st', '4 1', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') // '5th 1st', '5 1', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') // '6th 1st', '6 1', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') // '7th 2nd', '7 2', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') // '11th 2nd', '11 2', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') // '40th', '40', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') // '41st', '41', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') // '100th', '100', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') // '12:00 am CET', '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 AM, 12:00 am', '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') // '1:30 AM, 1:30 am', '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') // '2:00 AM, 2:00 am', '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') // '6:00 AM, 6:00 am', '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') // '10:00 AM, 10:00 am', '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 PM, 12:00 pm', '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') // '5:00 PM, 5:00 pm', '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') // '9:30 PM, 9:30 pm', '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') // '11:00 PM, 11:00 pm', '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') // '0th', '0', // Carbon::now()->subSeconds(1)->diffForHumans() // '1 second ago', '1 ସେକଣ୍ଢ ପୂର୍ବେ', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) // '1s ago', '1 ସେ. ପୂର୍ବେ', // Carbon::now()->subSeconds(2)->diffForHumans() // '2 seconds ago', '2 ସେକଣ୍ଢ ପୂର୍ବେ', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) // '2s ago', '2 ସେ. ପୂର୍ବେ', // Carbon::now()->subMinutes(1)->diffForHumans() // '1 minute ago', '1 ମିନଟ ପୂର୍ବେ', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) // '1m ago', '1 ମି. ପୂର୍ବେ', // Carbon::now()->subMinutes(2)->diffForHumans() // '2 minutes ago', '2 ମିନଟ ପୂର୍ବେ', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) // '2m ago', '2 ମି. ପୂର୍ବେ', // Carbon::now()->subHours(1)->diffForHumans() // '1 hour ago', '1 ଘଣ୍ତ ପୂର୍ବେ', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) // '1h ago', '1 ଘ. ପୂର୍ବେ', // Carbon::now()->subHours(2)->diffForHumans() // '2 hours ago', '2 ଘଣ୍ତ ପୂର୍ବେ', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) // '2h ago', '2 ଘ. ପୂର୍ବେ', // Carbon::now()->subDays(1)->diffForHumans() // '1 day ago', '1 ଦିନ ପୂର୍ବେ', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) // '1d ago', '1 ଦିନ ପୂର୍ବେ', // Carbon::now()->subDays(2)->diffForHumans() // '2 days ago', '2 ଦିନ ପୂର୍ବେ', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) // '2d ago', '2 ଦିନ ପୂର୍ବେ', // Carbon::now()->subWeeks(1)->diffForHumans() // '1 week ago', '1 ସପ୍ତାହ ପୂର୍ବେ', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) // '1w ago', '1 ସପ୍ତା. ପୂର୍ବେ', // Carbon::now()->subWeeks(2)->diffForHumans() // '2 weeks ago', '2 ସପ୍ତାହ ପୂର୍ବେ', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) // '2w ago', '2 ସପ୍ତା. ପୂର୍ବେ', // Carbon::now()->subMonths(1)->diffForHumans() // '1 month ago', '1 ମାସ ପୂର୍ବେ', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) // '1mo ago', '1 ମା. ପୂର୍ବେ', // Carbon::now()->subMonths(2)->diffForHumans() // '2 months ago', '2 ମାସ ପୂର୍ବେ', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) // '2mos ago', '2 ମା. ପୂର୍ବେ', // Carbon::now()->subYears(1)->diffForHumans() // '1 year ago', '1 ବର୍ଷ ପୂର୍ବେ', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) // '1yr ago', '1 ବ. ପୂର୍ବେ', // Carbon::now()->subYears(2)->diffForHumans() // '2 years ago', '2 ବର୍ଷ ପୂର୍ବେ', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) // '2yrs ago', '2 ବ. ପୂର୍ବେ', // Carbon::now()->addSecond()->diffForHumans() // '1 second from now', '1 ସେକଣ୍ଢରେ', // Carbon::now()->addSecond()->diffForHumans(null, false, true) // '1s from now', '1 ସେ.ରେ', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) // '1 second after', 'after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) // '1s after', 'after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) // '1 second before', 'before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) // '1s before', 'before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) // '1 second', '1 ସେକଣ୍ଢ', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) // '1s', '1 ସେ.', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) // '2 seconds', '2 ସେକଣ୍ଢ', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) // '2s', '2 ସେ.', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) // '1s from now', '1 ସେ.ରେ', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) // '1 minute 1 second', '1 ମିନଟ 1 ସେକଣ୍ଢ', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) // '2yrs 3mos 1d 1s', '2 ବ. 3 ମା. 1 ଦିନ 1 ସେ.', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) // '3 years from now', '3 ବର୍ଷରେ', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) // '5mos ago', '5 ମା. ପୂର୍ବେ', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) // '2yrs 3mos 1d 1s ago', '2 ବ. 3 ମା. 1 ଦିନ 1 ସେ. ପୂର୍ବେ', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) // '1 week 10 hours', '1 ସପ୍ତାହ 10 ଘଣ୍ତ', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days', '1 ସପ୍ତାହ 6 ଦିନ', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days', '1 ସପ୍ତାହ 6 ଦିନ', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) // '1 week and 6 days from now', '1 ସପ୍ତାହ 6 ଦିନରେ', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) // '2 weeks 1 hour', '2 ସପ୍ତାହ 1 ଘଣ୍ତ', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) // 'an hour from now', '1 ଘଣ୍ତରେ', // CarbonInterval::days(2)->forHumans() // '2 days', '2 ଦିନ', // CarbonInterval::create('P1DT3H')->forHumans(true) // '1d 3h', '1 ଦିନ 3 ଘ.', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/BiTest.php
tests/Localization/BiTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class BiTest extends LocalizationTestCase { public const LOCALE = 'bi'; // Bislama public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'sande at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mande at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'maj at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'wota at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'fraede at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'sarede at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'maj at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'wota at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'fraede at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'sarede at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Saturday at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last sande at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'maj at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last maj at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last mande at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last sande at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last sarede at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last fraede at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last wota at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last sarede at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 tu ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 tu ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 tu ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 tu ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 smol ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1 smol ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 smol ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2 smol ago', // Carbon::now()->subHours(1)->diffForHumans() '1 klok ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 klok ago', // Carbon::now()->subHours(2)->diffForHumans() '2 klok ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 klok ago', // Carbon::now()->subDays(1)->diffForHumans() '1 betde ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 betde ago', // Carbon::now()->subDays(2)->diffForHumans() '2 betde ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 betde ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 sarede ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 sarede ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 sarede ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 sarede ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 mi ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 mi ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 mi ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 mi ago', // Carbon::now()->subYears(1)->diffForHumans() '1 seven ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 seven ago', // Carbon::now()->subYears(2)->diffForHumans() '2 seven ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 seven ago', // Carbon::now()->addSecond()->diffForHumans() '1 tu from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1 tu from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 tu after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 tu after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 tu before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 tu before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 tu', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 tu', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 tu', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 tu', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1 tu from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 smol 1 tu', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 seven 3 mi 1 betde 1 tu', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 seven from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 mi ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 seven 3 mi 1 betde 1 tu ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 sarede 10 klok', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 sarede 6 betde', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 sarede 6 betde', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 sarede and 6 betde from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 sarede 1 klok', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '1 klok from now', // CarbonInterval::days(2)->forHumans() '2 betde', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 betde 3 klok', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/GvTest.php
tests/Localization/GvTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class GvTest extends LocalizationTestCase { public const LOCALE = 'gv'; // Manx public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jesarn at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jedoonee at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jelhein at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jemayrt at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Jercean at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Jerdein at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Jeheiney at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jemayrt at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jercean at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jerdein at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jeheiney at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jesarn at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last Jedoonee at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jemayrt at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jemayrt at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jelhein at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jedoonee at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jesarn at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jeheiney at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Jerdein at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Jercean at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Jeheiney at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 derrey ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 derrey ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 derrey ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 derrey ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 feer veg ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1 feer veg ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 feer veg ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2 feer veg ago', // Carbon::now()->subHours(1)->diffForHumans() '1 oor ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 oor ago', // Carbon::now()->subHours(2)->diffForHumans() '2 oor ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 oor ago', // Carbon::now()->subDays(1)->diffForHumans() '1 laa ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 laa ago', // Carbon::now()->subDays(2)->diffForHumans() '2 laa ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 laa ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 shiaghtin ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 shiaghtin ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 shiaghtin ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 shiaghtin ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 mee ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 mee ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 mee ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 mee ago', // Carbon::now()->subYears(1)->diffForHumans() '1 blein ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 blein ago', // Carbon::now()->subYears(2)->diffForHumans() '2 blein ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 blein ago', // Carbon::now()->addSecond()->diffForHumans() '1 derrey from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1 derrey from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 derrey after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 derrey after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 derrey before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 derrey before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 derrey', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 derrey', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 derrey', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 derrey', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1 derrey from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 feer veg 1 derrey', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 blein 3 mee 1 laa 1 derrey', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 blein from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 mee ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 blein 3 mee 1 laa 1 derrey ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 shiaghtin 10 oor', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 shiaghtin 6 laa', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 shiaghtin 6 laa', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 shiaghtin and 6 laa from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 shiaghtin 1 oor', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '1 oor from now', // CarbonInterval::days(2)->forHumans() '2 laa', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 laa 3 oor', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/TiEtTest.php
tests/Localization/TiEtTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class TiEtTest extends LocalizationTestCase { public const LOCALE = 'ti_ET'; // Tigrinya public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ቀዳም at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ሰንበት at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ሰኑይ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ሰሉስ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ረቡዕ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'ሓሙስ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'ዓርቢ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ሰሉስ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ረቡዕ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ሓሙስ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ዓርቢ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ቀዳም at 12:00 ንጉሆ ሰዓተ', // Carbon::now()->subDays(2)->calendar() 'Last ሰንበት at 8:49 ድሕር ሰዓት', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 ድሕር ሰዓት', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ሰሉስ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ሰሉስ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ሰኑይ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ሰንበት at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ቀዳም at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ዓርቢ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last ሓሙስ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last ረቡዕ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last ዓርቢ at 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 ንጉሆ ሰዓተ CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 ንጉሆ ሰዓተ, 12:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 ንጉሆ ሰዓተ, 1:30 ንጉሆ ሰዓተ', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 ንጉሆ ሰዓተ, 2:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 ንጉሆ ሰዓተ, 6:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 ንጉሆ ሰዓተ, 10:00 ንጉሆ ሰዓተ', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 ድሕር ሰዓት, 12:00 ድሕር ሰዓት', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 ድሕር ሰዓት, 5:00 ድሕር ሰዓት', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 ድሕር ሰዓት, 9:30 ድሕር ሰዓት', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 ድሕር ሰዓት, 11:00 ድሕር ሰዓት', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/NsoZaTest.php
tests/Localization/NsoZaTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class NsoZaTest extends LocalizationTestCase { public const LOCALE = 'nso_ZA'; // Northern Sotho public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mokibelo at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'LaMorena at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mošupologo at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Labobedi at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Laboraro at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Labone at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Labohlano at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Labobedi at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Laboraro at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Labone at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Labohlano at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Mokibelo at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last LaMorena at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Labobedi at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Labobedi at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Mošupologo at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last LaMorena at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Mokibelo at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Labohlano at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Labone at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Laboraro at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Labohlano at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 motsotswana ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 motsotswana ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 motsotswana ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 motsotswana ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 Motsotso ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1 Motsotso ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 Motsotso ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2 Motsotso ago', // Carbon::now()->subHours(1)->diffForHumans() '1 Iri ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 Iri ago', // Carbon::now()->subHours(2)->diffForHumans() '2 Iri ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 Iri ago', // Carbon::now()->subDays(1)->diffForHumans() '1 Letšatši ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 Letšatši ago', // Carbon::now()->subDays(2)->diffForHumans() '2 Letšatši ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 Letšatši ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 Beke ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 Beke ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 Beke ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 Beke ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 Kgwedi ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 Kgwedi ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 Kgwedi ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 Kgwedi ago', // Carbon::now()->subYears(1)->diffForHumans() '1 ngwaga ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 ngwaga ago', // Carbon::now()->subYears(2)->diffForHumans() '2 ngwaga ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 ngwaga ago', // Carbon::now()->addSecond()->diffForHumans() '1 motsotswana from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1 motsotswana from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 motsotswana after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 motsotswana after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 motsotswana before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 motsotswana before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 motsotswana', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 motsotswana', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 motsotswana', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 motsotswana', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1 motsotswana from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 Motsotso 1 motsotswana', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 ngwaga 3 Kgwedi 1 Letšatši 1 motsotswana', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 ngwaga from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 Kgwedi ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 ngwaga 3 Kgwedi 1 Letšatši 1 motsotswana ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 Beke 10 Iri', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 Beke 6 Letšatši', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 Beke 6 Letšatši', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 Beke and 6 Letšatši from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 Beke 1 Iri', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '1 Iri from now', // CarbonInterval::days(2)->forHumans() '2 Letšatši', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 Letšatši 3 Iri', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/BemTest.php
tests/Localization/BemTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class BemTest extends LocalizationTestCase { public const LOCALE = 'bem'; // Bemba public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tomorrow at 12:00 AM' 'Tomorrow at 12:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Saturday at 12:00 AM' 'Pachibelushi at 12:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Sunday at 12:00 AM' 'Pa Mulungu at 12:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Monday at 12:00 AM' 'Palichimo at 12:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tuesday at 12:00 AM' 'Palichibuli at 12:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Wednesday at 12:00 AM' 'Palichitatu at 12:00 uluchelo', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) // 'Thursday at 12:00 AM' 'Palichine at 12:00 uluchelo', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) // 'Friday at 12:00 AM' 'Palichisano at 12:00 uluchelo', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'Palichibuli at 12:00 uluchelo', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Wednesday at 12:00 AM' 'Palichitatu at 12:00 uluchelo', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Thursday at 12:00 AM' 'Palichine at 12:00 uluchelo', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Friday at 12:00 AM' 'Palichisano at 12:00 uluchelo', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Saturday at 12:00 AM' 'Pachibelushi at 12:00 uluchelo', // Carbon::now()->subDays(2)->calendar() // 'Last Sunday at 8:49 PM' 'Last Pa Mulungu at 8:49 akasuba', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 10:00 PM' 'Yesterday at 10:00 akasuba', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) // 'Today at 10:00 AM' 'Today at 10:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Today at 2:00 AM' 'Today at 2:00 uluchelo', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) // 'Tomorrow at 1:00 AM' 'Tomorrow at 1:00 uluchelo', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'Palichibuli at 12:00 uluchelo', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) // 'Yesterday at 12:00 AM' 'Yesterday at 12:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 12:00 AM' 'Yesterday at 12:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Tuesday at 12:00 AM' 'Last Palichibuli at 12:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Monday at 12:00 AM' 'Last Palichimo at 12:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Sunday at 12:00 AM' 'Last Pa Mulungu at 12:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Saturday at 12:00 AM' 'Last Pachibelushi at 12:00 uluchelo', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Friday at 12:00 AM' 'Last Palichisano at 12:00 uluchelo', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) // 'Last Thursday at 12:00 AM' 'Last Palichine at 12:00 uluchelo', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) // 'Last Wednesday at 12:00 AM' 'Last Palichitatu at 12:00 uluchelo', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Last Friday at 12:00 AM' 'Last Palichisano at 12:00 uluchelo', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') // '1st 1st 1st 1st 1st' '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') // '2nd 1st' '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') // '3rd 1st' '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') // '4th 1st' '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') // '5th 1st' '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') // '6th 1st' '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') // '7th 1st' '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') // '11th 2nd' '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') // '40th' '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') // '41st' '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') // '100th' '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') // '12:00 am CET' '12:00 uluchelo CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 AM, 12:00 am' '12:00 uluchelo, 12:00 uluchelo', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') // '1:30 AM, 1:30 am' '1:30 uluchelo, 1:30 uluchelo', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') // '2:00 AM, 2:00 am' '2:00 uluchelo, 2:00 uluchelo', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') // '6:00 AM, 6:00 am' '6:00 uluchelo, 6:00 uluchelo', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') // '10:00 AM, 10:00 am' '10:00 uluchelo, 10:00 uluchelo', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 PM, 12:00 pm' '12:00 akasuba, 12:00 akasuba', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') // '5:00 PM, 5:00 pm' '5:00 akasuba, 5:00 akasuba', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') // '9:30 PM, 9:30 pm' '9:30 akasuba, 9:30 akasuba', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') // '11:00 PM, 11:00 pm' '11:00 akasuba, 11:00 akasuba', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') // '0th' '0th', // Carbon::now()->subSeconds(1)->diffForHumans() // '1 second ago' 'sekondi 1 ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) // '1s ago' 'sekondi 1 ago', // Carbon::now()->subSeconds(2)->diffForHumans() // '2 seconds ago' 'sekondi 2 ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) // '2s ago' 'sekondi 2 ago', // Carbon::now()->subMinutes(1)->diffForHumans() // '1 minute ago' 'miniti 1 ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) // '1m ago' 'miniti 1 ago', // Carbon::now()->subMinutes(2)->diffForHumans() // '2 minutes ago' 'miniti 2 ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) // '2m ago' 'miniti 2 ago', // Carbon::now()->subHours(1)->diffForHumans() // '1 hour ago' 'awala 1 ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) // '1h ago' 'awala 1 ago', // Carbon::now()->subHours(2)->diffForHumans() // '2 hours ago' 'awala 2 ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) // '2h ago' 'awala 2 ago', // Carbon::now()->subDays(1)->diffForHumans() // '1 day ago' 'inshiku 1 ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) // '1d ago' 'inshiku 1 ago', // Carbon::now()->subDays(2)->diffForHumans() // '2 days ago' 'inshiku 2 ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) // '2d ago' 'inshiku 2 ago', // Carbon::now()->subWeeks(1)->diffForHumans() // '1 week ago' 'umulungu 1 ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) // '1w ago' 'umulungu 1 ago', // Carbon::now()->subWeeks(2)->diffForHumans() // '2 weeks ago' 'umulungu 2 ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) // '2w ago' 'umulungu 2 ago', // Carbon::now()->subMonths(1)->diffForHumans() // '1 month ago' 'myeshi 1 ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) // '1mo ago' 'myeshi 1 ago', // Carbon::now()->subMonths(2)->diffForHumans() // '2 months ago' 'myeshi 2 ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) // '2mos ago' 'myeshi 2 ago', // Carbon::now()->subYears(1)->diffForHumans() // '1 year ago' 'myaka 1 ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) // '1yr ago' 'myaka 1 ago', // Carbon::now()->subYears(2)->diffForHumans() // '2 years ago' 'myaka 2 ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) // '2yrs ago' 'myaka 2 ago', // Carbon::now()->addSecond()->diffForHumans() // '1 second from now' 'sekondi 1 from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) // '1s from now' 'sekondi 1 from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) // '1 second after' 'sekondi 1 after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) // '1s after' 'sekondi 1 after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) // '1 second before' 'sekondi 1 before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) // '1s before' 'sekondi 1 before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) // '1 second' 'sekondi 1', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) // '1s' 'sekondi 1', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) // '2 seconds' 'sekondi 2', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) // '2s' 'sekondi 2', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) // '1s from now' 'sekondi 1 from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) // '1 minute 1 second' 'miniti 1 sekondi 1', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) // '2yrs 3mos 1d 1s' 'myaka 2 myeshi 3 inshiku 1 sekondi 1', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) // '3 years from now' 'myaka 3 from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) // '5mos ago' 'myeshi 5 ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) // '2yrs 3mos 1d 1s ago' 'myaka 2 myeshi 3 inshiku 1 sekondi 1 ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) // '1 week 10 hours' 'umulungu 1 awala 10', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' 'umulungu 1 inshiku 6', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' 'umulungu 1 inshiku 6', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) // '1 week and 6 days from now' 'umulungu 1 and inshiku 6 from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) // '2 weeks 1 hour' 'umulungu 2 awala 1', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) // 'an hour from now' 'awala 1 from now', // CarbonInterval::days(2)->forHumans() // '2 days' 'inshiku 2', // CarbonInterval::create('P1DT3H')->forHumans(true) // '1d 3h' 'inshiku 1 awala 3', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/BsTest.php
tests/Localization/BsTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class BsTest extends LocalizationTestCase { public const LOCALE = 'bs'; // Bosnian public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'sutra u 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'u subotu u 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'u nedjelju u 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'u ponedjeljak u 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'u utorak u 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'u srijedu u 0:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'u četvrtak u 0:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'u petak u 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u utorak u 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u srijedu u 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u četvrtak u 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u petak u 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u subotu u 0:00', // Carbon::now()->subDays(2)->calendar() 'prošlu nedjelja u 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'jučer u 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'danas u 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'danas u 2:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'sutra u 1:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'u utorak u 0:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'jučer u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'jučer u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'prošli utorak u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'prošli ponedjeljak u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'prošlu nedjelja u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'prošle subote u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'prošli petak u 0:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'prošli četvrtak u 0:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'prošlu srijeda u 0:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'prošli petak u 0:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1. 1. 1. 1. 1.', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2. 1.', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3. 1.', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4. 1.', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5. 1.', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6. 1.', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7. 1.', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11. 2.', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40.', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41.', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100.', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 prijepodne CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 prijepodne, 12:00 prijepodne', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 prijepodne, 1:30 prijepodne', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 prijepodne, 2:00 prijepodne', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 prijepodne, 6:00 prijepodne', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 prijepodne, 10:00 prijepodne', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 popodne, 12:00 popodne', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 popodne, 5:00 popodne', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 popodne, 9:30 popodne', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 popodne, 11:00 popodne', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0.', // Carbon::now()->subSeconds(1)->diffForHumans() 'prije 1 sekund', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'prije 1 sekund', // Carbon::now()->subSeconds(2)->diffForHumans() 'prije 2 sekunda', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'prije 2 sekunda', // Carbon::now()->subMinutes(1)->diffForHumans() 'prije 1 minut', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'prije 1 minut', // Carbon::now()->subMinutes(2)->diffForHumans() 'prije 2 minuta', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'prije 2 minuta', // Carbon::now()->subHours(1)->diffForHumans() 'prije 1 sat', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'prije 1 sat', // Carbon::now()->subHours(2)->diffForHumans() 'prije 2 sata', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'prije 2 sata', // Carbon::now()->subDays(1)->diffForHumans() 'prije 1 dan', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'prije 1 dan', // Carbon::now()->subDays(2)->diffForHumans() 'prije 2 dana', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'prije 2 dana', // Carbon::now()->subWeeks(1)->diffForHumans() 'prije 1 sedmicu', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'prije 1 sedmica', // Carbon::now()->subWeeks(2)->diffForHumans() 'prije 2 sedmice', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'prije 2 sedmice', // Carbon::now()->subMonths(1)->diffForHumans() 'prije 1 mjesec', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'prije 1 mjesec', // Carbon::now()->subMonths(2)->diffForHumans() 'prije 2 mjeseca', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'prije 2 mjeseca', // Carbon::now()->subYears(1)->diffForHumans() 'prije 1 godinu', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'prije 1 godina', // Carbon::now()->subYears(2)->diffForHumans() 'prije 2 godine', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'prije 2 godine', // Carbon::now()->addSecond()->diffForHumans() 'za 1 sekund', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'za 1 sekund', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'nakon 1 sekund', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) 'nakon 1 sekund', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 sekund ranije', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 sekund ranije', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 sekund', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 sekund', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 sekunda', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 sekunda', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'za 1 sekund', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minut 1 sekund', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 godine 3 mjeseca 1 dan 1 sekund', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'za 3 godine', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'prije 5 mjeseci', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'prije 2 godine 3 mjeseca 1 dan 1 sekund', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 sedmica 10 sati', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 sedmica 6 dana', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 sedmica 6 dana', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'za 1 sedmicu i 6 dana', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 sedmice 1 sat', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'za 1 sat', // CarbonInterval::days(2)->forHumans() '2 dana', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 dan 3 sata', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/EsBrTest.php
tests/Localization/EsBrTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class EsBrTest extends LocalizationTestCase { public const LOCALE = 'es_BR'; // Spanish public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mañana a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'sábado a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'domingo a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'lunes a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'martes a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'miércoles a las 0:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'jueves a las 0:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'viernes a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'martes a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'miércoles a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'jueves a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'viernes a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'sábado a las 0:00', // Carbon::now()->subDays(2)->calendar() 'el domingo pasado a las 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ayer a las 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'hoy a las 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'hoy a las 2:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'mañana a las 1:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'martes a las 0:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'ayer a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ayer a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'el martes pasado a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'el lunes pasado a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'el domingo pasado a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'el sábado pasado a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'el viernes pasado a las 0:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'el jueves pasado a las 0:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'el miércoles pasado a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'el viernes pasado a las 0:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1º 1º 1º 1º 1º', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2º 1º', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3º 1º', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4º 1º', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5º 1º', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6º 1º', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7º 2º', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11º 2º', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40º', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41º', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100º', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 a. m. CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 a. m., 12:00 a. m.', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 a. m., 1:30 a. m.', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 a. m., 2:00 a. m.', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 a. m., 6:00 a. m.', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 a. m., 10:00 a. m.', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 p. m., 12:00 p. m.', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 p. m., 5:00 p. m.', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 p. m., 9:30 p. m.', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 p. m., 11:00 p. m.', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0º', // Carbon::now()->subSeconds(1)->diffForHumans() 'hace 1 segundo', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'hace 1s', // Carbon::now()->subSeconds(2)->diffForHumans() 'hace 2 segundos', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'hace 2s', // Carbon::now()->subMinutes(1)->diffForHumans() 'hace 1 minuto', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'hace 1m', // Carbon::now()->subMinutes(2)->diffForHumans() 'hace 2 minutos', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'hace 2m', // Carbon::now()->subHours(1)->diffForHumans() 'hace 1 hora', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'hace 1h', // Carbon::now()->subHours(2)->diffForHumans() 'hace 2 horas', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'hace 2h', // Carbon::now()->subDays(1)->diffForHumans() 'hace 1 día', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'hace 1d', // Carbon::now()->subDays(2)->diffForHumans() 'hace 2 días', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'hace 2d', // Carbon::now()->subWeeks(1)->diffForHumans() 'hace 1 semana', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'hace 1sem', // Carbon::now()->subWeeks(2)->diffForHumans() 'hace 2 semanas', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'hace 2sem', // Carbon::now()->subMonths(1)->diffForHumans() 'hace 1 mes', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'hace 1 mes', // Carbon::now()->subMonths(2)->diffForHumans() 'hace 2 meses', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'hace 2 meses', // Carbon::now()->subYears(1)->diffForHumans() 'hace 1 año', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'hace 1 año', // Carbon::now()->subYears(2)->diffForHumans() 'hace 2 años', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'hace 2 años', // Carbon::now()->addSecond()->diffForHumans() 'en 1 segundo', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'en 1s', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 segundo después', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s después', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 segundo antes', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s antes', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 segundo', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 segundos', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'en 1s', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minuto 1 segundo', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 años 3 meses 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'en 3 años', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'hace 5 meses', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'hace 2 años 3 meses 1d 1s', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 semana 10 horas', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semana 6 días', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semana 6 días', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'en 1 semana y 6 días', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 semanas 1 hora', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'en una hora', // CarbonInterval::days(2)->forHumans() '2 días', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/WaeTest.php
tests/Localization/WaeTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class WaeTest extends LocalizationTestCase { public const LOCALE = 'wae'; // Walser public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Samschtag at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Suntag at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mäntag at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Zischtag at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mittwuch at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Frontag at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Fritag at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Zischtag at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Mittwuch at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Frontag at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Fritag at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Samschtag at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last Suntag at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Zischtag at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Zischtag at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Mäntag at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Suntag at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Samschtag at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Fritag at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Frontag at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Mittwuch at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Fritag at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 Maano ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 Maano ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 Maano ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 Maano ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3 Maano 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 Maano ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3 Maano 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/ViVnTest.php
tests/Localization/ViVnTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class ViVnTest extends LocalizationTestCase { public const LOCALE = 'vi_VN'; // Vietnamese public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Ngày mai lúc 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'thứ bảy tuần tới lúc 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'chủ nhật tuần tới lúc 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'thứ hai tuần tới lúc 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'thứ ba tuần tới lúc 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'thứ tư tuần tới lúc 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'thứ năm tuần tới lúc 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'thứ sáu tuần tới lúc 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'thứ ba tuần tới lúc 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'thứ tư tuần tới lúc 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'thứ năm tuần tới lúc 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'thứ sáu tuần tới lúc 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'thứ bảy tuần tới lúc 00:00', // Carbon::now()->subDays(2)->calendar() 'chủ nhật tuần trước lúc 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hôm qua lúc 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Hôm nay lúc 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hôm nay lúc 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Ngày mai lúc 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'thứ ba tuần tới lúc 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Hôm qua lúc 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hôm qua lúc 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'thứ ba tuần trước lúc 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'thứ hai tuần trước lúc 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'chủ nhật tuần trước lúc 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'thứ bảy tuần trước lúc 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'thứ sáu tuần trước lúc 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'thứ năm tuần trước lúc 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'thứ tư tuần trước lúc 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'thứ sáu tuần trước lúc 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1 1 1 1 1', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2 1', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3 1', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4 1', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5 1', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6 1', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7 1', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11 2', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 sa CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 SA, 12:00 sa', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 SA, 1:30 sa', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 SA, 2:00 sa', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 SA, 6:00 sa', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 SA, 10:00 sa', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 CH, 12:00 ch', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 CH, 5:00 ch', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 CH, 9:30 ch', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 CH, 11:00 ch', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0', // Carbon::now()->subSeconds(1)->diffForHumans() '1 giây trước', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 giây trước', // Carbon::now()->subSeconds(2)->diffForHumans() '2 giây trước', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 giây trước', // Carbon::now()->subMinutes(1)->diffForHumans() '1 phút trước', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1 phút trước', // Carbon::now()->subMinutes(2)->diffForHumans() '2 phút trước', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2 phút trước', // Carbon::now()->subHours(1)->diffForHumans() '1 giờ trước', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 giờ trước', // Carbon::now()->subHours(2)->diffForHumans() '2 giờ trước', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 giờ trước', // Carbon::now()->subDays(1)->diffForHumans() '1 ngày trước', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 ngày trước', // Carbon::now()->subDays(2)->diffForHumans() '2 ngày trước', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 ngày trước', // Carbon::now()->subWeeks(1)->diffForHumans() '1 tuần trước', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 tuần trước', // Carbon::now()->subWeeks(2)->diffForHumans() '2 tuần trước', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 tuần trước', // Carbon::now()->subMonths(1)->diffForHumans() '1 tháng trước', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 tháng trước', // Carbon::now()->subMonths(2)->diffForHumans() '2 tháng trước', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 tháng trước', // Carbon::now()->subYears(1)->diffForHumans() '1 năm trước', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 năm trước', // Carbon::now()->subYears(2)->diffForHumans() '2 năm trước', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 năm trước', // Carbon::now()->addSecond()->diffForHumans() '1 giây tới', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1 giây tới', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 giây sau', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 giây sau', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 giây trước', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 giây trước', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 giây', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 giây', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 giây', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 giây', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1 giây tới', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 phút 1 giây', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 năm 3 tháng 1 ngày 1 giây', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 năm tới', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 tháng trước', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 năm 3 tháng 1 ngày 1 giây trước', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 tuần 10 giờ', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 tuần 6 ngày', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 tuần 6 ngày', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 tuần và 6 ngày tới', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 tuần 1 giờ', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'một giờ tới', // CarbonInterval::days(2)->forHumans() '2 ngày', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 ngày 3 giờ', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/CggTest.php
tests/Localization/CggTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class CggTest extends LocalizationTestCase { public const LOCALE = 'cgg'; // Chiga public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Orwamukaaga at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sande at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Orwokubanza at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Orwakabiri at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Orwakashatu at 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Orwakana at 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Orwakataano at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Orwakabiri at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Orwakashatu at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Orwakana at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Orwakataano at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Orwamukaaga at 00:00', // Carbon::now()->subDays(2)->calendar() 'Last Sande at 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Orwakabiri at 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Orwakabiri at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Orwokubanza at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Sande at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Orwamukaaga at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Orwakataano at 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Orwakana at 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Orwakashatu at 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Orwakataano at 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 1st', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 ruhanga ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 ruhanga ago', // Carbon::now()->subDays(2)->diffForHumans() '2 ruhanga ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 ruhanga ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1 ruhanga 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1 ruhanga 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 ruhanga', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 ruhanga', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 ruhanga from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 ruhanga', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 ruhanga 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/EsPyTest.php
tests/Localization/EsPyTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class EsPyTest extends LocalizationTestCase { public const LOCALE = 'es_PY'; // Spanish public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mañana a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'sábado a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'domingo a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'lunes a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'martes a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'miércoles a las 0:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'jueves a las 0:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'viernes a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'martes a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'miércoles a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'jueves a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'viernes a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'sábado a las 0:00', // Carbon::now()->subDays(2)->calendar() 'el domingo pasado a las 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ayer a las 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'hoy a las 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'hoy a las 2:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'mañana a las 1:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'martes a las 0:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'ayer a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ayer a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'el martes pasado a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'el lunes pasado a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'el domingo pasado a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'el sábado pasado a las 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'el viernes pasado a las 0:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'el jueves pasado a las 0:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'el miércoles pasado a las 0:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'el viernes pasado a las 0:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1º 1º 1º 1º 1º', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2º 1º', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3º 1º', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4º 1º', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5º 1º', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6º 1º', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7º 2º', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11º 2º', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40º', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41º', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100º', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 a. m. CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 a. m., 12:00 a. m.', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 a. m., 1:30 a. m.', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 a. m., 2:00 a. m.', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 a. m., 6:00 a. m.', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 a. m., 10:00 a. m.', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 p. m., 12:00 p. m.', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 p. m., 5:00 p. m.', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 p. m., 9:30 p. m.', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 p. m., 11:00 p. m.', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0º', // Carbon::now()->subSeconds(1)->diffForHumans() 'hace 1 segundo', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'hace 1s', // Carbon::now()->subSeconds(2)->diffForHumans() 'hace 2 segundos', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'hace 2s', // Carbon::now()->subMinutes(1)->diffForHumans() 'hace 1 minuto', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'hace 1m', // Carbon::now()->subMinutes(2)->diffForHumans() 'hace 2 minutos', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'hace 2m', // Carbon::now()->subHours(1)->diffForHumans() 'hace 1 hora', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'hace 1h', // Carbon::now()->subHours(2)->diffForHumans() 'hace 2 horas', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'hace 2h', // Carbon::now()->subDays(1)->diffForHumans() 'hace 1 día', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'hace 1d', // Carbon::now()->subDays(2)->diffForHumans() 'hace 2 días', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'hace 2d', // Carbon::now()->subWeeks(1)->diffForHumans() 'hace 1 semana', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'hace 1sem', // Carbon::now()->subWeeks(2)->diffForHumans() 'hace 2 semanas', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'hace 2sem', // Carbon::now()->subMonths(1)->diffForHumans() 'hace 1 mes', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'hace 1 mes', // Carbon::now()->subMonths(2)->diffForHumans() 'hace 2 meses', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'hace 2 meses', // Carbon::now()->subYears(1)->diffForHumans() 'hace 1 año', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'hace 1 año', // Carbon::now()->subYears(2)->diffForHumans() 'hace 2 años', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'hace 2 años', // Carbon::now()->addSecond()->diffForHumans() 'en 1 segundo', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'en 1s', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 segundo después', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s después', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 segundo antes', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s antes', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 segundo', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 segundos', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'en 1s', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minuto 1 segundo', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 años 3 meses 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'en 3 años', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'hace 5 meses', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'hace 2 años 3 meses 1d 1s', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 semana 10 horas', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semana 6 días', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semana 6 días', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'en 1 semana y 6 días', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 semanas 1 hora', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'en una hora', // CarbonInterval::days(2)->forHumans() '2 días', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/ArSaTest.php
tests/Localization/ArSaTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class ArSaTest extends LocalizationTestCase { public const LOCALE = 'ar_SA'; // Arabic public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'غدا على الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'السبت على الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الأحد على الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الاثنين على الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الثلاثاء على الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الأربعاء على الساعة 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'الخميس على الساعة 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'الجمعة على الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الثلاثاء على الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الأربعاء على الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الخميس على الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الجمعة على الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'السبت على الساعة 00:00', // Carbon::now()->subDays(2)->calendar() 'الأحد على الساعة 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'أمس على الساعة 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'اليوم على الساعة 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'اليوم على الساعة 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'غدا على الساعة 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الثلاثاء على الساعة 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'أمس على الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'أمس على الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الثلاثاء على الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الاثنين على الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الأحد على الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'السبت على الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الجمعة على الساعة 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'الخميس على الساعة 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'الأربعاء على الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الجمعة على الساعة 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1 1 1 1 1', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2 1', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3 1', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4 1', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5 1', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6 2', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7 2', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11 2', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 ص CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 ص, 12:00 ص', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 ص, 1:30 ص', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 ص, 2:00 ص', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 ص, 6:00 ص', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 ص, 10:00 ص', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 م, 12:00 م', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 م, 5:00 م', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 م, 9:30 م', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 م, 11:00 م', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0', // Carbon::now()->subSeconds(1)->diffForHumans() 'منذ ثانية', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'منذ ثانية', // Carbon::now()->subSeconds(2)->diffForHumans() 'منذ ثانيتين', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'منذ ثانيتين', // Carbon::now()->subMinutes(1)->diffForHumans() 'منذ دقيقة', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'منذ دقيقة', // Carbon::now()->subMinutes(2)->diffForHumans() 'منذ دقيقتين', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'منذ دقيقتين', // Carbon::now()->subHours(1)->diffForHumans() 'منذ ساعة', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'منذ ساعة', // Carbon::now()->subHours(2)->diffForHumans() 'منذ ساعتين', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'منذ ساعتين', // Carbon::now()->subDays(1)->diffForHumans() 'منذ يوم', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'منذ يوم', // Carbon::now()->subDays(2)->diffForHumans() 'منذ يومين', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'منذ يومين', // Carbon::now()->subWeeks(1)->diffForHumans() 'منذ أسبوع', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'منذ أسبوع', // Carbon::now()->subWeeks(2)->diffForHumans() 'منذ أسبوعين', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'منذ أسبوعين', // Carbon::now()->subMonths(1)->diffForHumans() 'منذ شهر', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'منذ شهر', // Carbon::now()->subMonths(2)->diffForHumans() 'منذ شهرين', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'منذ شهرين', // Carbon::now()->subYears(1)->diffForHumans() 'منذ سنة', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'منذ سنة', // Carbon::now()->subYears(2)->diffForHumans() 'منذ سنتين', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'منذ سنتين', // Carbon::now()->addSecond()->diffForHumans() 'في ثانية', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'في ثانية', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'بعد ثانية', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) 'بعد ثانية', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) 'قبل ثانية', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) 'قبل ثانية', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) 'ثانية', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) 'ثانية', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) 'ثانيتين', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) 'ثانيتين', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'في ثانية', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) 'دقيقة ثانية', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) 'سنتين 3 أشهر يوم ثانية', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'في 3 سنوات', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'منذ 5 أشهر', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'منذ سنتين 3 أشهر يوم ثانية', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) 'أسبوع 10 ساعات', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'أسبوع 6 أيام', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'أسبوع 6 أيام', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'في أسبوع و 6 أيام', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) 'أسبوعين ساعة', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'في ساعة', // CarbonInterval::days(2)->forHumans() 'يومين', // CarbonInterval::create('P1DT3H')->forHumans(true) 'يوم 3 ساعات', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/TcyTest.php
tests/Localization/TcyTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class TcyTest extends LocalizationTestCase { public const LOCALE = 'tcy'; // Tulu public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ಶನಿವಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ಐಥಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ಸೋಮಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ಅಂಗರೆ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ಬುಧಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'ಗುರುವಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'ಶುಕ್ರರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ಅಂಗರೆ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ಬುಧಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ಗುರುವಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ಶುಕ್ರರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ಶನಿವಾರ at 12:00 ಕಾಂಡೆ', // Carbon::now()->subDays(2)->calendar() 'Last ಐಥಾರ at 8:49 ಬಯ್ಯ', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 ಬಯ್ಯ', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ಅಂಗರೆ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ಅಂಗರೆ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ಸೋಮಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ಐಥಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ಶನಿವಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last ಶುಕ್ರರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last ಗುರುವಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last ಬುಧಾರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last ಶುಕ್ರರ at 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 ಕಾಂಡೆ CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 ಕಾಂಡೆ, 12:00 ಕಾಂಡೆ', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 ಕಾಂಡೆ, 1:30 ಕಾಂಡೆ', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 ಕಾಂಡೆ, 2:00 ಕಾಂಡೆ', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 ಕಾಂಡೆ, 6:00 ಕಾಂಡೆ', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 ಕಾಂಡೆ, 10:00 ಕಾಂಡೆ', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 ಬಯ್ಯ, 12:00 ಬಯ್ಯ', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 ಬಯ್ಯ, 5:00 ಬಯ್ಯ', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 ಬಯ್ಯ, 9:30 ಬಯ್ಯ', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 ಬಯ್ಯ, 11:00 ಬಯ್ಯ', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 ಸುಗ್ಗಿ ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 ಸುಗ್ಗಿ ago', // Carbon::now()->subDays(2)->diffForHumans() '2 ಸುಗ್ಗಿ ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 ಸುಗ್ಗಿ ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 ಮೀನ್ ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 ಮೀನ್ ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 ಮೀನ್ ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 ಮೀನ್ ago', // Carbon::now()->subYears(1)->diffForHumans() '1 ನೀರ್ ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 ನೀರ್ ago', // Carbon::now()->subYears(2)->diffForHumans() '2 ನೀರ್ ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 ನೀರ್ ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 ನೀರ್ 3 ಮೀನ್ 1 ಸುಗ್ಗಿ 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 ನೀರ್ from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 ಮೀನ್ ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 ನೀರ್ 3 ಮೀನ್ 1 ಸುಗ್ಗಿ 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 ಸುಗ್ಗಿ', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 ಸುಗ್ಗಿ', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 ಸುಗ್ಗಿ from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 ಸುಗ್ಗಿ', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 ಸುಗ್ಗಿ 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/OmKeTest.php
tests/Localization/OmKeTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class OmKeTest extends LocalizationTestCase { public const LOCALE = 'om_KE'; // Oromo public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sanbata at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Dilbata at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Wiixata at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Qibxata at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Roobii at 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Kamiisa at 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Jimaata at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Qibxata at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Roobii at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Kamiisa at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Jimaata at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Sanbata at 00:00', // Carbon::now()->subDays(2)->calendar() 'Last Dilbata at 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Qibxata at 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Qibxata at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Wiixata at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Dilbata at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Sanbata at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Jimaata at 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Kamiisa at 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Roobii at 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Jimaata at 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 wd CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 WD, 12:00 wd', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 WD, 1:30 wd', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 WD, 2:00 wd', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 WD, 6:00 wd', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 WD, 10:00 wd', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 WB, 12:00 wb', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 WB, 5:00 wb', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 WB, 9:30 wb', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 WB, 11:00 wb', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() 'sekoondii 1 ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'sekoondii 1 ago', // Carbon::now()->subSeconds(2)->diffForHumans() 'sekoondii 2 ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'sekoondii 2 ago', // Carbon::now()->subMinutes(1)->diffForHumans() 'daqiiqaa 1 ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'daqiiqaa 1 ago', // Carbon::now()->subMinutes(2)->diffForHumans() 'daqiiqaa 2 ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'daqiiqaa 2 ago', // Carbon::now()->subHours(1)->diffForHumans() 'saʼaatii 1 ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'saʼaatii 1 ago', // Carbon::now()->subHours(2)->diffForHumans() 'saʼaatii 2 ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'saʼaatii 2 ago', // Carbon::now()->subDays(1)->diffForHumans() 'guyyaa 1 ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'guyyaa 1 ago', // Carbon::now()->subDays(2)->diffForHumans() 'guyyaa 2 ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'guyyaa 2 ago', // Carbon::now()->subWeeks(1)->diffForHumans() 'torban 1 ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'torban 1 ago', // Carbon::now()->subWeeks(2)->diffForHumans() 'torban 2 ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'torban 2 ago', // Carbon::now()->subMonths(1)->diffForHumans() 'ji’a 1 ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'ji’a 1 ago', // Carbon::now()->subMonths(2)->diffForHumans() 'ji’a 2 ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'ji’a 2 ago', // Carbon::now()->subYears(1)->diffForHumans() 'wggoota 1 ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'wggoota 1 ago', // Carbon::now()->subYears(2)->diffForHumans() 'wggoota 2 ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'wggoota 2 ago', // Carbon::now()->addSecond()->diffForHumans() 'sekoondii 1 from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'sekoondii 1 from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'sekoondii 1 after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) 'sekoondii 1 after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) 'sekoondii 1 before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) 'sekoondii 1 before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) 'sekoondii 1', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) 'sekoondii 1', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) 'sekoondii 2', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) 'sekoondii 2', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'sekoondii 1 from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) 'daqiiqaa 1 sekoondii 1', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) 'wggoota 2 ji’a 3 guyyaa 1 sekoondii 1', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'wggoota 3 from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'ji’a 5 ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'wggoota 2 ji’a 3 guyyaa 1 sekoondii 1 ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) 'torban 1 saʼaatii 10', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'torban 1 guyyaa 6', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'torban 1 guyyaa 6', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'torban 1 and guyyaa 6 from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) 'torban 2 saʼaatii 1', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'saʼaatii 1 from now', // CarbonInterval::days(2)->forHumans() 'guyyaa 2', // CarbonInterval::create('P1DT3H')->forHumans(true) 'guyyaa 1 saʼaatii 3', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/FrCaTest.php
tests/Localization/FrCaTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class FrCaTest extends LocalizationTestCase { public const LOCALE = 'fr_CA'; // French public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Demain à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'samedi à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'dimanche à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'lundi à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mardi à 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mercredi à 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'jeudi à 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'vendredi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'mardi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'mercredi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'jeudi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'vendredi à 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'samedi à 00:00', // Carbon::now()->subDays(2)->calendar() 'dimanche dernier à 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hier à 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Aujourd’hui à 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Aujourd’hui à 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Demain à 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'mardi à 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Hier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'mardi dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'lundi dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'dimanche dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'samedi dernier à 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'vendredi dernier à 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'jeudi dernier à 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'mercredi dernier à 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'vendredi dernier à 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1er 1er 1er 1re 1re', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2 1re', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3 1re', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4 1re', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5 1re', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6 1re', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7 2e', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11 2e', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40e', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41e', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100e', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0e', // Carbon::now()->subSeconds(1)->diffForHumans() 'il y a 1 seconde', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'il y a 1 s', // Carbon::now()->subSeconds(2)->diffForHumans() 'il y a 2 secondes', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'il y a 2 s', // Carbon::now()->subMinutes(1)->diffForHumans() 'il y a 1 minute', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'il y a 1 min', // Carbon::now()->subMinutes(2)->diffForHumans() 'il y a 2 minutes', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'il y a 2 min', // Carbon::now()->subHours(1)->diffForHumans() 'il y a 1 heure', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'il y a 1 h', // Carbon::now()->subHours(2)->diffForHumans() 'il y a 2 heures', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'il y a 2 h', // Carbon::now()->subDays(1)->diffForHumans() 'il y a 1 jour', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'il y a 1 j', // Carbon::now()->subDays(2)->diffForHumans() 'il y a 2 jours', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'il y a 2 j', // Carbon::now()->subWeeks(1)->diffForHumans() 'il y a 1 semaine', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'il y a 1 sem.', // Carbon::now()->subWeeks(2)->diffForHumans() 'il y a 2 semaines', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'il y a 2 sem.', // Carbon::now()->subMonths(1)->diffForHumans() 'il y a 1 mois', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'il y a 1 mois', // Carbon::now()->subMonths(2)->diffForHumans() 'il y a 2 mois', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'il y a 2 mois', // Carbon::now()->subYears(1)->diffForHumans() 'il y a 1 an', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'il y a 1 an', // Carbon::now()->subYears(2)->diffForHumans() 'il y a 2 ans', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'il y a 2 ans', // Carbon::now()->addSecond()->diffForHumans() 'dans 1 seconde', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'dans 1 s', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 seconde après', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 s après', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 seconde avant', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 s avant', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 seconde', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 secondes', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'dans 1 s', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 seconde', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 ans 3 mois 1 j 1 s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'dans 3 ans', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'il y a 5 mois', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'il y a 2 ans 3 mois 1 j 1 s', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 semaine 10 heures', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semaine 6 jours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semaine 6 jours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'dans 1 semaine et 6 jours', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 semaines 1 heure', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'dans une heure', // CarbonInterval::days(2)->forHumans() '2 jours', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 j 3 h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/MznTest.php
tests/Localization/MznTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class MznTest extends LocalizationTestCase { public const LOCALE = 'mzn'; // Mazanderani public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tomorrow at 12:00 AM', 'فردا ساعت 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Saturday at 12:00 AM', 'شنبه ساعت 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Sunday at 12:00 AM', 'یکشنبه ساعت 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Monday at 12:00 AM', 'دوشنبه ساعت 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tuesday at 12:00 AM', 'سه‌شنبه ساعت 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Wednesday at 12:00 AM', 'چهارشنبه ساعت 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) // 'Thursday at 12:00 AM', 'پنجشنبه ساعت 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) // 'Friday at 12:00 AM', 'جمعه ساعت 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM', 'سه‌شنبه ساعت 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Wednesday at 12:00 AM', 'چهارشنبه ساعت 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Thursday at 12:00 AM', 'پنجشنبه ساعت 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Friday at 12:00 AM', 'جمعه ساعت 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Saturday at 12:00 AM', 'شنبه ساعت 00:00', // Carbon::now()->subDays(2)->calendar() // 'Last Sunday at 8:49 PM', 'یکشنبه پیش ساعت 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 10:00 PM', 'دیروز ساعت 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) // 'Today at 10:00 AM', 'امروز ساعت 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Today at 2:00 AM', 'امروز ساعت 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) // 'Tomorrow at 1:00 AM', 'فردا ساعت 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM', 'سه‌شنبه ساعت 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) // 'Yesterday at 12:00 AM', 'دیروز ساعت 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 12:00 AM', 'دیروز ساعت 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Tuesday at 12:00 AM', 'سه‌شنبه پیش ساعت 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Monday at 12:00 AM', 'دوشنبه پیش ساعت 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Sunday at 12:00 AM', 'یکشنبه پیش ساعت 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Saturday at 12:00 AM', 'شنبه پیش ساعت 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Friday at 12:00 AM', 'جمعه پیش ساعت 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) // 'Last Thursday at 12:00 AM', 'پنجشنبه پیش ساعت 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) // 'Last Wednesday at 12:00 AM', 'چهارشنبه پیش ساعت 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Last Friday at 12:00 AM', 'جمعه پیش ساعت 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') // '1st 1st 1st 1st 1st', ':timeم :timeم :timeم :timeم :timeم', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') // '2nd 1st', ':timeم :timeم', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') // '3rd 1st', ':timeم :timeم', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') // '4th 1st', ':timeم :timeم', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') // '5th 1st', ':timeم :timeم', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') // '6th 1st', ':timeم :timeم', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') // '7th 2nd', ':timeم :timeم', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') // '11th 2nd', ':timeم :timeم', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') // '40th', ':timeم', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') // '41st', ':timeم', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') // '100th', ':timeم', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') // '12:00 am CET', '12:00 قبل از ظهر CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 AM, 12:00 am', '12:00 قبل از ظهر, 12:00 قبل از ظهر', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') // '1:30 AM, 1:30 am', '1:30 قبل از ظهر, 1:30 قبل از ظهر', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') // '2:00 AM, 2:00 am', '2:00 قبل از ظهر, 2:00 قبل از ظهر', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') // '6:00 AM, 6:00 am', '6:00 قبل از ظهر, 6:00 قبل از ظهر', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') // '10:00 AM, 10:00 am', '10:00 قبل از ظهر, 10:00 قبل از ظهر', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 PM, 12:00 pm', '12:00 بعد از ظهر, 12:00 بعد از ظهر', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') // '5:00 PM, 5:00 pm', '5:00 بعد از ظهر, 5:00 بعد از ظهر', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') // '9:30 PM, 9:30 pm', '9:30 بعد از ظهر, 9:30 بعد از ظهر', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') // '11:00 PM, 11:00 pm', '11:00 بعد از ظهر, 11:00 بعد از ظهر', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') // '0th', ':timeم', // Carbon::now()->subSeconds(1)->diffForHumans() // '1 second ago', '1 ثانیه پیش', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) // '1s ago', '1 ثانیه پیش', // Carbon::now()->subSeconds(2)->diffForHumans() // '2 seconds ago', '2 ثانیه پیش', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) // '2s ago', '2 ثانیه پیش', // Carbon::now()->subMinutes(1)->diffForHumans() // '1 minute ago', '1 دقیقه پیش', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) // '1m ago', '1 دقیقه پیش', // Carbon::now()->subMinutes(2)->diffForHumans() // '2 minutes ago', '2 دقیقه پیش', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) // '2m ago', '2 دقیقه پیش', // Carbon::now()->subHours(1)->diffForHumans() // '1 hour ago', '1 ساعت پیش', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) // '1h ago', '1 ساعت پیش', // Carbon::now()->subHours(2)->diffForHumans() // '2 hours ago', '2 ساعت پیش', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) // '2h ago', '2 ساعت پیش', // Carbon::now()->subDays(1)->diffForHumans() // '1 day ago', '1 روز پیش', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) // '1d ago', '1 روز پیش', // Carbon::now()->subDays(2)->diffForHumans() // '2 days ago', '2 روز پیش', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) // '2d ago', '2 روز پیش', // Carbon::now()->subWeeks(1)->diffForHumans() // '1 week ago', '1 هفته پیش', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) // '1w ago', '1 هفته پیش', // Carbon::now()->subWeeks(2)->diffForHumans() // '2 weeks ago', '2 هفته پیش', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) // '2w ago', '2 هفته پیش', // Carbon::now()->subMonths(1)->diffForHumans() // '1 month ago', '1 ماه پیش', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) // '1mo ago', '1 ماه پیش', // Carbon::now()->subMonths(2)->diffForHumans() // '2 months ago', '2 ماه پیش', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) // '2mos ago', '2 ماه پیش', // Carbon::now()->subYears(1)->diffForHumans() // '1 year ago', '1 سال پیش', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) // '1yr ago', '1 سال پیش', // Carbon::now()->subYears(2)->diffForHumans() // '2 years ago', '2 سال پیش', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) // '2yrs ago', '2 سال پیش', // Carbon::now()->addSecond()->diffForHumans() // '1 second from now', '1 ثانیه دیگر', // Carbon::now()->addSecond()->diffForHumans(null, false, true) // '1s from now', '1 ثانیه دیگر', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) // '1 second after', '1 ثانیه پس از', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) // '1s after', '1 ثانیه پس از', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) // '1 second before', '1 ثانیه پیش از', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) // '1s before', '1 ثانیه پیش از', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) // '1 second', '1 ثانیه', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) // '1s', '1 ثانیه', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) // '2 seconds', '2 ثانیه', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) // '2s', '2 ثانیه', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) // '1s from now', '1 ثانیه دیگر', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) // '1 minute 1 second', '1 دقیقه 1 ثانیه', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) // '2yrs 3mos 1d 1s', '2 سال 3 ماه 1 روز 1 ثانیه', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) // '3 years from now', '3 سال دیگر', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) // '5mos ago', '5 ماه پیش', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) // '2yrs 3mos 1d 1s ago', '2 سال 3 ماه 1 روز 1 ثانیه پیش', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) // '1 week 10 hours', '1 هفته 10 ساعت', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days', '1 هفته 6 روز', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days', '1 هفته 6 روز', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) // '1 week and 6 days from now', '1 هفته و 6 روز دیگر', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) // '2 weeks 1 hour', '2 هفته 1 ساعت', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) // 'an hour from now', 'یک ساعت دیگر', // CarbonInterval::days(2)->forHumans() // '2 days', '2 روز', // CarbonInterval::create('P1DT3H')->forHumans(true) // '1d 3h', '1 روز 3 ساعت', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/JgoTest.php
tests/Localization/JgoTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class JgoTest extends LocalizationTestCase { public const LOCALE = 'jgo'; // Ngomba public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Saturday at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last Sunday at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Thursday at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/SaqTest.php
tests/Localization/SaqTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class SaqTest extends LocalizationTestCase { public const LOCALE = 'saq'; // Samburu public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mderot ee kwe at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mderot ee are at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mderot ee kuni at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mderot ee ong’wan at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mderot ee inet at 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Mderot ee ile at 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Mderot ee sapa at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Mderot ee ong’wan at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Mderot ee inet at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Mderot ee ile at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Mderot ee sapa at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Mderot ee kwe at 00:00', // Carbon::now()->subDays(2)->calendar() 'Last Mderot ee are at 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Mderot ee ong’wan at 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Mderot ee ong’wan at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Mderot ee kuni at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Mderot ee are at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Mderot ee kwe at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Mderot ee sapa at 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Mderot ee ile at 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Mderot ee inet at 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Mderot ee sapa at 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 tesiran CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 Tesiran, 12:00 tesiran', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 Tesiran, 1:30 tesiran', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 Tesiran, 2:00 tesiran', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 Tesiran, 6:00 tesiran', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 Tesiran, 10:00 tesiran', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 Teipa, 12:00 teipa', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 Teipa, 5:00 teipa', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 Teipa, 9:30 teipa', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 Teipa, 11:00 teipa', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/MaiInTest.php
tests/Localization/MaiInTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class MaiInTest extends LocalizationTestCase { public const LOCALE = 'mai_IN'; // Maithili public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'शनीदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'रविदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'सोमदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'मंगलदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'बुधदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'बृहस्पतीदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'शुक्रदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'मंगलदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'बुधदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'बृहस्पतीदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'शुक्रदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'शनीदिन at 12:00 पूर्वाह्न', // Carbon::now()->subDays(2)->calendar() 'Last रविदिन at 8:49 अपराह्न', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 अपराह्न', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 पूर्वाह्न', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 पूर्वाह्न', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'मंगलदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last मंगलदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last सोमदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last रविदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last शनीदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last शुक्रदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last बृहस्पतीदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last बुधदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last शुक्रदिन at 12:00 पूर्वाह्न', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 पूर्वाह्न CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 पूर्वाह्न, 12:00 पूर्वाह्न', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 पूर्वाह्न, 1:30 पूर्वाह्न', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 पूर्वाह्न, 2:00 पूर्वाह्न', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 पूर्वाह्न, 6:00 पूर्वाह्न', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 पूर्वाह्न, 10:00 पूर्वाह्न', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 अपराह्न, 12:00 अपराह्न', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 अपराह्न, 5:00 अपराह्न', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 अपराह्न, 9:30 अपराह्न', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 अपराह्न, 11:00 अपराह्न', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 समय ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1 समय ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 समय ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2 समय ago', // Carbon::now()->subHours(1)->diffForHumans() '1 घण्टा ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 घण्टा ago', // Carbon::now()->subHours(2)->diffForHumans() '2 घण्टा ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 घण्टा ago', // Carbon::now()->subDays(1)->diffForHumans() '1 दिन ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 दिन ago', // Carbon::now()->subDays(2)->diffForHumans() '2 दिन ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 दिन ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 श्रेणी:क्यालेन्डर ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 श्रेणी:क्यालेन्डर ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 श्रेणी:क्यालेन्डर ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 श्रेणी:क्यालेन्डर ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 महिना ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 महिना ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 महिना ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 महिना ago', // Carbon::now()->subYears(1)->diffForHumans() '1 ऋतु ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 ऋतु ago', // Carbon::now()->subYears(2)->diffForHumans() '2 ऋतु ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 ऋतु ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 समय 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 ऋतु 3 महिना 1 दिन 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 ऋतु from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 महिना ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 ऋतु 3 महिना 1 दिन 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 श्रेणी:क्यालेन्डर 10 घण्टा', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 श्रेणी:क्यालेन्डर 6 दिन', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 श्रेणी:क्यालेन्डर 6 दिन', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 श्रेणी:क्यालेन्डर and 6 दिन from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 श्रेणी:क्यालेन्डर 1 घण्टा', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) '1 घण्टा from now', // CarbonInterval::days(2)->forHumans() '2 दिन', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 दिन 3 घण्टा', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/TtTest.php
tests/Localization/TtTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class TtTest extends LocalizationTestCase { public const LOCALE = 'tt'; // Tatar public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'шимбә at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'якшәмбе at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'дышәмбе at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'сишәмбе at 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'чәршәәмбе at 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'пәнҗешмбе at 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'җомга at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'сишәмбе at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'чәршәәмбе at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'пәнҗешмбе at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'җомга at 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'шимбә at 00:00', // Carbon::now()->subDays(2)->calendar() 'Last якшәмбе at 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'сишәмбе at 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last сишәмбе at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last дышәмбе at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last якшәмбе at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last шимбә at 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last җомга at 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last пәнҗешмбе at 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last чәршәәмбе at 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last җомга at 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1 1 1 1 1', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2 1', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3 1', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4 1', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5 1', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6 1', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7 1', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11 2', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0', // Carbon::now()->subSeconds(1)->diffForHumans() 'ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subSeconds(2)->diffForHumans() 'ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subMinutes(1)->diffForHumans() 'ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subMinutes(2)->diffForHumans() 'ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subHours(1)->diffForHumans() 'ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subHours(2)->diffForHumans() 'ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subDays(1)->diffForHumans() 'ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subDays(2)->diffForHumans() 'ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subWeeks(1)->diffForHumans() 'ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subWeeks(2)->diffForHumans() 'ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subMonths(1)->diffForHumans() 'ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subMonths(2)->diffForHumans() 'ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subYears(1)->diffForHumans() 'ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'ago', // Carbon::now()->subYears(2)->diffForHumans() 'ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'ago', // Carbon::now()->addSecond()->diffForHumans() 'from_now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'from_now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) 'after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) 'before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) 'before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 секунд', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 секунд', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 секунд', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 секунд', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'from_now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 минут 1 секунд', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 ел 3 ай 1 көн 1 секунд', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'from_now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 атна 10 сәгать', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 атна 6 көн', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 атна 6 көн', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'from_now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 атна 1 сәгать', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'from_now', // CarbonInterval::days(2)->forHumans() '2 көн', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 көн 3 сәгать', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/BnBdTest.php
tests/Localization/BnBdTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class BnBdTest extends LocalizationTestCase { public const LOCALE = 'bn_BD'; // Bengali public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tomorrow at 12:00 AM', 'আগামীকাল রাত ১২:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Saturday at 12:00 AM', 'শনিবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Sunday at 12:00 AM', 'রবিবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Monday at 12:00 AM', 'সোমবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tuesday at 12:00 AM', 'মঙ্গলবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Wednesday at 12:00 AM', 'বুধবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) // 'Thursday at 12:00 AM', 'বৃহস্পতিবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) // 'Friday at 12:00 AM', 'শুক্রবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM', 'মঙ্গলবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Wednesday at 12:00 AM', 'বুধবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Thursday at 12:00 AM', 'বৃহস্পতিবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Friday at 12:00 AM', 'শুক্রবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Saturday at 12:00 AM', 'শনিবার, রাত ১২:০ সময়', // Carbon::now()->subDays(2)->calendar() // 'Last Sunday at 8:49 PM', 'গত রবিবার, রাত ৮:৪৯ সময়', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 10:00 PM', 'গতকাল রাত ১০:০ সময়', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) // 'Today at 10:00 AM', 'আজ দুপুর ১০:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Today at 2:00 AM', 'আজ রাত ২:০ সময়', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) // 'Tomorrow at 1:00 AM', 'আগামীকাল রাত ১:০ সময়', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM', 'মঙ্গলবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) // 'Yesterday at 12:00 AM', 'গতকাল রাত ১২:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 12:00 AM', 'গতকাল রাত ১২:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Tuesday at 12:00 AM', 'গত মঙ্গলবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Monday at 12:00 AM', 'গত সোমবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Sunday at 12:00 AM', 'গত রবিবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Saturday at 12:00 AM', 'গত শনিবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Friday at 12:00 AM', 'গত শুক্রবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) // 'Last Thursday at 12:00 AM', 'গত বৃহস্পতিবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) // 'Last Wednesday at 12:00 AM', 'গত বুধবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Last Friday at 12:00 AM', 'গত শুক্রবার, রাত ১২:০ সময়', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') // '1st 1st 1st 1st 1st', '১ম ১ম ১ম ১ম ১ম', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') // '2nd 1st', '২য় ১ম', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') // '3rd 1st', '৩য় ১ম', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') // '4th 1st', '৪র্থ ১ম', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') // '5th 1st', '৫ম ২য়', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') // '6th 1st', '৬ষ্ঠ ২য়', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') // '7th 2nd', '৭ম ২য়', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') // '11th 2nd', '১১তম ২য়', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') // '40th', '৪০তম', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') // '41st', '৪১তম', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') // '100th', '১০০তম', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') // '12:00 am CET', '12:00 রাত CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 AM, 12:00 am', '12:00 রাত, 12:00 রাত', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') // '1:30 AM, 1:30 am', '1:30 রাত, 1:30 রাত', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') // '2:00 AM, 2:00 am', '2:00 রাত, 2:00 রাত', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') // '6:00 AM, 6:00 am', '6:00 সকাল, 6:00 সকাল', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') // '10:00 AM, 10:00 am', '10:00 দুপুর, 10:00 দুপুর', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 PM, 12:00 pm', '12:00 দুপুর, 12:00 দুপুর', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') // '5:00 PM, 5:00 pm', '5:00 বিকাল, 5:00 বিকাল', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') // '9:30 PM, 9:30 pm', '9:30 রাত, 9:30 রাত', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') // '11:00 PM, 11:00 pm', '11:00 রাত, 11:00 রাত', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') // '0th', '০তম', // Carbon::now()->subSeconds(1)->diffForHumans() // '1 second ago', '1 সেকেন্ড আগে', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) // '1s ago', '১ সেকেন্ড আগে', // Carbon::now()->subSeconds(2)->diffForHumans() // '2 seconds ago', '2 সেকেন্ড আগে', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) // '2s ago', '2 সেকেন্ড আগে', // Carbon::now()->subMinutes(1)->diffForHumans() // '1 minute ago', '1 মিনিট আগে', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) // '1m ago', '১ মিনিট আগে', // Carbon::now()->subMinutes(2)->diffForHumans() // '2 minutes ago', '2 মিনিট আগে', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) // '2m ago', '2 মিনিট আগে', // Carbon::now()->subHours(1)->diffForHumans() // '1 hour ago', '1 ঘন্টা আগে', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) // '1h ago', '১ ঘন্টা আগে', // Carbon::now()->subHours(2)->diffForHumans() // '2 hours ago', '2 ঘন্টা আগে', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) // '2h ago', '2 ঘন্টা আগে', // Carbon::now()->subDays(1)->diffForHumans() // '1 day ago', '1 দিন আগে', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) // '1d ago', '১ দিন আগে', // Carbon::now()->subDays(2)->diffForHumans() // '2 days ago', '2 দিন আগে', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) // '2d ago', '2 দিন আগে', // Carbon::now()->subWeeks(1)->diffForHumans() // '1 week ago', '1 সপ্তাহ আগে', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) // '1w ago', '১ সপ্তাহ আগে', // Carbon::now()->subWeeks(2)->diffForHumans() // '2 weeks ago', '2 সপ্তাহ আগে', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) // '2w ago', '2 সপ্তাহ আগে', // Carbon::now()->subMonths(1)->diffForHumans() // '1 month ago', '1 মাস আগে', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) // '1mo ago', '১ মাস আগে', // Carbon::now()->subMonths(2)->diffForHumans() // '2 months ago', '2 মাস আগে', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) // '2mos ago', '2 মাস আগে', // Carbon::now()->subYears(1)->diffForHumans() // '1 year ago', '1 বছর আগে', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) // '1yr ago', '১ বছর আগে', // Carbon::now()->subYears(2)->diffForHumans() // '2 years ago', '2 বছর আগে', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) // '2yrs ago', '2 বছর আগে', // Carbon::now()->addSecond()->diffForHumans() // '1 second from now', '1 সেকেন্ড পরে', // Carbon::now()->addSecond()->diffForHumans(null, false, true) // '1s from now', '১ সেকেন্ড পরে', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) // '1 second after', '1 সেকেন্ড পরে', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) // '1s after', '১ সেকেন্ড পরে', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) // '1 second before', '1 সেকেন্ড আগে', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) // '1s before', '১ সেকেন্ড আগে', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) // '1 second', '1 সেকেন্ড', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) // '1s', '১ সেকেন্ড', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) // '2 seconds', '2 সেকেন্ড', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) // '2s', '2 সেকেন্ড', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) // '1s from now', '১ সেকেন্ড পরে', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) // '1 minute 1 second', '1 মিনিট 1 সেকেন্ড', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) // '2yrs 3mos 1d 1s', '2 বছর 3 মাস ১ দিন ১ সেকেন্ড', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) // '3 years from now', '3 বছর পরে', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) // '5mos ago', '5 মাস আগে', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) // '2yrs 3mos 1d 1s ago', '2 বছর 3 মাস ১ দিন ১ সেকেন্ড আগে', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) // '1 week 10 hours', '1 সপ্তাহ 10 ঘন্টা', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days', '1 সপ্তাহ 6 দিন', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days', '1 সপ্তাহ 6 দিন', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) // '1 week and 6 days from now', '1 সপ্তাহ এবং 6 দিন পরে', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) // '2 weeks 1 hour', '2 সপ্তাহ 1 ঘন্টা', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) // 'an hour from now', 'এক ঘন্টা পরে', // CarbonInterval::days(2)->forHumans() // '2 days', '2 দিন', // CarbonInterval::create('P1DT3H')->forHumans(true) // '1d 3h', '১ দিন 3 ঘন্টা', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/TnTest.php
tests/Localization/TnTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class TnTest extends LocalizationTestCase { public const LOCALE = 'tn'; // Tswana public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Lamatlhatso at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'laTshipi at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mosupologo at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Labobedi at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Laboraro at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Labone at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Labotlhano at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Labobedi at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Laboraro at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Labone at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Labotlhano at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Lamatlhatso at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last laTshipi at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Labobedi at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Labobedi at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Mosupologo at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last laTshipi at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Lamatlhatso at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Labotlhano at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Labone at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Laboraro at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Labotlhano at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() 'metsotswana e le 1 ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'metsotswana e le 1 ago', // Carbon::now()->subSeconds(2)->diffForHumans() 'metsotswana e le 2 ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'metsotswana e le 2 ago', // Carbon::now()->subMinutes(1)->diffForHumans() 'metsotso e le 1 ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'metsotso e le 1 ago', // Carbon::now()->subMinutes(2)->diffForHumans() 'metsotso e le 2 ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'metsotso e le 2 ago', // Carbon::now()->subHours(1)->diffForHumans() 'diura di le 1 ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'diura di le 1 ago', // Carbon::now()->subHours(2)->diffForHumans() 'diura di le 2 ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'diura di le 2 ago', // Carbon::now()->subDays(1)->diffForHumans() 'malatsi 1 ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'malatsi 1 ago', // Carbon::now()->subDays(2)->diffForHumans() 'malatsi 2 ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'malatsi 2 ago', // Carbon::now()->subWeeks(1)->diffForHumans() 'dibeke di le 1 ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'dibeke di le 1 ago', // Carbon::now()->subWeeks(2)->diffForHumans() 'dibeke di le 2 ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'dibeke di le 2 ago', // Carbon::now()->subMonths(1)->diffForHumans() 'dikgwedi di le 1 ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'dikgwedi di le 1 ago', // Carbon::now()->subMonths(2)->diffForHumans() 'dikgwedi di le 2 ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'dikgwedi di le 2 ago', // Carbon::now()->subYears(1)->diffForHumans() 'dingwaga di le 1 ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'dingwaga di le 1 ago', // Carbon::now()->subYears(2)->diffForHumans() 'dingwaga di le 2 ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'dingwaga di le 2 ago', // Carbon::now()->addSecond()->diffForHumans() 'metsotswana e le 1 from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'metsotswana e le 1 from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'metsotswana e le 1 after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) 'metsotswana e le 1 after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) 'metsotswana e le 1 before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) 'metsotswana e le 1 before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) 'metsotswana e le 1', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) 'metsotswana e le 1', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) 'metsotswana e le 2', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) 'metsotswana e le 2', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'metsotswana e le 1 from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) 'metsotso e le 1 metsotswana e le 1', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) 'dingwaga di le 2 dikgwedi di le 3 malatsi 1 metsotswana e le 1', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'dingwaga di le 3 from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'dikgwedi di le 5 ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'dingwaga di le 2 dikgwedi di le 3 malatsi 1 metsotswana e le 1 ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) 'dibeke di le 1 diura di le 10', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'dibeke di le 1 malatsi 6', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'dibeke di le 1 malatsi 6', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'dibeke di le 1 and malatsi 6 from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) 'dibeke di le 2 diura di le 1', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'diura di le 1 from now', // CarbonInterval::days(2)->forHumans() 'malatsi 2', // CarbonInterval::create('P1DT3H')->forHumans(true) 'malatsi 1 diura di le 3', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/SrRsLatinTest.php
tests/Localization/SrRsLatinTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class SrRsLatinTest extends LocalizationTestCase { public const LOCALE = 'sr_RS@latin'; // Serbian public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tomorrow at 12:00 AM' 'sutra u 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Saturday at 12:00 AM' 'u subotu u 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Sunday at 12:00 AM' 'u nedelju u 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Monday at 12:00 AM' 'u ponedeljak u 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tuesday at 12:00 AM' 'u utorak u 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Wednesday at 12:00 AM' 'u sredu u 0:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) // 'Thursday at 12:00 AM' 'u četvrtak u 0:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) // 'Friday at 12:00 AM' 'u petak u 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'u utorak u 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Wednesday at 12:00 AM' 'u sredu u 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Thursday at 12:00 AM' 'u četvrtak u 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Friday at 12:00 AM' 'u petak u 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Saturday at 12:00 AM' 'u subotu u 0:00', // Carbon::now()->subDays(2)->calendar() // 'Last Sunday at 8:49 PM' 'prošle nedelje u 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 10:00 PM' 'juče u 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) // 'Today at 10:00 AM' 'danas u 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Today at 2:00 AM' 'danas u 2:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) // 'Tomorrow at 1:00 AM' 'sutra u 1:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'u utorak u 0:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) // 'Yesterday at 12:00 AM' 'juče u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 12:00 AM' 'juče u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Tuesday at 12:00 AM' 'prošlog utorka u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Monday at 12:00 AM' 'prošlog ponedeljka u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Sunday at 12:00 AM' 'prošle nedelje u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Saturday at 12:00 AM' 'prošle subote u 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Friday at 12:00 AM' 'prošlog petka u 0:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) // 'Last Thursday at 12:00 AM' 'prošlog četvrtka u 0:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) // 'Last Wednesday at 12:00 AM' 'prošle srede u 0:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Last Friday at 12:00 AM' 'prošlog petka u 0:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') // '1st 1st 1st 1st 1st' '1. 1. 1. 1. 1.', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') // '2nd 1st' '2. 1.', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') // '3rd 1st' '3. 1.', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') // '4th 1st' '4. 1.', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') // '5th 1st' '5. 1.', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') // '6th 1st' '6. 1.', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') // '7th 1st' '7. 1.', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') // '11th 2nd' '11. 2.', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') // '40th' '40.', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') // '41st' '41.', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') // '100th' '100.', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') // '12:00 am CET' '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 AM, 12:00 am' '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') // '1:30 AM, 1:30 am' '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') // '2:00 AM, 2:00 am' '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') // '6:00 AM, 6:00 am' '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') // '10:00 AM, 10:00 am' '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 PM, 12:00 pm' '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') // '5:00 PM, 5:00 pm' '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') // '9:30 PM, 9:30 pm' '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') // '11:00 PM, 11:00 pm' '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') // '0th' '0.', // Carbon::now()->subSeconds(1)->diffForHumans() // '1 second ago' 'pre 1 sekundu', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) // '1s ago' 'pre 1 sek.', // Carbon::now()->subSeconds(2)->diffForHumans() // '2 seconds ago' 'pre 2 sekunde', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) // '2s ago' 'pre 2 sek.', // Carbon::now()->subMinutes(1)->diffForHumans() // '1 minute ago' 'pre 1 minut', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) // '1m ago' 'pre 1 min.', // Carbon::now()->subMinutes(2)->diffForHumans() // '2 minutes ago' 'pre 2 minuta', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) // '2m ago' 'pre 2 min.', // Carbon::now()->subHours(1)->diffForHumans() // '1 hour ago' 'pre 1 sat', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) // '1h ago' 'pre 1 č.', // Carbon::now()->subHours(2)->diffForHumans() // '2 hours ago' 'pre 2 sata', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) // '2h ago' 'pre 2 č.', // Carbon::now()->subDays(1)->diffForHumans() // '1 day ago' 'pre 1 dan', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) // '1d ago' 'pre 1 d.', // Carbon::now()->subDays(2)->diffForHumans() // '2 days ago' 'pre 2 dana', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) // '2d ago' 'pre 2 d.', // Carbon::now()->subWeeks(1)->diffForHumans() // '1 week ago' 'pre 1 nedelju', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) // '1w ago' 'pre 1 ned.', // Carbon::now()->subWeeks(2)->diffForHumans() // '2 weeks ago' 'pre 2 nedelje', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) // '2w ago' 'pre 2 ned.', // Carbon::now()->subMonths(1)->diffForHumans() // '1 month ago' 'pre 1 mesec', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) // '1mo ago' 'pre 1 mes.', // Carbon::now()->subMonths(2)->diffForHumans() // '2 months ago' 'pre 2 meseca', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) // '2mos ago' 'pre 2 mes.', // Carbon::now()->subYears(1)->diffForHumans() // '1 year ago' 'pre 1 godinu', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) // '1yr ago' 'pre 1 g.', // Carbon::now()->subYears(2)->diffForHumans() // '2 years ago' 'pre 2 godine', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) // '2yrs ago' 'pre 2 g.', // Carbon::now()->addSecond()->diffForHumans() // '1 second from now' 'za 1 sekundu', // Carbon::now()->addSecond()->diffForHumans(null, false, true) // '1s from now' 'za 1 sek.', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) // '1 second after' 'nakon 1 sekundu', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) // '1s after' 'nakon 1 sek.', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) // '1 second before' 'pre 1 sekundu', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) // '1s before' 'pre 1 sek.', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) // '1 second' '1 sekundu', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) // '1s' '1 sek.', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) // '2 seconds' '2 sekunde', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) // '2s' '2 sek.', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) // '1s from now' 'za 1 sek.', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) // '1 minute 1 second' '1 minut 1 sekundu', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) // '2yrs 3mos 1d 1s' '2 g. 3 mes. 1 d. 1 sek.', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) // '3 years from now' 'za 3 godine', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) // '5mos ago' 'pre 5 mes.', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) // '2yrs 3mos 1d 1s ago' 'pre 2 g. 3 mes. 1 d. 1 sek.', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) // '1 week 10 hours' '1 nedelja 10 sati', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1 nedelja 6 dana', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1 nedelja 6 dana', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) // '1 week and 6 days from now' 'za 1 nedelju i 6 dana', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) // '2 weeks 1 hour' '2 nedelje 1 sat', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) // 'an hour from now' 'za 1 sat', // CarbonInterval::days(2)->forHumans() // '2 days' '2 dana', // CarbonInterval::create('P1DT3H')->forHumans(true) // '1d 3h' '1 d. 3 č.', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/SrRsTest.php
tests/Localization/SrRsTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class SrRsTest extends LocalizationTestCase { public const LOCALE = 'sr_RS'; // Serbian public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tomorrow at 12:00 AM' 'сутра у 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Saturday at 12:00 AM' 'у суботу у 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Sunday at 12:00 AM' 'у недељу у 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Monday at 12:00 AM' 'у понедељак у 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Tuesday at 12:00 AM' 'у уторак у 0:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Wednesday at 12:00 AM' 'у среду у 0:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) // 'Thursday at 12:00 AM' 'у четвртак у 0:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) // 'Friday at 12:00 AM' 'у петак у 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'у уторак у 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Wednesday at 12:00 AM' 'у среду у 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Thursday at 12:00 AM' 'у четвртак у 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Friday at 12:00 AM' 'у петак у 0:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Saturday at 12:00 AM' 'у суботу у 0:00', // Carbon::now()->subDays(2)->calendar() // 'Last Sunday at 8:49 PM' 'прошле недеље у 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 10:00 PM' 'јуче у 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) // 'Today at 10:00 AM' 'данас у 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Today at 2:00 AM' 'данас у 2:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) // 'Tomorrow at 1:00 AM' 'сутра у 1:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Tuesday at 12:00 AM' 'у уторак у 0:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) // 'Yesterday at 12:00 AM' 'јуче у 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Yesterday at 12:00 AM' 'јуче у 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Tuesday at 12:00 AM' 'прошлог уторка у 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Monday at 12:00 AM' 'прошлог понедељка у 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Sunday at 12:00 AM' 'прошле недеље у 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Saturday at 12:00 AM' 'прошле суботе у 0:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) // 'Last Friday at 12:00 AM' 'прошлог петка у 0:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) // 'Last Thursday at 12:00 AM' 'прошлог четвртка у 0:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) // 'Last Wednesday at 12:00 AM' 'прошле среде у 0:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) // 'Last Friday at 12:00 AM' 'прошлог петка у 0:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') // '1st 1st 1st 1st 1st' '1. 1. 1. 1. 1.', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') // '2nd 1st' '2. 1.', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') // '3rd 1st' '3. 1.', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') // '4th 1st' '4. 1.', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') // '5th 1st' '5. 1.', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') // '6th 1st' '6. 1.', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') // '7th 1st' '7. 1.', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') // '11th 2nd' '11. 2.', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') // '40th' '40.', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') // '41st' '41.', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') // '100th' '100.', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') // '12:00 am CET' '12:00 ам CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 AM, 12:00 am' '12:00 АМ, 12:00 ам', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') // '1:30 AM, 1:30 am' '1:30 АМ, 1:30 ам', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') // '2:00 AM, 2:00 am' '2:00 АМ, 2:00 ам', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') // '6:00 AM, 6:00 am' '6:00 АМ, 6:00 ам', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') // '10:00 AM, 10:00 am' '10:00 АМ, 10:00 ам', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') // '12:00 PM, 12:00 pm' '12:00 ПМ, 12:00 пм', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') // '5:00 PM, 5:00 pm' '5:00 ПМ, 5:00 пм', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') // '9:30 PM, 9:30 pm' '9:30 ПМ, 9:30 пм', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') // '11:00 PM, 11:00 pm' '11:00 ПМ, 11:00 пм', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') // '0th' '0.', // Carbon::now()->subSeconds(1)->diffForHumans() // '1 second ago' 'пре 1 секунд', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) // '1s ago' 'пре 1 сек.', // Carbon::now()->subSeconds(2)->diffForHumans() // '2 seconds ago' 'пре 2 секунде', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) // '2s ago' 'пре 2 сек.', // Carbon::now()->subMinutes(1)->diffForHumans() // '1 minute ago' 'пре 1 минут', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) // '1m ago' 'пре 1 мин.', // Carbon::now()->subMinutes(2)->diffForHumans() // '2 minutes ago' 'пре 2 минута', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) // '2m ago' 'пре 2 мин.', // Carbon::now()->subHours(1)->diffForHumans() // '1 hour ago' 'пре 1 сат', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) // '1h ago' 'пре 1 ч.', // Carbon::now()->subHours(2)->diffForHumans() // '2 hours ago' 'пре 2 сата', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) // '2h ago' 'пре 2 ч.', // Carbon::now()->subDays(1)->diffForHumans() // '1 day ago' 'пре 1 дан', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) // '1d ago' 'пре 1 д.', // Carbon::now()->subDays(2)->diffForHumans() // '2 days ago' 'пре 2 дана', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) // '2d ago' 'пре 2 д.', // Carbon::now()->subWeeks(1)->diffForHumans() // '1 week ago' 'пре 1 недељу', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) // '1w ago' 'пре 1 нед.', // Carbon::now()->subWeeks(2)->diffForHumans() // '2 weeks ago' 'пре 2 недеље', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) // '2w ago' 'пре 2 нед.', // Carbon::now()->subMonths(1)->diffForHumans() // '1 month ago' 'пре 1 месец', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) // '1mo ago' 'пре 1 м.', // Carbon::now()->subMonths(2)->diffForHumans() // '2 months ago' 'пре 2 месеца', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) // '2mos ago' 'пре 2 м.', // Carbon::now()->subYears(1)->diffForHumans() // '1 year ago' 'пре 1 годину', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) // '1yr ago' 'пре 1 г.', // Carbon::now()->subYears(2)->diffForHumans() // '2 years ago' 'пре 2 године', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) // '2yrs ago' 'пре 2 г.', // Carbon::now()->addSecond()->diffForHumans() // '1 second from now' 'за 1 секунд', // Carbon::now()->addSecond()->diffForHumans(null, false, true) // '1s from now' 'за 1 сек.', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) // '1 second after' '1 секунд након', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) // '1s after' '1 сек. након', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) // '1 second before' '1 секунд пре', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) // '1s before' '1 сек. пре', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) // '1 second' '1 секунд', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) // '1s' '1 сек.', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) // '2 seconds' '2 секунде', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) // '2s' '2 сек.', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) // '1s from now' 'за 1 сек.', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) // '1 minute 1 second' '1 минут 1 секунд', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) // '2yrs 3mos 1d 1s' '2 г. 3 м. 1 д. 1 сек.', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) // '3 years from now' 'за 3 године', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) // '5mos ago' 'пре 5 м.', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) // '2yrs 3mos 1d 1s ago' 'пре 2 г. 3 м. 1 д. 1 сек.', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) // '1 week 10 hours' '1 недеља 10 сати', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1 недеља 6 дана', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) // '1 week 6 days' '1 недеља 6 дана', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) // '1 week and 6 days from now' 'за 1 недељу и 6 дана', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) // '2 weeks 1 hour' '2 недеље 1 сат', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) // 'an hour from now' 'за 1 сат', // CarbonInterval::days(2)->forHumans() // '2 days' '2 дана', // CarbonInterval::create('P1DT3H')->forHumans(true) // '1d 3h' '1 д. 3 ч.', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/ArTest.php
tests/Localization/ArTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class ArTest extends LocalizationTestCase { public const LOCALE = 'ar'; // Arabic public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'غدًا عند الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'السبت عند الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الأحد عند الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الاثنين عند الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الثلاثاء عند الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الأربعاء عند الساعة 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'الخميس عند الساعة 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'الجمعة عند الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الثلاثاء عند الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الأربعاء عند الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الخميس عند الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الجمعة عند الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'السبت عند الساعة 00:00', // Carbon::now()->subDays(2)->calendar() 'الأحد عند الساعة 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'أمس عند الساعة 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'اليوم عند الساعة 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'اليوم عند الساعة 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'غدًا عند الساعة 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الثلاثاء عند الساعة 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'أمس عند الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'أمس عند الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الثلاثاء عند الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الاثنين عند الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الأحد عند الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'السبت عند الساعة 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'الجمعة عند الساعة 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'الخميس عند الساعة 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'الأربعاء عند الساعة 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'الجمعة عند الساعة 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1 1 1 1 1', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2 1', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3 1', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4 1', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5 1', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6 2', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7 2', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11 2', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 ص CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 ص, 12:00 ص', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 ص, 1:30 ص', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 ص, 2:00 ص', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 ص, 6:00 ص', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 ص, 10:00 ص', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 م, 12:00 م', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 م, 5:00 م', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 م, 9:30 م', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 م, 11:00 م', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0', // Carbon::now()->subSeconds(1)->diffForHumans() 'منذ ثانية', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'منذ ثانية', // Carbon::now()->subSeconds(2)->diffForHumans() 'منذ ثانيتين', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'منذ ثانيتين', // Carbon::now()->subMinutes(1)->diffForHumans() 'منذ دقيقة', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'منذ دقيقة', // Carbon::now()->subMinutes(2)->diffForHumans() 'منذ دقيقتين', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'منذ دقيقتين', // Carbon::now()->subHours(1)->diffForHumans() 'منذ ساعة', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'منذ ساعة', // Carbon::now()->subHours(2)->diffForHumans() 'منذ ساعتين', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'منذ ساعتين', // Carbon::now()->subDays(1)->diffForHumans() 'منذ يوم', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'منذ يوم', // Carbon::now()->subDays(2)->diffForHumans() 'منذ يومين', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'منذ يومين', // Carbon::now()->subWeeks(1)->diffForHumans() 'منذ أسبوع', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'منذ أسبوع', // Carbon::now()->subWeeks(2)->diffForHumans() 'منذ أسبوعين', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'منذ أسبوعين', // Carbon::now()->subMonths(1)->diffForHumans() 'منذ شهر', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'منذ شهر', // Carbon::now()->subMonths(2)->diffForHumans() 'منذ شهرين', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'منذ شهرين', // Carbon::now()->subYears(1)->diffForHumans() 'منذ سنة', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'منذ سنة', // Carbon::now()->subYears(2)->diffForHumans() 'منذ سنتين', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'منذ سنتين', // Carbon::now()->addSecond()->diffForHumans() 'ثانية من الآن', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'ثانية من الآن', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'بعد ثانية', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) 'بعد ثانية', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) 'قبل ثانية', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) 'قبل ثانية', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) 'ثانية', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) 'ثانية', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) 'ثانيتين', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) 'ثانيتين', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'ثانية من الآن', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) 'دقيقة ثانية', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) 'سنتين 3 أشهر يوم ثانية', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 سنوات من الآن', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'منذ 5 أشهر', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'منذ سنتين 3 أشهر يوم ثانية', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) 'أسبوع 10 ساعات', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'أسبوع 6 أيام', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'أسبوع 6 أيام', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'أسبوع و 6 أيام من الآن', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) 'أسبوعين ساعة', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'ساعة من الآن', // CarbonInterval::days(2)->forHumans() 'يومين', // CarbonInterval::create('P1DT3H')->forHumans(true) 'يوم 3 ساعات', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/MiNzTest.php
tests/Localization/MiNzTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class MiNzTest extends LocalizationTestCase { public const LOCALE = 'mi_NZ'; // Maori public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'apopo i 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hātarei i 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Rātapu i 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mane i 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tūrei i 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Wenerei i 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Tāite i 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Paraire i 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tūrei i 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Wenerei i 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tāite i 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Paraire i 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Hātarei i 00:00', // Carbon::now()->subDays(2)->calendar() 'Rātapu whakamutunga i 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'inanahi i 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'i teie mahana, i 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'i teie mahana, i 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'apopo i 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tūrei i 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'inanahi i 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'inanahi i 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tūrei whakamutunga i 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Mane whakamutunga i 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Rātapu whakamutunga i 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hātarei whakamutunga i 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Paraire whakamutunga i 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Tāite whakamutunga i 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Wenerei whakamutunga i 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Paraire whakamutunga i 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1º 1º 1º 1º 1º', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2º 1º', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3º 1º', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4º 1º', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5º 1º', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6º 1º', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7º 1º', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11º 2º', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40º', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41º', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100º', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0º', // Carbon::now()->subSeconds(1)->diffForHumans() '1 hēkona i mua', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 hēkona i mua', // Carbon::now()->subSeconds(2)->diffForHumans() '2 hēkona i mua', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 hēkona i mua', // Carbon::now()->subMinutes(1)->diffForHumans() '1 meneti i mua', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1 meneti i mua', // Carbon::now()->subMinutes(2)->diffForHumans() '2 meneti i mua', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2 meneti i mua', // Carbon::now()->subHours(1)->diffForHumans() '1 haora i mua', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 haora i mua', // Carbon::now()->subHours(2)->diffForHumans() '2 haora i mua', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 haora i mua', // Carbon::now()->subDays(1)->diffForHumans() '1 ra i mua', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 ra i mua', // Carbon::now()->subDays(2)->diffForHumans() '2 ra i mua', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 ra i mua', // Carbon::now()->subWeeks(1)->diffForHumans() '1 wiki i mua', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 wiki i mua', // Carbon::now()->subWeeks(2)->diffForHumans() '2 wiki i mua', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 wiki i mua', // Carbon::now()->subMonths(1)->diffForHumans() '1 marama i mua', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 marama i mua', // Carbon::now()->subMonths(2)->diffForHumans() '2 marama i mua', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 marama i mua', // Carbon::now()->subYears(1)->diffForHumans() '1 tau i mua', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 tau i mua', // Carbon::now()->subYears(2)->diffForHumans() '2 tau i mua', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 tau i mua', // Carbon::now()->addSecond()->diffForHumans() 'i roto i 1 hēkona', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'i roto i 1 hēkona', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) 'after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) 'before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) 'before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 hēkona', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 hēkona', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 hēkona', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 hēkona', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'i roto i 1 hēkona', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 meneti 1 hēkona', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 tau 3 marama 1 ra 1 hēkona', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'i roto i 3 tau', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 marama i mua', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 tau 3 marama 1 ra 1 hēkona i mua', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 wiki 10 haora', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 wiki 6 ra', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 wiki 6 ra', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'i roto i 1 wiki me te 6 ra', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 wiki 1 haora', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'i roto i te haora', // CarbonInterval::days(2)->forHumans() '2 ra', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 ra 3 haora', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/SwCdTest.php
tests/Localization/SwCdTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class SwCdTest extends LocalizationTestCase { public const LOCALE = 'sw_CD'; // Swahili public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'kesho saa 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'wiki ijayo Jumamosi saat 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'wiki ijayo Jumapili saat 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'wiki ijayo Jumatatu saat 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'wiki ijayo Jumanne saat 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'wiki ijayo Jumatano saat 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'wiki ijayo Alhamisi saat 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'wiki ijayo Ijumaa saat 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'wiki ijayo Jumanne saat 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'wiki ijayo Jumatano saat 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'wiki ijayo Alhamisi saat 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'wiki ijayo Ijumaa saat 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'wiki ijayo Jumamosi saat 00:00', // Carbon::now()->subDays(2)->calendar() 'wiki iliyopita Jumapili saat 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'jana 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'leo saa 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'leo saa 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'kesho saa 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'wiki ijayo Jumanne saat 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'jana 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'jana 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'wiki iliyopita Jumanne saat 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'wiki iliyopita Jumatatu saat 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'wiki iliyopita Jumapili saat 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'wiki iliyopita Jumamosi saat 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'wiki iliyopita Ijumaa saat 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'wiki iliyopita Alhamisi saat 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'wiki iliyopita Jumatano saat 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'wiki iliyopita Ijumaa saat 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1 1 1 1 1', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2 1', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3 1', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4 1', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5 1', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6 1', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7 1', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11 2', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0', // Carbon::now()->subSeconds(1)->diffForHumans() 'tokea sekunde 1', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'tokea se. 1', // Carbon::now()->subSeconds(2)->diffForHumans() 'tokea sekunde 2', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'tokea se. 2', // Carbon::now()->subMinutes(1)->diffForHumans() 'tokea dakika 1', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'tokea d. 1', // Carbon::now()->subMinutes(2)->diffForHumans() 'tokea dakika 2', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'tokea d. 2', // Carbon::now()->subHours(1)->diffForHumans() 'tokea saa 1', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'tokea saa 1', // Carbon::now()->subHours(2)->diffForHumans() 'tokea masaa 2', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'tokea masaa 2', // Carbon::now()->subDays(1)->diffForHumans() 'tokea siku 1', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'tokea si. 1', // Carbon::now()->subDays(2)->diffForHumans() 'tokea siku 2', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'tokea si. 2', // Carbon::now()->subWeeks(1)->diffForHumans() 'tokea wiki 1', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'tokea w. 1', // Carbon::now()->subWeeks(2)->diffForHumans() 'tokea wiki 2', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'tokea w. 2', // Carbon::now()->subMonths(1)->diffForHumans() 'tokea mwezi 1', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'tokea mwezi 1', // Carbon::now()->subMonths(2)->diffForHumans() 'tokea miezi 2', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'tokea miezi 2', // Carbon::now()->subYears(1)->diffForHumans() 'tokea mwaka 1', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'tokea mwaka 1', // Carbon::now()->subYears(2)->diffForHumans() 'tokea miaka 2', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'tokea miaka 2', // Carbon::now()->addSecond()->diffForHumans() 'sekunde 1 baadaye', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'se. 1 baadaye', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'sekunde 1 baada', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) 'se. 1 baada', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) 'sekunde 1 kabla', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) 'se. 1 kabla', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) 'sekunde 1', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) 'se. 1', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) 'sekunde 2', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) 'se. 2', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'se. 1 baadaye', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) 'dakika 1 sekunde 1', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) 'miaka 2 miezi 3 si. 1 se. 1', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'miaka 3 baadaye', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'tokea miezi 5', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'tokea miaka 2 miezi 3 si. 1 se. 1', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) 'wiki 1 masaa 10', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'wiki 1 siku 6', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) 'wiki 1 siku 6', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'wiki 1 na siku 6 baadaye', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) 'wiki 2 saa 1', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'saa limoja baadaye', // CarbonInterval::days(2)->forHumans() 'siku 2', // CarbonInterval::create('P1DT3H')->forHumans(true) 'si. 1 masaa 3', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/PtTest.php
tests/Localization/PtTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class PtTest extends LocalizationTestCase { public const LOCALE = 'pt'; // Portuguese public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Amanhã às 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'sábado às 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'domingo às 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'segunda-feira às 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'terça-feira às 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'quarta-feira às 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'quinta-feira às 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'sexta-feira às 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'terça-feira às 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'quarta-feira às 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'quinta-feira às 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'sexta-feira às 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'sábado às 00:00', // Carbon::now()->subDays(2)->calendar() 'Último domingo às 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Ontem às 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Hoje às 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Hoje às 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Amanhã às 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'terça-feira às 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Ontem às 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Ontem às 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Última terça-feira às 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Última segunda-feira às 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Último domingo às 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Último sábado às 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Última sexta-feira às 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Última quinta-feira às 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Última quarta-feira às 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Última sexta-feira às 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1º 1º 1º 1º 1º', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2º 1º', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3º 1º', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4º 1º', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5º 1º', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6º 1º', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7º 1º', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11º 2º', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40º', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41º', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100º', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0º', // Carbon::now()->subSeconds(1)->diffForHumans() 'há 1 segundo', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'há 1s', // Carbon::now()->subSeconds(2)->diffForHumans() 'há 2 segundos', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'há 2s', // Carbon::now()->subMinutes(1)->diffForHumans() 'há 1 minuto', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'há 1min', // Carbon::now()->subMinutes(2)->diffForHumans() 'há 2 minutos', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'há 2min', // Carbon::now()->subHours(1)->diffForHumans() 'há 1 hora', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'há 1h', // Carbon::now()->subHours(2)->diffForHumans() 'há 2 horas', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'há 2h', // Carbon::now()->subDays(1)->diffForHumans() 'há 1 dia', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'há 1d', // Carbon::now()->subDays(2)->diffForHumans() 'há 2 dias', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'há 2d', // Carbon::now()->subWeeks(1)->diffForHumans() 'há 1 semana', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'há 1sem', // Carbon::now()->subWeeks(2)->diffForHumans() 'há 2 semanas', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'há 2sem', // Carbon::now()->subMonths(1)->diffForHumans() 'há 1 mês', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'há 1m', // Carbon::now()->subMonths(2)->diffForHumans() 'há 2 meses', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'há 2m', // Carbon::now()->subYears(1)->diffForHumans() 'há 1 ano', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'há 1a', // Carbon::now()->subYears(2)->diffForHumans() 'há 2 anos', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'há 2a', // Carbon::now()->addSecond()->diffForHumans() 'em 1 segundo', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'em 1s', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 segundo depois', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s depois', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 segundo antes', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s antes', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 segundo', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 segundos', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'em 1s', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minuto 1 segundo', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2a 3m 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'em 3 anos', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'há 5m', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'há 2a 3m 1d 1s', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 semana 10 horas', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semana 6 dias', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 semana 6 dias', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'em 1 semana e 6 dias', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 semanas 1 hora', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'em uma hora', // CarbonInterval::days(2)->forHumans() '2 dias', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/KyTest.php
tests/Localization/KyTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class KyTest extends LocalizationTestCase { public const LOCALE = 'ky'; // Kirghiz public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Эртең саат 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Ишемби саат 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Жекшемби саат 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Дүйшөмбү саат 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Шейшемби саат 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Шаршемби саат 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Бейшемби саат 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Жума саат 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Шейшемби саат 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Шаршемби саат 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Бейшемби саат 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Жума саат 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Ишемби саат 00:00', // Carbon::now()->subDays(2)->calendar() 'Өткен аптанын Жекшемби күнү саат 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Кече саат 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Бүгүн саат 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Бүгүн саат 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Эртең саат 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Шейшемби саат 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Кече саат 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Кече саат 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Өткен аптанын Шейшемби күнү саат 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Өткен аптанын Дүйшөмбү күнү саат 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Өткен аптанын Жекшемби күнү саат 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Өткен аптанын Ишемби күнү саат 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Өткен аптанын Жума күнү саат 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Өткен аптанын Бейшемби күнү саат 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Өткен аптанын Шаршемби күнү саат 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Өткен аптанын Жума күнү саат 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1-чи 1-чи 1-чи 1-чи 1-чи', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2-чи 1-чи', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3-чү 1-чи', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4-чү 1-чи', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5-чи 1-чи', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6-чы 1-чи', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7-чи 1-чи', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11-чи 2-чи', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40-чы', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41-чи', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100-чү', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 таңкы CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 таңкы, 12:00 таңкы', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 таңкы, 1:30 таңкы', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 таңкы, 2:00 таңкы', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 таңкы, 6:00 таңкы', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 таңкы, 10:00 таңкы', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 түштөн кийинки, 12:00 түштөн кийинки', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 түштөн кийинки, 5:00 түштөн кийинки', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 түштөн кийинки, 9:30 түштөн кийинки', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 түштөн кийинки, 11:00 түштөн кийинки', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0-чү', // Carbon::now()->subSeconds(1)->diffForHumans() '1 секунд мурун', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1 сек. мурун', // Carbon::now()->subSeconds(2)->diffForHumans() '2 секунд мурун', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2 сек. мурун', // Carbon::now()->subMinutes(1)->diffForHumans() '1 мүнөт мурун', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1 мүн. мурун', // Carbon::now()->subMinutes(2)->diffForHumans() '2 мүнөт мурун', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2 мүн. мурун', // Carbon::now()->subHours(1)->diffForHumans() '1 саат мурун', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1 саат. мурун', // Carbon::now()->subHours(2)->diffForHumans() '2 саат мурун', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2 саат. мурун', // Carbon::now()->subDays(1)->diffForHumans() '1 күн мурун', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1 күн мурун', // Carbon::now()->subDays(2)->diffForHumans() '2 күн мурун', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2 күн мурун', // Carbon::now()->subWeeks(1)->diffForHumans() '1 апта мурун', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1 апт. мурун', // Carbon::now()->subWeeks(2)->diffForHumans() '2 апта мурун', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2 апт. мурун', // Carbon::now()->subMonths(1)->diffForHumans() '1 ай мурун', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1 ай мурун', // Carbon::now()->subMonths(2)->diffForHumans() '2 ай мурун', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2 ай мурун', // Carbon::now()->subYears(1)->diffForHumans() '1 жыл мурун', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1 жыл мурун', // Carbon::now()->subYears(2)->diffForHumans() '2 жыл мурун', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2 жыл мурун', // Carbon::now()->addSecond()->diffForHumans() '1 секунд ичинде', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1 сек. ичинде', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) 'after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) 'after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) 'before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) 'before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 секунд', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 сек.', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 секунд', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 сек.', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1 сек. ичинде', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 мүнөт 1 секунд', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 жыл 3 ай 1 күн 1 сек.', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 жыл ичинде', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5 ай мурун', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2 жыл 3 ай 1 күн 1 сек. мурун', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 апта 10 саат', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 апта 6 күн', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 апта 6 күн', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 апта 6 күн ичинде', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 апта 1 саат', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'бир саат ичинде', // CarbonInterval::days(2)->forHumans() '2 күн', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 күн 3 саат.', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/LanguagesCoverageTest.php
tests/Localization/LanguagesCoverageTest.php
<?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 Tests\Localization; use Tests\AbstractTestCase; class LanguagesCoverageTest extends AbstractTestCase { public function testAllLanguagesAreTested() { $languages = glob(__DIR__.'/../../src/Carbon/Lang/*.php'); $tests = array_map(function ($file) { return strtolower(substr(basename($file), 0, -8)); }, glob(__DIR__.'/*Test.php')); $tester = $this; $missingLanguages = array_filter($languages, function ($language) use ($tester, $tests) { $file = basename($language); $covered = \in_array( str_replace(['_', '-', '@'], '', strtolower(substr($file, 0, -4))), $tests, true, ); $tester->assertTrue($covered, "Expect $file language file to be covered."); return !$covered; }); $this->assertCount(0, $missingLanguages, 'Expect to have 0 languages uncovered.'); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/DvTest.php
tests/Localization/DvTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class DvTest extends LocalizationTestCase { public const LOCALE = 'dv'; // Divehi public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'މާދަމާ 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ހޮނިހިރު 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'އާދިއްތަ 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ހޯމަ 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'އަންގާރަ 00:00', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ބުދަ 00:00', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'ބުރާސްފަތި 00:00', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'ހުކުރު 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'އަންގާރަ 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ބުދަ 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ބުރާސްފަތި 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ހުކުރު 00:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ހޮނިހިރު 00:00', // Carbon::now()->subDays(2)->calendar() 'ފާއިތުވި އާދިއްތަ 20:49', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'އިއްޔެ 22:00', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'މިއަދު 10:00', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'މިއަދު 02:00', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'މާދަމާ 01:00', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'އަންގާރަ 00:00', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'އިއްޔެ 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'އިއްޔެ 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ފާއިތުވި އަންގާރަ 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ފާއިތުވި ހޯމަ 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ފާއިތުވި އާދިއްތަ 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ފާއިތުވި ހޮނިހިރު 00:00', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'ފާއިތުވި ހުކުރު 00:00', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'ފާއިތުވި ބުރާސްފަތި 00:00', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'ފާއިތުވި ބުދަ 00:00', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'ފާއިތުވި ހުކުރު 00:00', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1 1 1 1 1', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2 1', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3 1', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4 1', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5 1', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6 1', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7 2', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11 2', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 މކ CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 މކ, 12:00 މކ', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 މކ, 1:30 މކ', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 މކ, 2:00 މކ', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 މކ, 6:00 މކ', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 މކ, 10:00 މކ', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 މފ, 12:00 މފ', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 މފ, 5:00 މފ', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 މފ, 9:30 މފ', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 މފ, 11:00 މފ', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0', // Carbon::now()->subSeconds(1)->diffForHumans() 'ކުރިން 1 ސިކުންތު', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) 'ކުރިން 1 ސިކުންތު', // Carbon::now()->subSeconds(2)->diffForHumans() 'ކުރިން 2 ސިކުންތު', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) 'ކުރިން 2 ސިކުންތު', // Carbon::now()->subMinutes(1)->diffForHumans() 'ކުރިން 1 މިނިޓު', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) 'ކުރިން 1 މިނިޓު', // Carbon::now()->subMinutes(2)->diffForHumans() 'ކުރިން 2 މިނިޓު', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) 'ކުރިން 2 މިނިޓު', // Carbon::now()->subHours(1)->diffForHumans() 'ކުރިން 1 ގަޑިއިރު', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) 'ކުރިން 1 ގަޑިއިރު', // Carbon::now()->subHours(2)->diffForHumans() 'ކުރިން 2 ގަޑިއިރު', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) 'ކުރިން 2 ގަޑިއިރު', // Carbon::now()->subDays(1)->diffForHumans() 'ކުރިން 1 ދުވަސް', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) 'ކުރިން 1 ދުވަސް', // Carbon::now()->subDays(2)->diffForHumans() 'ކުރިން 2 ދުވަސް', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) 'ކުރިން 2 ދުވަސް', // Carbon::now()->subWeeks(1)->diffForHumans() 'ކުރިން 1 ހަފްތާ', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) 'ކުރިން 1 ހަފްތާ', // Carbon::now()->subWeeks(2)->diffForHumans() 'ކުރިން 2 ހަފްތާ', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) 'ކުރިން 2 ހަފްތާ', // Carbon::now()->subMonths(1)->diffForHumans() 'ކުރިން 1 މަސް', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) 'ކުރިން 1 މަސް', // Carbon::now()->subMonths(2)->diffForHumans() 'ކުރިން 2 މަސް', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) 'ކުރިން 2 މަސް', // Carbon::now()->subYears(1)->diffForHumans() 'ކުރިން 1 އަހަރު', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) 'ކުރިން 1 އަހަރު', // Carbon::now()->subYears(2)->diffForHumans() 'ކުރިން 2 އަހަރު', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) 'ކުރިން 2 އަހަރު', // Carbon::now()->addSecond()->diffForHumans() 'ތެރޭގައި 1 ސިކުންތު', // Carbon::now()->addSecond()->diffForHumans(null, false, true) 'ތެރޭގައި 1 ސިކުންތު', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 ސިކުންތު ފަހުން', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1 ސިކުންތު ފަހުން', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 ސިކުންތު ކުރި', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1 ސިކުންތު ކުރި', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 ސިކުންތު', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1 ސިކުންތު', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 ސިކުންތު', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2 ސިކުންތު', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) 'ތެރޭގައި 1 ސިކުންތު', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 މިނިޓު 1 ސިކުންތު', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2 އަހަރު 3 މަސް 1 ދުވަސް 1 ސިކުންތު', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) 'ތެރޭގައި 3 އަހަރު', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) 'ކުރިން 5 މަސް', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) 'ކުރިން 2 އަހަރު 3 މަސް 1 ދުވަސް 1 ސިކުންތު', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 ހަފްތާ 10 ގަޑިއިރު', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 ހަފްތާ 6 ދުވަސް', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 ހަފްތާ 6 ދުވަސް', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) 'ތެރޭގައި 1 ހަފްތާ އަދި 6 ދުވަސް', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 ހަފްތާ 1 ގަޑިއިރު', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'ތެރޭގައި ގަޑިއިރެއް', // CarbonInterval::days(2)->forHumans() '2 ދުވަސް', // CarbonInterval::create('P1DT3H')->forHumans(true) '1 ދުވަސް 3 ގަޑިއިރު', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/Localization/EnMoTest.php
tests/Localization/EnMoTest.php
<?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 Tests\Localization; use PHPUnit\Framework\Attributes\Group; #[Group('localization')] class EnMoTest extends LocalizationTestCase { public const LOCALE = 'en_MO'; // English public const CASES = [ // Carbon::parse('2018-01-04 00:00:00')->addDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tomorrow at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-05 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-05 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-06 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-06 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(4)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Thursday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(5)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Friday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(6)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Saturday at 12:00 AM', // Carbon::now()->subDays(2)->calendar() 'Last Sunday at 8:49 PM', // Carbon::parse('2018-01-04 00:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 10:00 PM', // Carbon::parse('2018-01-04 12:00:00')->subHours(2)->calendar(Carbon::parse('2018-01-04 12:00:00')) 'Today at 10:00 AM', // Carbon::parse('2018-01-04 00:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Today at 2:00 AM', // Carbon::parse('2018-01-04 23:00:00')->addHours(2)->calendar(Carbon::parse('2018-01-04 23:00:00')) 'Tomorrow at 1:00 AM', // Carbon::parse('2018-01-07 00:00:00')->addDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Tuesday at 12:00 AM', // Carbon::parse('2018-01-08 00:00:00')->subDay()->calendar(Carbon::parse('2018-01-08 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(1)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Yesterday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Tuesday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(3)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Monday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(4)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Sunday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(5)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Saturday at 12:00 AM', // Carbon::parse('2018-01-04 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-04 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-03 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-03 00:00:00')) 'Last Thursday at 12:00 AM', // Carbon::parse('2018-01-02 00:00:00')->subDays(6)->calendar(Carbon::parse('2018-01-02 00:00:00')) 'Last Wednesday at 12:00 AM', // Carbon::parse('2018-01-07 00:00:00')->subDays(2)->calendar(Carbon::parse('2018-01-07 00:00:00')) 'Last Friday at 12:00 AM', // Carbon::parse('2018-01-01 00:00:00')->isoFormat('Qo Mo Do Wo wo') '1st 1st 1st 1st 1st', // Carbon::parse('2018-01-02 00:00:00')->isoFormat('Do wo') '2nd 1st', // Carbon::parse('2018-01-03 00:00:00')->isoFormat('Do wo') '3rd 1st', // Carbon::parse('2018-01-04 00:00:00')->isoFormat('Do wo') '4th 1st', // Carbon::parse('2018-01-05 00:00:00')->isoFormat('Do wo') '5th 1st', // Carbon::parse('2018-01-06 00:00:00')->isoFormat('Do wo') '6th 1st', // Carbon::parse('2018-01-07 00:00:00')->isoFormat('Do wo') '7th 2nd', // Carbon::parse('2018-01-11 00:00:00')->isoFormat('Do wo') '11th 2nd', // Carbon::parse('2018-02-09 00:00:00')->isoFormat('DDDo') '40th', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('DDDo') '41st', // Carbon::parse('2018-04-10 00:00:00')->isoFormat('DDDo') '100th', // Carbon::parse('2018-02-10 00:00:00', 'Europe/Paris')->isoFormat('h:mm a z') '12:00 am CET', // Carbon::parse('2018-02-10 00:00:00')->isoFormat('h:mm A, h:mm a') '12:00 AM, 12:00 am', // Carbon::parse('2018-02-10 01:30:00')->isoFormat('h:mm A, h:mm a') '1:30 AM, 1:30 am', // Carbon::parse('2018-02-10 02:00:00')->isoFormat('h:mm A, h:mm a') '2:00 AM, 2:00 am', // Carbon::parse('2018-02-10 06:00:00')->isoFormat('h:mm A, h:mm a') '6:00 AM, 6:00 am', // Carbon::parse('2018-02-10 10:00:00')->isoFormat('h:mm A, h:mm a') '10:00 AM, 10:00 am', // Carbon::parse('2018-02-10 12:00:00')->isoFormat('h:mm A, h:mm a') '12:00 PM, 12:00 pm', // Carbon::parse('2018-02-10 17:00:00')->isoFormat('h:mm A, h:mm a') '5:00 PM, 5:00 pm', // Carbon::parse('2018-02-10 21:30:00')->isoFormat('h:mm A, h:mm a') '9:30 PM, 9:30 pm', // Carbon::parse('2018-02-10 23:00:00')->isoFormat('h:mm A, h:mm a') '11:00 PM, 11:00 pm', // Carbon::parse('2018-01-01 00:00:00')->ordinal('hour') '0th', // Carbon::now()->subSeconds(1)->diffForHumans() '1 second ago', // Carbon::now()->subSeconds(1)->diffForHumans(null, false, true) '1s ago', // Carbon::now()->subSeconds(2)->diffForHumans() '2 seconds ago', // Carbon::now()->subSeconds(2)->diffForHumans(null, false, true) '2s ago', // Carbon::now()->subMinutes(1)->diffForHumans() '1 minute ago', // Carbon::now()->subMinutes(1)->diffForHumans(null, false, true) '1m ago', // Carbon::now()->subMinutes(2)->diffForHumans() '2 minutes ago', // Carbon::now()->subMinutes(2)->diffForHumans(null, false, true) '2m ago', // Carbon::now()->subHours(1)->diffForHumans() '1 hour ago', // Carbon::now()->subHours(1)->diffForHumans(null, false, true) '1h ago', // Carbon::now()->subHours(2)->diffForHumans() '2 hours ago', // Carbon::now()->subHours(2)->diffForHumans(null, false, true) '2h ago', // Carbon::now()->subDays(1)->diffForHumans() '1 day ago', // Carbon::now()->subDays(1)->diffForHumans(null, false, true) '1d ago', // Carbon::now()->subDays(2)->diffForHumans() '2 days ago', // Carbon::now()->subDays(2)->diffForHumans(null, false, true) '2d ago', // Carbon::now()->subWeeks(1)->diffForHumans() '1 week ago', // Carbon::now()->subWeeks(1)->diffForHumans(null, false, true) '1w ago', // Carbon::now()->subWeeks(2)->diffForHumans() '2 weeks ago', // Carbon::now()->subWeeks(2)->diffForHumans(null, false, true) '2w ago', // Carbon::now()->subMonths(1)->diffForHumans() '1 month ago', // Carbon::now()->subMonths(1)->diffForHumans(null, false, true) '1mo ago', // Carbon::now()->subMonths(2)->diffForHumans() '2 months ago', // Carbon::now()->subMonths(2)->diffForHumans(null, false, true) '2mos ago', // Carbon::now()->subYears(1)->diffForHumans() '1 year ago', // Carbon::now()->subYears(1)->diffForHumans(null, false, true) '1yr ago', // Carbon::now()->subYears(2)->diffForHumans() '2 years ago', // Carbon::now()->subYears(2)->diffForHumans(null, false, true) '2yrs ago', // Carbon::now()->addSecond()->diffForHumans() '1 second from now', // Carbon::now()->addSecond()->diffForHumans(null, false, true) '1s from now', // Carbon::now()->addSecond()->diffForHumans(Carbon::now()) '1 second after', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), false, true) '1s after', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()) '1 second before', // Carbon::now()->diffForHumans(Carbon::now()->addSecond(), false, true) '1s before', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true) '1 second', // Carbon::now()->addSecond()->diffForHumans(Carbon::now(), true, true) '1s', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true) '2 seconds', // Carbon::now()->diffForHumans(Carbon::now()->addSecond()->addSecond(), true, true) '2s', // Carbon::now()->addSecond()->diffForHumans(null, false, true, 1) '1s from now', // Carbon::now()->addMinute()->addSecond()->diffForHumans(null, true, false, 2) '1 minute 1 second', // Carbon::now()->addYears(2)->addMonths(3)->addDay()->addSecond()->diffForHumans(null, true, true, 4) '2yrs 3mos 1d 1s', // Carbon::now()->addYears(3)->diffForHumans(null, null, false, 4) '3 years from now', // Carbon::now()->subMonths(5)->diffForHumans(null, null, true, 4) '5mos ago', // Carbon::now()->subYears(2)->subMonths(3)->subDay()->subSecond()->diffForHumans(null, null, true, 4) '2yrs 3mos 1d 1s ago', // Carbon::now()->addWeek()->addHours(10)->diffForHumans(null, true, false, 2) '1 week 10 hours', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(null, true, false, 2) '1 week 6 days', // Carbon::now()->addWeek()->addDays(6)->diffForHumans(["join" => true, "parts" => 2]) '1 week and 6 days from now', // Carbon::now()->addWeeks(2)->addHour()->diffForHumans(null, true, false, 2) '2 weeks 1 hour', // Carbon::now()->addHour()->diffForHumans(["aUnit" => true]) 'an hour from now', // CarbonInterval::days(2)->forHumans() '2 days', // CarbonInterval::create('P1DT3H')->forHumans(true) '1d 3h', ]; }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/LocalizationTest.php
tests/CarbonImmutable/LocalizationTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\CarbonInterval; use Carbon\Language; use Carbon\Translator; use InvalidArgumentException; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\TestWith; use Symfony\Component\Translation\IdentityTranslator; use Symfony\Component\Translation\Loader\ArrayLoader; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Translator as SymfonyTranslator; use Tests\AbstractTestCase; use Tests\CarbonImmutable\Fixtures\MyCarbon; #[Group('localization')] class LocalizationTest extends AbstractTestCase { protected function tearDown(): void { parent::tearDown(); Carbon::setLocale('en'); } public function testGetTranslator() { /** @var Translator $t */ $t = Carbon::getTranslator(); $this->assertNotNull($t); $this->assertSame('en', $t->getLocale()); } public function testResetTranslator() { /** @var Translator $t */ $t = MyCarbon::getTranslator(); $this->assertNotNull($t); $this->assertSame('en', $t->getLocale()); } #[TestWith([ 'fr', ['fr_FR.UTF-8', 'fr_FR.utf8', 'fr_FR', 'fr'], 'il y a 2 secondes', ])] #[TestWith([ 'sr', ['sr_ME.UTF-8', 'sr_ME.utf8', 'sr_ME', 'sr'], ['pre 2 sekunde' /* sr */, 'prije 2 sekunde' /* sr_ME */], ])] #[TestWith([ 'zh', ['zh_TW.UTF-8', 'zh_TW.utf8', 'zh_TW', 'zh'], '2秒前', ])] public function testSetLocaleToAutoFromSupportedLocale(string $language, array $locales, array|string $twoSecondsAgo) { $currentLocale = setlocale(LC_ALL, '0'); $this->setLocaleOrSkip(...$locales); try { Carbon::setLocale('auto'); $locale = Carbon::getLocale(); $diff = Carbon::now()->subSeconds(2)->diffForHumans(); } finally { setlocale(LC_ALL, $currentLocale); } $this->assertStringStartsWith($language, $locale); $this->assertContains($diff, (array) $twoSecondsAgo); } public function testSetLocaleToAutoFromUnsupportedLocale() { $currentLocale = setlocale(LC_ALL, '0'); $this->setLocaleOrSkip('ar_AE.UTF-8', 'ar_AE.utf8', 'ar_AE', 'ar'); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->resetMessages(); $translator->setLocale('en'); $directories = $translator->getDirectories(); $directory = sys_get_temp_dir().'/carbon'.mt_rand(0, 9999999); mkdir($directory); foreach (glob(__DIR__.'/../../src/Carbon/Lang/*.php') as $file) { copy($file, "$directory/".basename($file)); } try { $translator->setDirectories([$directory]); Carbon::setLocale('auto'); $locale = Carbon::getLocale(); $diff = Carbon::now()->subSeconds(2)->diffForHumans(); } finally { $translator->setDirectories([$directory]); setlocale(LC_ALL, $currentLocale); $this->remove($directory); $translator->setDirectories($directories); } $this->assertStringStartsWith('ar', $locale); $this->assertSame('منذ ثانيتين', $diff); } public function testSetLocaleToAutoFallback() { $currentLocale = setlocale(LC_ALL, '0'); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->resetMessages(); $translator->setLocale('en'); $directories = $translator->getDirectories(); $directory = sys_get_temp_dir().'/carbon'.mt_rand(0, 9999999); try { $this->setLocaleOrSkip('fr_FR.UTF-8', 'fr_FR.utf8', 'fr_FR', 'fr'); mkdir($directory); $files = [ 'en', 'zh_Hans', 'zh', 'fr', 'fr_CA', ]; foreach ($files as $file) { copy(__DIR__."/../../src/Carbon/Lang/$file.php", "$directory/$file.php"); } $translator->setDirectories([$directory]); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->resetMessages(); Carbon::setLocale('auto'); $locale = Carbon::getLocale(); $diff = Carbon::now()->subSeconds(2)->diffForHumans(); setlocale(LC_ALL, $currentLocale); $this->assertSame('fr', $locale); $this->assertSame('il y a 2 secondes', $diff); $this->setLocaleOrSkip('zh_CN.UTF-8', 'zh_CN.utf8', 'zh_CN', 'zh'); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->resetMessages(); Carbon::setLocale('auto'); $locale = Carbon::getLocale(); $diff = Carbon::now()->subSeconds(2)->diffForHumans(); setlocale(LC_ALL, $currentLocale); $this->assertSame('zh', $locale); $this->assertSame('2秒前', $diff); $this->setLocaleOrSkip('yo_NG.UTF-8', 'yo_NG.utf8', 'yo_NG', 'yo'); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->resetMessages(); Carbon::setLocale('en'); Carbon::setLocale('auto'); $locale = Carbon::getLocale(); $diff = Carbon::now()->subSeconds(2)->diffForHumans(); setlocale(LC_ALL, $currentLocale); $this->assertSame('en', $locale); $this->assertSame('2 seconds ago', $diff); } finally { setlocale(LC_ALL, $currentLocale); $translator->setDirectories($directories); $this->remove($directory); } } /** * @see \Tests\CarbonImmutable\LocalizationTest::testSetLocale * @see \Tests\CarbonImmutable\LocalizationTest::testSetTranslator */ public static function dataForLocales(): array { return [ 'af' => ['af'], 'ar' => ['ar'], 'ar_DZ' => ['ar_DZ'], 'ar_KW' => ['ar_KW'], 'ar_LY' => ['ar_LY'], 'ar_MA' => ['ar_MA'], 'ar_SA' => ['ar_SA'], 'ar_Shakl' => ['ar_Shakl'], 'ar_TN' => ['ar_TN'], 'az' => ['az'], 'be' => ['be'], 'bg' => ['bg'], 'bm' => ['bm'], 'bn' => ['bn'], 'bo' => ['bo'], 'br' => ['br'], 'bs' => ['bs'], 'bs_BA' => ['bs_BA'], 'ca' => ['ca'], 'cs' => ['cs'], 'cv' => ['cv'], 'cy' => ['cy'], 'da' => ['da'], 'de' => ['de'], 'de_AT' => ['de_AT'], 'de_CH' => ['de_CH'], 'dv' => ['dv'], 'dv_MV' => ['dv_MV'], 'el' => ['el'], 'en' => ['en'], 'en_AU' => ['en_AU'], 'en_CA' => ['en_CA'], 'en_GB' => ['en_GB'], 'en_IE' => ['en_IE'], 'en_IL' => ['en_IL'], 'en_NZ' => ['en_NZ'], 'eo' => ['eo'], 'es' => ['es'], 'es_DO' => ['es_DO'], 'es_US' => ['es_US'], 'et' => ['et'], 'eu' => ['eu'], 'fa' => ['fa'], 'fi' => ['fi'], 'fo' => ['fo'], 'fr' => ['fr'], 'fr_CA' => ['fr_CA'], 'fr_CH' => ['fr_CH'], 'fy' => ['fy'], 'gd' => ['gd'], 'gl' => ['gl'], 'gom_Latn' => ['gom_Latn'], 'gu' => ['gu'], 'he' => ['he'], 'hi' => ['hi'], 'hr' => ['hr'], 'hu' => ['hu'], 'hy' => ['hy'], 'hy_AM' => ['hy_AM'], 'id' => ['id'], 'is' => ['is'], 'it' => ['it'], 'ja' => ['ja'], 'jv' => ['jv'], 'ka' => ['ka'], 'kk' => ['kk'], 'km' => ['km'], 'kn' => ['kn'], 'ko' => ['ko'], 'ku' => ['ku'], 'ky' => ['ky'], 'lb' => ['lb'], 'lo' => ['lo'], 'lt' => ['lt'], 'lv' => ['lv'], 'me' => ['me'], 'mi' => ['mi'], 'mk' => ['mk'], 'ml' => ['ml'], 'mn' => ['mn'], 'mr' => ['mr'], 'ms' => ['ms'], 'ms_MY' => ['ms_MY'], 'mt' => ['mt'], 'my' => ['my'], 'nb' => ['nb'], 'ne' => ['ne'], 'nl' => ['nl'], 'nl_BE' => ['nl_BE'], 'nn' => ['nn'], 'no' => ['no'], 'oc' => ['oc'], 'pa_IN' => ['pa_IN'], 'pl' => ['pl'], 'ps' => ['ps'], 'pt' => ['pt'], 'pt_BR' => ['pt_BR'], 'ro' => ['ro'], 'ru' => ['ru'], 'sd' => ['sd'], 'se' => ['se'], 'sh' => ['sh'], 'si' => ['si'], 'sk' => ['sk'], 'sl' => ['sl'], 'sq' => ['sq'], 'sr' => ['sr'], 'sr_Cyrl' => ['sr_Cyrl'], 'sr_Cyrl_ME' => ['sr_Cyrl_ME'], 'sr_Latn_ME' => ['sr_Latn_ME'], 'sr_ME' => ['sr_ME'], 'ss' => ['ss'], 'sv' => ['sv'], 'sw' => ['sw'], 'ta' => ['ta'], 'te' => ['te'], 'tet' => ['tet'], 'tg' => ['tg'], 'th' => ['th'], 'tl_PH' => ['tl_PH'], 'tlh' => ['tlh'], 'tr' => ['tr'], 'tzl' => ['tzl'], 'tzm' => ['tzm'], 'tzm_Latn' => ['tzm_Latn'], 'ug_CN' => ['ug_CN'], 'uk' => ['uk'], 'ur' => ['ur'], 'uz' => ['uz'], 'uz_Latn' => ['uz_Latn'], 'vi' => ['vi'], 'yo' => ['yo'], 'zh' => ['zh'], 'zh_CN' => ['zh_CN'], 'zh_HK' => ['zh_HK'], 'zh_TW' => ['zh_TW'], ]; } #[DataProvider('dataForLocales')] public function testSetLocale(string $locale) { Carbon::setLocale($locale); $this->assertTrue($this->areSameLocales($locale, Carbon::getLocale())); } #[DataProvider('dataForLocales')] public function testSetTranslator(string $locale) { $ori = Carbon::getTranslator(); $t = new Translator($locale); $t->addLoader('array', new ArrayLoader()); Carbon::setTranslator($t); /** @var Translator $t */ $t = Carbon::getTranslator(); $this->assertNotNull($t); $this->assertTrue($this->areSameLocales($locale, $t->getLocale())); Carbon::setTranslator($ori); } public function testSetLocaleWithKnownLocale() { Carbon::setLocale('fr'); $this->assertSame('fr', Carbon::getLocale()); } #[TestWith(['DE'])] #[TestWith(['pt-BR'])] #[TestWith(['pt-br'])] #[TestWith(['PT-br'])] #[TestWith(['PT-BR'])] #[TestWith(['pt_br'])] #[TestWith(['PT_br'])] #[TestWith(['PT_BR'])] public function testSetLocaleWithMalformedLocale(string $malformedLocale) { Carbon::setLocale($malformedLocale); $split = preg_split('/[-_]/', $malformedLocale); $this->assertSame( strtolower($split[0]).(\count($split) === 1 ? '' : '_'.strtoupper($split[1])), Carbon::getLocale(), ); } public function testSetLocaleWithNonExistingLocale() { Carbon::setLocale('pt-XX'); $this->assertSame('pt', Carbon::getLocale()); } public function testSetLocaleWithUnknownLocale() { Carbon::setLocale('zz'); $this->assertSame('en', Carbon::getLocale()); } public function testCustomTranslation() { Carbon::setLocale('en'); /** @var Translator $translator */ $translator = Carbon::getTranslator(); /** @var MessageCatalogue $messages */ $messages = $translator->getCatalogue('en'); $resources = $messages->all('messages'); $resources['day'] = '1 boring day|%count% boring days'; $translator->addResource('array', $resources, 'en'); $diff = Carbon::create(2018, 1, 1, 0, 0, 0) ->diffForHumans(Carbon::create(2018, 1, 4, 4, 0, 0), true, false, 2); $this->assertSame('3 boring days 4 hours', $diff); Carbon::setLocale('en'); } public function testAddCustomTranslation() { $enBoring = [ 'day' => '1 boring day|%count% boring days', ]; Carbon::setLocale('en'); $this->assertSame('en', Carbon::getLocale()); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->setMessages('en', $enBoring); $diff = Carbon::create(2018, 1, 1, 0, 0, 0) ->diffForHumans(Carbon::create(2018, 1, 4, 4, 0, 0), true, false, 2); $this->assertSame('3 boring days 4 hours', $diff); $translator->resetMessages('en'); $diff = Carbon::create(2018, 1, 1, 0, 0, 0) ->diffForHumans(Carbon::create(2018, 1, 4, 4, 0, 0), true, false, 2); $this->assertSame('3 days 4 hours', $diff); $translator->setMessages('en_Boring', $enBoring); $this->assertSame($enBoring, $translator->getMessages('en_Boring')); $messages = $translator->getMessages(); $this->assertArrayHasKey('en', $messages); $this->assertArrayHasKey('en_Boring', $messages); $this->assertSame($enBoring, $messages['en_Boring']); Carbon::setLocale('en_Boring'); $this->assertSame('en_Boring', Carbon::getLocale()); $diff = Carbon::create(2018, 1, 1, 0, 0, 0) ->diffForHumans(Carbon::create(2018, 1, 4, 4, 0, 0), true, false, 2); // en_Boring inherit en because it starts with "en", see symfony-translation behavior $this->assertSame('3 boring days 4 hours', $diff); $translator->resetMessages(); $this->assertSame([], $translator->getMessages()); Carbon::setLocale('en'); $this->assertSame('en', Carbon::getLocale()); } public function testCustomWeekStart() { Carbon::setLocale('ru'); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->setMessages('ru', [ 'first_day_of_week' => 1, ]); $calendar = Carbon::parse('2018-07-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-07-07 00:00:00')); $this->assertSame('В следующий вторник, в 0:00', $calendar); $calendar = Carbon::parse('2018-07-12 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-07-12 00:00:00')); $this->assertSame('В воскресенье, в 0:00', $calendar); $translator->setMessages('ru', [ 'first_day_of_week' => 5, ]); $calendar = Carbon::parse('2018-07-07 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-07-07 00:00:00')); $this->assertSame('Во вторник, в 0:00', $calendar); $calendar = Carbon::parse('2018-07-12 00:00:00')->addDays(3)->calendar(Carbon::parse('2018-07-12 00:00:00')); $this->assertSame('В следующее воскресенье, в 0:00', $calendar); $translator->resetMessages('ru'); Carbon::setLocale('en'); } public function testAddAndRemoveDirectory() { $directory = sys_get_temp_dir().'/carbon'.mt_rand(0, 9999999); mkdir($directory); copy(__DIR__.'/../../src/Carbon/Lang/fr.php', "$directory/foo.php"); copy(__DIR__.'/../../src/Carbon/Lang/fr.php', "$directory/bar.php"); /** @var Translator $translator */ $translator = Carbon::getTranslator(); Carbon::setLocale('en'); Carbon::setLocale('foo'); $this->assertSame('Saturday', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); $translator->addDirectory($directory); Carbon::setLocale('foo'); $this->assertSame('samedi', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); Carbon::setLocale('en'); $translator->removeDirectory($directory); Carbon::setLocale('bar'); $this->assertSame('Saturday', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); Carbon::setLocale('foo'); $this->assertSame('samedi', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); Carbon::setLocale('en'); } public function testLocaleHasShortUnits() { $withShortUnit = [ 'year' => 'foo', 'y' => 'bar', ]; $withShortHourOnly = [ 'year' => 'foo', 'y' => 'foo', 'day' => 'foo', 'd' => 'foo', 'hour' => 'foo', 'h' => 'bar', ]; $withoutShortUnit = [ 'year' => 'foo', ]; $withSameShortUnit = [ 'year' => 'foo', 'y' => 'foo', ]; $withShortHourOnlyLocale = 'zz_'.ucfirst(strtolower('withShortHourOnly')); $withShortUnitLocale = 'zz_'.ucfirst(strtolower('withShortUnit')); $withoutShortUnitLocale = 'zz_'.ucfirst(strtolower('withoutShortUnit')); $withSameShortUnitLocale = 'zz_'.ucfirst(strtolower('withSameShortUnit')); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->setMessages($withShortUnitLocale, $withShortUnit); $translator->setMessages($withShortHourOnlyLocale, $withShortHourOnly); $translator->setMessages($withoutShortUnitLocale, $withoutShortUnit); $translator->setMessages($withSameShortUnitLocale, $withSameShortUnit); $this->assertTrue(Carbon::localeHasShortUnits($withShortUnitLocale)); $this->assertTrue(Carbon::localeHasShortUnits($withShortHourOnlyLocale)); $this->assertFalse(Carbon::localeHasShortUnits($withoutShortUnitLocale)); $this->assertFalse(Carbon::localeHasShortUnits($withSameShortUnitLocale)); } public function testLocaleHasDiffSyntax() { $withDiffSyntax = [ 'year' => 'foo', 'ago' => ':time ago', 'from_now' => ':time from now', 'after' => ':time after', 'before' => ':time before', ]; $withoutDiffSyntax = [ 'year' => 'foo', ]; $withDiffSyntaxLocale = 'zz_'.ucfirst(strtolower('withDiffSyntax')); $withoutDiffSyntaxLocale = 'zz_'.ucfirst(strtolower('withoutDiffSyntax')); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->setMessages($withDiffSyntaxLocale, $withDiffSyntax); $translator->setMessages($withoutDiffSyntaxLocale, $withoutDiffSyntax); $this->assertTrue(Carbon::localeHasDiffSyntax($withDiffSyntaxLocale)); $this->assertFalse(Carbon::localeHasDiffSyntax($withoutDiffSyntaxLocale)); $this->assertTrue(Carbon::localeHasDiffSyntax('ka')); $this->assertFalse(Carbon::localeHasDiffSyntax('foobar')); } public function testLocaleHasDiffOneDayWords() { $withOneDayWords = [ 'year' => 'foo', 'diff_now' => 'just now', 'diff_yesterday' => 'yesterday', 'diff_tomorrow' => 'tomorrow', ]; $withoutOneDayWords = [ 'year' => 'foo', ]; $withOneDayWordsLocale = 'zz_'.ucfirst(strtolower('withOneDayWords')); $withoutOneDayWordsLocale = 'zz_'.ucfirst(strtolower('withoutOneDayWords')); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->setMessages($withOneDayWordsLocale, $withOneDayWords); $translator->setMessages($withoutOneDayWordsLocale, $withoutOneDayWords); $this->assertTrue(Carbon::localeHasDiffOneDayWords($withOneDayWordsLocale)); $this->assertFalse(Carbon::localeHasDiffOneDayWords($withoutOneDayWordsLocale)); } public function testLocaleHasDiffTwoDayWords() { $withTwoDayWords = [ 'year' => 'foo', 'diff_before_yesterday' => 'before yesterday', 'diff_after_tomorrow' => 'after tomorrow', ]; $withoutTwoDayWords = [ 'year' => 'foo', ]; $withTwoDayWordsLocale = 'zz_'.ucfirst(strtolower('withTwoDayWords')); $withoutTwoDayWordsLocale = 'zz_'.ucfirst(strtolower('withoutTwoDayWords')); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->setMessages($withTwoDayWordsLocale, $withTwoDayWords); $translator->setMessages($withoutTwoDayWordsLocale, $withoutTwoDayWords); $this->assertTrue(Carbon::localeHasDiffTwoDayWords($withTwoDayWordsLocale)); $this->assertFalse(Carbon::localeHasDiffTwoDayWords($withoutTwoDayWordsLocale)); } public function testLocaleHasPeriodSyntax() { $withPeriodSyntax = [ 'year' => 'foo', 'period_recurrences' => 'once|%count% times', 'period_interval' => 'every :interval', 'period_start_date' => 'from :date', 'period_end_date' => 'to :date', ]; $withoutPeriodSyntax = [ 'year' => 'foo', ]; $withPeriodSyntaxLocale = 'zz_'.ucfirst(strtolower('withPeriodSyntax')); $withoutPeriodSyntaxLocale = 'zz_'.ucfirst(strtolower('withoutPeriodSyntax')); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->setMessages($withPeriodSyntaxLocale, $withPeriodSyntax); $translator->setMessages($withoutPeriodSyntaxLocale, $withoutPeriodSyntax); $this->assertTrue(Carbon::localeHasPeriodSyntax($withPeriodSyntaxLocale)); $this->assertFalse(Carbon::localeHasPeriodSyntax($withoutPeriodSyntaxLocale)); $this->assertTrue(Carbon::localeHasPeriodSyntax('nl')); } public function testGetAvailableLocales() { $this->assertCount(\count(glob(__DIR__.'/../../src/Carbon/Lang/*.php')), Carbon::getAvailableLocales()); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->setMessages('zz_ZZ', []); $this->assertContains('zz_ZZ', Carbon::getAvailableLocales()); Carbon::setTranslator(new SymfonyTranslator('en')); $this->assertSame(['en'], Carbon::getAvailableLocales()); } public function testGetAvailableLocalesInfo() { $infos = Carbon::getAvailableLocalesInfo(); $this->assertCount(\count(Carbon::getAvailableLocales()), Carbon::getAvailableLocalesInfo()); $this->assertArrayHasKey('en', $infos); $this->assertInstanceOf(Language::class, $infos['en']); $this->assertSame('English', $infos['en']->getIsoName()); } public function testGeorgianSpecialFromNowTranslation() { $diff = Carbon::now()->locale('ka')->addWeeks(3)->diffForHumans(); $this->assertSame('3 კვირაში', $diff); } public function testWeekDayMultipleForms() { $date = Carbon::parse('2018-10-10')->locale('ru'); $this->assertSame('в среду', $date->isoFormat('[в] dddd')); $this->assertSame('среда, 10 октября 2018', $date->isoFormat('dddd, D MMMM YYYY')); $this->assertSame('среда', $date->dayName); $this->assertSame('ср', $date->isoFormat('dd')); $date = Carbon::parse('2018-10-10')->locale('uk'); $this->assertSame('середа, 10', $date->isoFormat('dddd, D')); $this->assertSame('в середу', $date->isoFormat('[в] dddd')); $this->assertSame('минулої середи', $date->isoFormat('[минулої] dddd')); } public function testTranslationCustomWithCustomTranslator() { $this->expectExceptionObject(new InvalidArgumentException( 'Translator does not implement Symfony\Contracts\Translation\TranslatorInterface '. 'and Symfony\Component\Translation\TranslatorBagInterface. '. 'Symfony\Component\Translation\IdentityTranslator has been given.', )); $date = Carbon::create(2018, 1, 1, 0, 0, 0); $date->setLocalTranslator(new IdentityTranslator()); $date->getTranslationMessage('foo'); } public function testTranslateTimeStringTo() { $date = Carbon::parse('2019-07-05')->locale('de'); $baseString = $date->isoFormat('LLLL'); $this->assertSame('Freitag, 5. Juli 2019 00:00', $baseString); $this->assertSame('Friday, 5. July 2019 00:00', $date->translateTimeStringTo($baseString)); $this->assertSame('vendredi, 5. juillet 2019 00:00', $date->translateTimeStringTo($baseString, 'fr')); } public function testFallbackLocales() { // /!\ Used for backward compatibility, please avoid this method // @see testMultiLocales() as preferred method $myDialect = 'xx_MY_Dialect'; $secondChoice = 'xy_MY_Dialect'; $thirdChoice = 'it_CH'; /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->setMessages($myDialect, [ 'day' => ':count yub yub', ]); $translator->setMessages($secondChoice, [ 'day' => ':count buza', 'hour' => ':count ohto', ]); Carbon::setLocale($myDialect); Carbon::setFallbackLocale($thirdChoice); $this->assertSame($thirdChoice, Carbon::getFallbackLocale()); $this->assertSame('3 yub yub e 5 ora fa', Carbon::now()->subDays(3)->subHours(5)->ago([ 'parts' => 2, 'join' => true, ])); Carbon::setTranslator(new Translator('en')); /** @var Translator $translator */ $translator = Carbon::getTranslator(); $translator->setMessages($myDialect, [ 'day' => ':count yub yub', ]); $translator->setMessages($secondChoice, [ 'day' => ':count buza', 'hour' => ':count ohto', ]); Carbon::setLocale($myDialect); Carbon::setFallbackLocale($secondChoice); Carbon::setFallbackLocale($thirdChoice); $this->assertSame($thirdChoice, Carbon::getFallbackLocale()); $this->assertSame('3 yub yub e 5 ohto fa', Carbon::now()->subDays(3)->subHours(5)->ago([ 'parts' => 2, 'join' => true, ])); Carbon::setTranslator(new IdentityTranslator()); $this->assertNull(Carbon::getFallbackLocale()); Carbon::setTranslator(new Translator('en')); } public function testMultiLocales() { $myDialect = 'xx_MY_Dialect'; $secondChoice = 'xy_MY_Dialect'; $thirdChoice = 'it_CH'; Translator::get($myDialect)->setTranslations([ 'day' => ':count yub yub', ]); Translator::get($secondChoice)->setTranslations([ 'day' => ':count buza', 'hour' => ':count ohto', ]); $date = Carbon::now()->subDays(3)->subHours(5)->locale($myDialect, $secondChoice, $thirdChoice); $this->assertSame('3 yub yub e 5 ohto fa', $date->ago([ 'parts' => 2, 'join' => true, ])); } public function testStandAloneMonthsInLLLFormat() { $this->assertSame( '29 февраля 2020 г., 12:24', Carbon::parse('2020-02-29 12:24:00')->locale('ru_RU')->isoFormat('LLL'), 'Use "months" for date formatting', ); } public function testStandAloneMonthName() { $this->assertSame( 'февраль', Carbon::parse('2020-02-29 12:24:00')->locale('ru_RU')->monthName, 'Use "months_standalone" the month alone', ); } public function testShortMonthNameInFormat() { $this->assertSame( '29. мая', Carbon::parse('2020-05-29 12:24:00')->locale('ru_RU')->isoFormat('D. MMM'), 'Use "months_short" for date formatting', ); $this->assertSame( 'май', Carbon::parse('2020-05-29 12:24:00')->locale('ru_RU')->isoFormat('MMM'), 'Use "months_short" for date formatting', ); } public function testStandAloneShortMonthName() { $this->assertSame( 'май', Carbon::parse('2020-05-29 12:24:00')->locale('ru_RU')->shortMonthName, 'Use "months_short_standalone" the month alone', ); } public function testAgoDeclension() { $this->assertSame( 'година', CarbonInterval::hour()->locale('uk')->forHumans(['aUnit' => true]), ); $this->assertSame( 'годину тому', Carbon::now()->subHour()->locale('uk')->diffForHumans(['aUnit' => true]), ); } public function testPolishDeclensions() { $hour = Carbon::now()->addHour()->locale('pl'); $minute = Carbon::now()->addMinute()->locale('pl'); $second = Carbon::now()->addSecond()->locale('pl'); $this->assertSame('za 1 godzinę', $hour->diffForHumans()); $this->assertSame('za 1 minutę', $minute->diffForHumans()); $this->assertSame('za 1 sekundę', $second->diffForHumans()); $this->assertSame('za godzinę', $hour->diffForHumans(['aUnit' => true])); $this->assertSame('za minutę', $minute->diffForHumans(['aUnit' => true])); $this->assertSame('za sekundę', $second->translate('from_now', ['time' => 'sekunda'])); } public function testDeclensionModes() { Carbon::setTestNow('2022-12-30'); $this->assertSame( '2 жил 3 сар 1 өдөр 1с өмнө', Carbon::now() ->subYears(2) ->subMonths(3) ->subDay() ->subSecond() ->locale('mn') ->diffForHumans(null, null, true, 4) ); $this->assertSame( '2 жил 3 сар 1 өдөр 1 секундын өмнө', Carbon::now() ->subYears(2) ->subMonths(3) ->subDay() ->subSecond() ->locale('mn') ->diffForHumans(null, null, false, 4) ); } #[TestWith(['мая', 'May'])] #[TestWith(['май', 'May'])] #[TestWith(['февраль', 'February'])] #[TestWith(['февраля', 'February'])] public function testTranslateMonthsEitherStandaloneOrNot(string $ru, string $en) { $this->assertSame($en, \Carbon\Carbon::translateTimeString($ru, 'ru', 'en')); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/ConstructTest.php
tests/CarbonImmutable/ConstructTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\Exceptions\InvalidFormatException; use DateTime; use DateTimeImmutable; use DateTimeInterface; use DateTimeZone; use Tests\AbstractTestCase; class ConstructTest extends AbstractTestCase { public function testCreatesAnInstanceDefaultToNow() { $c = new Carbon(); $now = Carbon::now(); $this->assertInstanceOfCarbon($c); $this->assertInstanceOf(DateTimeImmutable::class, $c); $this->assertInstanceOf(DateTimeInterface::class, $c); $this->assertSame($now->tzName, $c->tzName); $this->assertCarbon($c, $now->year, $now->month, $now->day, $now->hour, $now->minute, $now->second); } public function testCreatesAnInstanceFromADateTime() { $c = new Carbon(Carbon::parse('2009-09-09 09:09:09')); $this->assertSame('2009-09-09 09:09:09 America/Toronto', $c->format('Y-m-d H:i:s e')); $c = new Carbon(new DateTime('2009-09-09 09:09:09')); $this->assertSame('2009-09-09 09:09:09 America/Toronto', $c->format('Y-m-d H:i:s e')); $c = new Carbon(new DateTime('2009-09-09 09:09:09', new DateTimeZone('Europe/Paris'))); $this->assertSame('2009-09-09 09:09:09 Europe/Paris', $c->format('Y-m-d H:i:s e')); $c = new Carbon(new DateTime('2009-09-09 09:09:09'), 'Europe/Paris'); $this->assertSame('2009-09-09 15:09:09 Europe/Paris', $c->format('Y-m-d H:i:s e')); $c = new Carbon(new DateTime('2009-09-09 09:09:09', new DateTimeZone('Asia/Tokyo')), 'Europe/Paris'); $this->assertSame('2009-09-09 02:09:09 Europe/Paris', $c->format('Y-m-d H:i:s e')); } public function testParseCreatesAnInstanceDefaultToNow() { $c = Carbon::parse(null); $now = Carbon::now(); $this->assertInstanceOfCarbon($c); $this->assertSame($now->tzName, $c->tzName); $this->assertCarbon($c, $now->year, $now->month, $now->day, $now->hour, $now->minute, $now->second); } public function testWithFancyString() { Carbon::setTestNow(Carbon::today()); $c = new Carbon('first day of January 2008'); $this->assertCarbon($c, 2008, 1, 1, 0, 0, 0); } public function testParseWithFancyString() { Carbon::setTestNow(Carbon::today()); $c = Carbon::parse('first day of January 2008'); $this->assertCarbon($c, 2008, 1, 1, 0, 0, 0); } public function testParseWithYYYMMDD() { $c = Carbon::parse('20201128'); $this->assertCarbon($c, 2020, 11, 28, 0, 0, 0); } public function testParseWithYYYMMDDHHMMSS() { $c = Carbon::parse('20201128192533'); $this->assertCarbon($c, 2020, 11, 28, 19, 25, 33); } public function testDefaultTimezone() { $c = new Carbon('now'); $this->assertSame('America/Toronto', $c->tzName); } public function testParseWithDefaultTimezone() { $c = Carbon::parse('now'); $this->assertSame('America/Toronto', $c->tzName); } public function testSettingTimezone() { $timezone = 'Europe/London'; $dtz = new DateTimeZone($timezone); $dt = new DateTime('now', $dtz); $dayLightSavingTimeOffset = (int) $dt->format('I'); $c = new Carbon('now', $dtz); $this->assertSame($timezone, $c->tzName); $this->assertSame($dayLightSavingTimeOffset, $c->offsetHours); } public function testParseSettingTimezone() { $timezone = 'Europe/London'; $dtz = new DateTimeZone($timezone); $dt = new DateTime('now', $dtz); $dayLightSavingTimeOffset = (int) $dt->format('I'); $c = Carbon::parse('now', $dtz); $this->assertSame($timezone, $c->tzName); $this->assertSame($dayLightSavingTimeOffset, $c->offsetHours); } public function testSettingTimezoneWithString() { $timezone = 'Asia/Tokyo'; $dtz = new DateTimeZone($timezone); $dt = new DateTime('now', $dtz); $dayLightSavingTimeOffset = (int) $dt->format('I'); $c = new Carbon('now', $timezone); $this->assertSame($timezone, $c->tzName); $this->assertSame(9 + $dayLightSavingTimeOffset, $c->offsetHours); } public function testParseSettingTimezoneWithString() { $timezone = 'Asia/Tokyo'; $dtz = new DateTimeZone($timezone); $dt = new DateTime('now', $dtz); $dayLightSavingTimeOffset = (int) $dt->format('I'); $c = Carbon::parse('now', $timezone); $this->assertSame($timezone, $c->tzName); $this->assertSame(9 + $dayLightSavingTimeOffset, $c->offsetHours); } public function testParseError() { $this->expectException(InvalidFormatException::class); $this->expectExceptionMessage("Could not parse 'completely broken'"); $this->expectExceptionMessage('Failed to parse time string'); Carbon::parse('completely broken'); } public function testMockingWithMicroseconds() { $c = new Carbon(Carbon::now()->toDateTimeString().'.123456'); Carbon::setTestNow($c); $mockedC = Carbon::now(); $this->assertTrue($c->eq($mockedC)); Carbon::setTestNow(); } public function testTimestamp() { $date = new Carbon(1367186296); $this->assertSame('Sunday 28 April 2013 21:58:16.000000', $date->format('l j F Y H:i:s.u')); $date = new Carbon(123); $this->assertSame('Thursday 1 January 1970 00:02:03.000000', $date->format('l j F Y H:i:s.u')); } public function testFloatTimestamp() { $date = new Carbon(1367186296.654321); $this->assertSame('Sunday 28 April 2013 21:58:16.654321', $date->format('l j F Y H:i:s.u')); $date = new Carbon(123.5); $this->assertSame('Thursday 1 January 1970 00:02:03.500000', $date->format('l j F Y H:i:s.u')); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/StringsTest.php
tests/CarbonImmutable/StringsTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\CarbonInterface; use Carbon\FactoryImmutable; use DateTime; use Tests\AbstractTestCase; use Tests\Carbon\Fixtures\MyCarbon; use Tests\CarbonImmutable\Fixtures\BadIsoCarbon; class StringsTest extends AbstractTestCase { public function testToString() { $d = Carbon::now(); $this->assertSame(Carbon::now()->toDateTimeString(), ''.$d); } public function testSetToStringFormatString() { Carbon::setToStringFormat('jS \o\f F, Y g:i:s a'); $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('25th of December, 1975 2:15:16 pm', ''.$d); } public function testSetToStringFormatClosure() { Carbon::setToStringFormat(function (CarbonInterface $d) { $format = $d->year === 1976 ? 'jS \o\f F g:i:s a' : 'jS \o\f F, Y g:i:s a'; return $d->format($format); }); $d = Carbon::create(1976, 12, 25, 14, 15, 16); $this->assertSame('25th of December 2:15:16 pm', ''.$d); $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('25th of December, 1975 2:15:16 pm', ''.$d); } public function testSetToStringFormatViaSettings() { $factory = new FactoryImmutable([ 'toStringFormat' => function (CarbonInterface $d) { return $d->isoFormat('dddd'); }, ]); $d = $factory->create(1976, 12, 25, 14, 15, 16); $this->assertSame('Saturday', ''.$d); } public function testResetToStringFormat() { $d = Carbon::now(); Carbon::setToStringFormat('123'); Carbon::resetToStringFormat(); $this->assertSame($d->toDateTimeString(), ''.$d); } public function testExtendedClassToString() { $d = MyCarbon::now(); $this->assertSame($d->toDateTimeString(), ''.$d); } public function testToDateString() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('1975-12-25', $d->toDateString()); } public function testToFormattedDateString() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('Dec 25, 1975', $d->toFormattedDateString()); } public function testToTimeString() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('14:15:16', $d->toTimeString()); } public function testToDateTimeString() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('1975-12-25 14:15:16', $d->toDateTimeString()); } public function testToDateTimeStringWithPaddedZeroes() { $d = Carbon::create(2000, 5, 2, 4, 3, 4); $this->assertSame('2000-05-02 04:03:04', $d->toDateTimeString()); } public function testToDayDateTimeString() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('Thu, Dec 25, 1975 2:15 PM', $d->toDayDateTimeString()); } public function testToAtomString() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('1975-12-25T14:15:16-05:00', $d->toAtomString()); } public function testToCOOKIEString() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame( DateTime::COOKIE === 'l, d-M-y H:i:s T' ? 'Thursday, 25-Dec-75 14:15:16 EST' : 'Thursday, 25-Dec-1975 14:15:16 EST', $d->toCookieString(), ); } public function testToIso8601String() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('1975-12-25T14:15:16-05:00', $d->toIso8601String()); } public function testToIso8601ZuluString() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('1975-12-25T19:15:16Z', $d->toIso8601ZuluString()); } public function testToRC822String() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('Thu, 25 Dec 75 14:15:16 -0500', $d->toRfc822String()); } public function testToRfc850String() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('Thursday, 25-Dec-75 14:15:16 EST', $d->toRfc850String()); } public function testToRfc1036String() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('Thu, 25 Dec 75 14:15:16 -0500', $d->toRfc1036String()); } public function testToRfc1123String() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('Thu, 25 Dec 1975 14:15:16 -0500', $d->toRfc1123String()); } public function testToRfc2822String() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('Thu, 25 Dec 1975 14:15:16 -0500', $d->toRfc2822String()); } public function testToRfc3339String() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('1975-12-25T14:15:16-05:00', $d->toRfc3339String()); $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('1975-12-25T14:15:16.000-05:00', $d->toRfc3339String(true)); } public function testToRssString() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('Thu, 25 Dec 1975 14:15:16 -0500', $d->toRssString()); } public function testToW3cString() { $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('1975-12-25T14:15:16-05:00', $d->toW3cString()); } public function testToRfc7231String() { $d = Carbon::create(1975, 12, 25, 14, 15, 16, 'GMT'); $this->assertSame('Thu, 25 Dec 1975 14:15:16 GMT', $d->toRfc7231String()); $d = Carbon::create(1975, 12, 25, 14, 15, 16); $this->assertSame('Thu, 25 Dec 1975 19:15:16 GMT', $d->toRfc7231String()); } public function testIsoFormat() { $d = Carbon::parse('midnight'); $this->assertSame('24', $d->isoFormat('k')); $d = Carbon::parse('2017-01-01'); $this->assertSame('2017', $d->isoFormat('g')); $this->assertSame('2017', $d->locale('en_US')->isoFormat('g')); $this->assertSame('2016', $d->locale('fr')->isoFormat('g')); $this->assertSame('2016', $d->isoFormat('G')); $this->assertSame('2016', $d->locale('en_US')->isoFormat('G')); $this->assertSame('2016', $d->locale('fr')->isoFormat('G')); $d = Carbon::parse('2015-12-31'); $this->assertSame('2016', $d->isoFormat('g')); $this->assertSame('2016', $d->locale('en_US')->isoFormat('g')); $this->assertSame('2015', $d->locale('fr')->isoFormat('g')); $this->assertSame('2015', $d->isoFormat('G')); $this->assertSame('2015', $d->locale('en_US')->isoFormat('G')); $this->assertSame('2015', $d->locale('fr')->isoFormat('G')); $d = Carbon::parse('2017-01-01 22:25:24.182937'); $this->assertSame('1 18 182 1829 18293 182937', $d->isoFormat('S SS SSS SSSS SSSSS SSSSSS')); $this->assertSame('02017 +002017', $d->isoFormat('YYYYY YYYYYY')); $this->assertSame(-117, Carbon::create(-117, 1, 1)->year); $this->assertSame('-00117 -000117', Carbon::create(-117, 1, 1)->isoFormat('YYYYY YYYYYY')); $this->assertSame('M01', $d->isoFormat('\\MMM')); $this->assertSame('Jan', $d->isoFormat('MMM')); $this->assertSame('janv.', $d->locale('fr')->isoFormat('MMM')); $this->assertSame('ene.', $d->locale('es')->isoFormat('MMM')); $this->assertSame('1 de enero de 2017', $d->locale('es')->isoFormat('LL')); $this->assertSame('1 de ene. de 2017', $d->locale('es')->isoFormat('ll')); $this->assertSame('1st', Carbon::parse('2018-06-01')->isoFormat('Do')); $this->assertSame('11th', Carbon::parse('2018-06-11')->isoFormat('Do')); $this->assertSame('21st', Carbon::parse('2018-06-21')->isoFormat('Do')); $this->assertSame('15th', Carbon::parse('2018-06-15')->isoFormat('Do')); } public function testBadIsoFormat() { $d = BadIsoCarbon::parse('midnight'); $this->assertSame('', $d->isoFormat('MMM')); } public function testTranslatedFormat() { $this->assertSame('1st', Carbon::parse('01-01-01')->translatedFormat('jS')); $this->assertSame('1er', Carbon::parse('01-01-01')->locale('fr')->translatedFormat('jS')); $this->assertSame('31 мая', Carbon::parse('2019-05-15')->locale('ru')->translatedFormat('t F')); $this->assertSame('5 май', Carbon::parse('2019-05-15')->locale('ru')->translatedFormat('n F')); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/GenericMacroTest.php
tests/CarbonImmutable/GenericMacroTest.php
<?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 Tests\CarbonImmutable; use BadMethodCallException; use Carbon\CarbonImmutable as Carbon; use Tests\AbstractTestCaseWithOldNow; use Throwable; class GenericMacroTest extends AbstractTestCaseWithOldNow { public function testGenericMacro() { Carbon::genericMacro(function ($method) { $time = preg_replace('/[A-Z]/', ' $0', $method); try { return self::this()->modify($time); } catch (Throwable $exception) { if (preg_match('(Could not modify with|Failed to parse)', $exception->getMessage())) { throw new BadMethodCallException('Try next macro', 0, $exception); } throw $exception; } }); /** @var mixed $now */ $now = Carbon::now(); $this->assertSame('2017-07-02', $now->nextSunday()->format('Y-m-d')); $this->assertSame('2017-06-26', Carbon::lastMonday()->format('Y-m-d')); $message = null; try { Carbon::fooBar(); } catch (BadMethodCallException $exception) { $message = $exception->getMessage(); } $this->assertSame('Method '.Carbon::class.'::fooBar does not exist.', $message); $message = null; try { $now->barBiz(); } catch (BadMethodCallException $exception) { $message = $exception->getMessage(); } $this->assertSame('Method barBiz does not exist.', $message); } public function testGenericMacroPriority() { Carbon::genericMacro(function ($method) { if (!str_starts_with($method, 'myPrefix')) { throw new BadMethodCallException('Try next macro', 0); } return 'first'; }); Carbon::genericMacro(function ($method) { if (!str_starts_with($method, 'myPrefix')) { throw new BadMethodCallException('Try next macro', 0); } return 'second'; }, 1); Carbon::genericMacro(function ($method) { if (!str_starts_with($method, 'myPrefix')) { throw new BadMethodCallException('Try next macro', 0); } return 'third'; }, -1); Carbon::macro('myPrefixFooBar', function () { return 'myPrefixFooBar'; }); /** @var mixed $now */ $now = Carbon::now(); $this->assertSame('second', $now->myPrefixSomething()); $this->assertSame('second', Carbon::myPrefixSomething()); $this->assertSame('myPrefixFooBar', $now->myPrefixFooBar()); $this->assertSame('myPrefixFooBar', Carbon::myPrefixFooBar()); } public function testLocalGenericMacroPriority() { Carbon::genericMacro(function ($method) { if (!str_starts_with($method, 'mlp')) { throw new BadMethodCallException('Try next macro', 0); } return 'first'; }); Carbon::genericMacro(function ($method) { if (!str_starts_with($method, 'mlp')) { throw new BadMethodCallException('Try next macro', 0); } return 'second'; }, 1); Carbon::genericMacro(function ($method) { if (!str_starts_with($method, 'mlp')) { throw new BadMethodCallException('Try next macro', 0); } return 'third'; }, -1); Carbon::macro('mlpFooBar', function () { return 'mlpFooBar'; }); /** @var mixed $date */ $date = Carbon::now()->settings([ 'genericMacros' => [ function ($method) { if (!str_starts_with($method, 'mlp')) { throw new BadMethodCallException('Try next macro', 0); } return 'local-first'; }, function ($method) { if (!str_starts_with($method, 'mlp')) { throw new BadMethodCallException('Try next macro', 0); } return 'local-second'; }, ], ]); /** @var mixed $now */ $now = Carbon::now(); $this->assertSame('local-first', $date->mlpSomething()); $this->assertSame('second', $now->mlpSomething()); $this->assertSame('second', Carbon::mlpSomething()); $this->assertSame('mlpFooBar', $date->mlpFooBar()); $this->assertSame('mlpFooBar', $now->mlpFooBar()); $this->assertSame('mlpFooBar', Carbon::mlpFooBar()); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/NowDerivativesTest.php
tests/CarbonImmutable/NowDerivativesTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Tests\AbstractTestCase; class NowDerivativesTest extends AbstractTestCase { public function testNowWithSameTimezone() { $dt = Carbon::now('Europe/London'); $dt2 = $dt->nowWithSameTz(); $this->assertSame($dt2->toDateTimeString(), $dt->toDateTimeString()); $this->assertSame($dt2->tzName, $dt->tzName); Carbon::setTestNow(new Carbon('2017-07-29T07:57:27.123456Z')); $dt = Carbon::createFromTime(13, 40, 00, 'Africa/Asmara'); $dt2 = $dt->nowWithSameTz(); Carbon::setTestNow(); $this->assertSame($dt->format('H:i'), '13:40'); $this->assertSame($dt2->format('H:i'), '10:57'); $this->assertSame($dt2->tzName, $dt->tzName); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/ExpressiveComparisonTest.php
tests/CarbonImmutable/ExpressiveComparisonTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Tests\AbstractTestCase; class ExpressiveComparisonTest extends AbstractTestCase { public function testEqualToTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->equalTo(Carbon::createFromDate(2000, 1, 1))); } public function testEqualToFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->equalTo(Carbon::createFromDate(2000, 1, 2))); } public function testEqualWithTimezoneTrue() { $this->assertTrue(Carbon::create(2000, 1, 1, 12, 0, 0, 'America/Toronto')->equalTo(Carbon::create(2000, 1, 1, 9, 0, 0, 'America/Vancouver'))); } public function testNotEqualToTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->notEqualTo(Carbon::createFromDate(2000, 1, 2))); } public function testNotEqualToFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->notEqualTo(Carbon::createFromDate(2000, 1, 1))); } public function testGreaterThanTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->greaterThan(Carbon::createFromDate(1999, 12, 31))); } public function testGreaterThanFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->greaterThan(Carbon::createFromDate(2000, 1, 2))); } public function testGreaterThanWithTimezoneTrue() { $dt1 = Carbon::create(2000, 1, 1, 12, 0, 0, 'America/Toronto'); $dt2 = Carbon::create(2000, 1, 1, 8, 59, 59, 'America/Vancouver'); $this->assertTrue($dt1->greaterThan($dt2)); } public function testGreaterThanWithTimezoneFalse() { $dt1 = Carbon::create(2000, 1, 1, 12, 0, 0, 'America/Toronto'); $dt2 = Carbon::create(2000, 1, 1, 9, 0, 1, 'America/Vancouver'); $this->assertFalse($dt1->greaterThan($dt2)); } public function testGreaterThanOrEqualTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->greaterThanOrEqualTo(Carbon::createFromDate(1999, 12, 31))); } public function testGreaterThanOrEqualTrueEqual() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->greaterThanOrEqualTo(Carbon::createFromDate(2000, 1, 1))); } public function testGreaterThanOrEqualFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->greaterThanOrEqualTo(Carbon::createFromDate(2000, 1, 2))); } public function testLessThanTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lessThan(Carbon::createFromDate(2000, 1, 2))); } public function testLessThanFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->lessThan(Carbon::createFromDate(1999, 12, 31))); } public function testLessThanOrEqualTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lessThanOrEqualTo(Carbon::createFromDate(2000, 1, 2))); } public function testLessThanOrEqualTrueEqual() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lessThanOrEqualTo(Carbon::createFromDate(2000, 1, 1))); } public function testLessThanOrEqualFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->lessThanOrEqualTo(Carbon::createFromDate(1999, 12, 31))); } public function testBetweenEqualTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), true)); } public function testBetweenNotEqualTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), false)); } public function testBetweenEqualFalse() { $this->assertFalse(Carbon::createFromDate(1999, 12, 31)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), true)); } public function testBetweenNotEqualFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), false)); } public function testBetweenEqualSwitchTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), true)); } public function testBetweenNotEqualSwitchTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), false)); } public function testBetweenEqualSwitchFalse() { $this->assertFalse(Carbon::createFromDate(1999, 12, 31)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), true)); } public function testBetweenNotEqualSwitchFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), false)); } public function testMinIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->minimum()); } public function testMinWithNow() { $dt = Carbon::create(2012, 1, 1, 0, 0, 0)->minimum(); $this->assertCarbon($dt, 2012, 1, 1, 0, 0, 0); } public function testMinWithInstance() { $dt1 = Carbon::create(2013, 12, 31, 23, 59, 59); $dt2 = Carbon::create(2012, 1, 1, 0, 0, 0)->minimum($dt1); $this->assertCarbon($dt2, 2012, 1, 1, 0, 0, 0); } public function testMaxIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->maximum()); } public function testMaxWithNow() { $dt = Carbon::create(2099, 12, 31, 23, 59, 59)->maximum(); $this->assertCarbon($dt, 2099, 12, 31, 23, 59, 59); } public function testMaxWithInstance() { $dt1 = Carbon::create(2012, 1, 1, 0, 0, 0); $dt2 = Carbon::create(2099, 12, 31, 23, 59, 59)->maximum($dt1); $this->assertCarbon($dt2, 2099, 12, 31, 23, 59, 59); } public function testIsBirthday() { $dt1 = Carbon::createFromDate(1987, 4, 23); $dt2 = Carbon::createFromDate(2014, 9, 26); $dt3 = Carbon::createFromDate(2014, 4, 23); $this->assertFalse($dt2->isBirthday($dt1)); $this->assertTrue($dt3->isBirthday($dt1)); } public function testIsLastOfMonth() { $dt1 = Carbon::createFromDate(2017, 1, 31); $dt2 = Carbon::createFromDate(2016, 2, 28); $dt3 = Carbon::createFromDate(2016, 2, 29); $dt4 = Carbon::createFromDate(2018, 5, 5); $this->assertTrue($dt1->isLastOfMonth()); $this->assertFalse($dt2->isLastOfMonth()); $this->assertTrue($dt3->isLastOfMonth()); $this->assertFalse($dt4->isLastOfMonth()); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/ObjectsTest.php
tests/CarbonImmutable/ObjectsTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use DateTime; use DateTimeImmutable; use stdClass; use Tests\AbstractTestCase; class ObjectsTest extends AbstractTestCase { public function testToObject() { $dt = Carbon::now(); $dtToObject = $dt->toObject(); $this->assertInstanceOf(stdClass::class, $dtToObject); $this->assertObjectHasProperty('year', $dtToObject); $this->assertSame($dt->year, $dtToObject->year); $this->assertObjectHasProperty('month', $dtToObject); $this->assertSame($dt->month, $dtToObject->month); $this->assertObjectHasProperty('day', $dtToObject); $this->assertSame($dt->day, $dtToObject->day); $this->assertObjectHasProperty('dayOfWeek', $dtToObject); $this->assertSame($dt->dayOfWeek, $dtToObject->dayOfWeek); $this->assertObjectHasProperty('dayOfYear', $dtToObject); $this->assertSame($dt->dayOfYear, $dtToObject->dayOfYear); $this->assertObjectHasProperty('hour', $dtToObject); $this->assertSame($dt->hour, $dtToObject->hour); $this->assertObjectHasProperty('minute', $dtToObject); $this->assertSame($dt->minute, $dtToObject->minute); $this->assertObjectHasProperty('second', $dtToObject); $this->assertSame($dt->second, $dtToObject->second); $this->assertObjectHasProperty('micro', $dtToObject); $this->assertSame($dt->micro, $dtToObject->micro); $this->assertObjectHasProperty('timestamp', $dtToObject); $this->assertSame($dt->timestamp, $dtToObject->timestamp); $this->assertObjectHasProperty('timezone', $dtToObject); $this->assertEquals($dt->timezone, $dtToObject->timezone); $this->assertObjectHasProperty('formatted', $dtToObject); $this->assertSame($dt->format(Carbon::DEFAULT_TO_STRING_FORMAT), $dtToObject->formatted); } public function testToDateTime() { $dt = Carbon::create(2000, 3, 26); $date = $dt->toDateTime(); $this->assertInstanceOf(DateTime::class, $date); $this->assertSame('2000-03-26', $date->format('Y-m-d')); $date = $dt->toDate(); $this->assertInstanceOf(DateTime::class, $date); $this->assertSame('2000-03-26', $date->format('Y-m-d')); } public function testToDateTimeImmutable() { $dt = Carbon::create(2000, 3, 26); $date = $dt->toDateTimeImmutable(); $this->assertInstanceOf(DateTimeImmutable::class, $date); $this->assertSame('2000-03-26', $date->format('Y-m-d')); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/SubTest.php
tests/CarbonImmutable/SubTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\CarbonInterval; use Carbon\Unit; use DateTimeImmutable; use Tests\AbstractTestCase; class SubTest extends AbstractTestCase { public function testSubMethod() { $this->assertSame(1973, Carbon::createFromDate(1975)->sub(2, 'year')->year); $this->assertSame(1973, Carbon::createFromDate(1975)->sub('year', 2)->year); $this->assertSame(1973, Carbon::createFromDate(1975)->sub(2, Unit::Year)->year); $this->assertSame(1973, Carbon::createFromDate(1975)->sub(Unit::Year, 2)->year); $this->assertSame(1973, Carbon::createFromDate(1975)->sub('2 years')->year); $lastNegated = null; $date = Carbon::createFromDate(1975)->sub( function (DateTimeImmutable $date, bool $negated = false) use (&$lastNegated): DateTimeImmutable { $lastNegated = $negated; return new DateTimeImmutable($date->format('Y-m-d H:i:s').' - 2 years'); }, ); $this->assertInstanceOf(Carbon::class, $date); $this->assertSame(1973, $date->year); $this->assertTrue($lastNegated); $this->assertSame(1973, Carbon::createFromDate(1975)->subtract(2, 'year')->year); $this->assertSame(1973, Carbon::createFromDate(1975)->subtract('year', 2)->year); $this->assertSame(1973, Carbon::createFromDate(1975)->subtract(2, Unit::Year)->year); $this->assertSame(1973, Carbon::createFromDate(1975)->subtract(Unit::Year, 2)->year); $this->assertSame(1973, Carbon::createFromDate(1975)->subtract('2 years')->year); $lastNegated = null; $this->assertSame(1973, Carbon::createFromDate(1975)->subtract( function (DateTimeImmutable $date, bool $negated = false) use (&$lastNegated): DateTimeImmutable { $lastNegated = $negated; return new DateTimeImmutable($date->format('Y-m-d H:i:s').' - 2 years'); }, )->year); $this->assertTrue($lastNegated); /** @var CarbonInterval $interval */ $interval = include __DIR__.'/../Fixtures/dynamicInterval.php'; $originalDate = Carbon::parse('2020-06-08'); $date = $originalDate->sub($interval); $this->assertInstanceOf(Carbon::class, $date); $this->assertSame('2020-05-31', $date->format('Y-m-d')); $this->assertNotSame($originalDate, $date); $date = Carbon::parse('2020-07-16')->subtract($interval); $this->assertInstanceOf(Carbon::class, $date); $this->assertSame('2020-06-30', $date->format('Y-m-d')); } public function testSubYearsPositive() { $this->assertSame(1974, Carbon::createFromDate(1975)->subYears(1)->year); } public function testSubYearsZero() { $this->assertSame(1975, Carbon::createFromDate(1975)->subYears(0)->year); } public function testSubYearsNegative() { $this->assertSame(1976, Carbon::createFromDate(1975)->subYears(-1)->year); } public function testSubYear() { $this->assertSame(1974, Carbon::createFromDate(1975)->subYear()->year); $this->assertSame(1973, Carbon::createFromDate(1975)->sub(2, 'year')->year); $this->assertSame(1973, Carbon::createFromDate(1975)->sub(2, 'years')->year); $this->assertSame(1973, Carbon::createFromDate(1975)->sub(CarbonInterval::years(2))->year); } public function testSubMonthsPositive() { $this->assertSame(12, Carbon::createFromDate(1975, 1, 1)->subMonths(1)->month); } public function testSubMonthsZero() { $this->assertSame(1, Carbon::createFromDate(1975, 1, 1)->subMonths(0)->month); } public function testSubMonthsNegative() { $this->assertSame(2, Carbon::createFromDate(1975, 1, 1)->subMonths(-1)->month); } public function testSubMonth() { $this->assertSame(12, Carbon::createFromDate(1975, 1, 1)->subMonth()->month); } public function testSubDaysPositive() { $this->assertSame(30, Carbon::createFromDate(1975, 5, 1)->subDays(1)->day); } public function testSubDaysZero() { $this->assertSame(1, Carbon::createFromDate(1975, 5, 1)->subDays(0)->day); } public function testSubDaysNegative() { $this->assertSame(2, Carbon::createFromDate(1975, 5, 1)->subDays(-1)->day); } public function testSubDay() { $this->assertSame(30, Carbon::createFromDate(1975, 5, 1)->subDay()->day); } public function testSubWeekdaysPositive() { $this->assertSame(22, Carbon::createFromDate(2012, 1, 4)->subWeekdays(9)->day); } public function testSubWeekdaysZero() { $this->assertSame(4, Carbon::createFromDate(2012, 1, 4)->subWeekdays(0)->day); } public function testSubWeekdaysNegative() { $this->assertSame(13, Carbon::createFromDate(2012, 1, 31)->subWeekdays(-9)->day); } public function testSubWeekday() { $this->assertSame(6, Carbon::createFromDate(2012, 1, 9)->subWeekday()->day); } public function testSubWeekdayDuringWeekend() { $this->assertSame(6, Carbon::createFromDate(2012, 1, 8)->subWeekday()->day); } public function testSubWeeksPositive() { $this->assertSame(14, Carbon::createFromDate(1975, 5, 21)->subWeeks(1)->day); } public function testSubWeeksZero() { $this->assertSame(21, Carbon::createFromDate(1975, 5, 21)->subWeeks(0)->day); } public function testSubWeeksNegative() { $this->assertSame(28, Carbon::createFromDate(1975, 5, 21)->subWeeks(-1)->day); } public function testSubWeek() { $this->assertSame(14, Carbon::createFromDate(1975, 5, 21)->subWeek()->day); } public function testSubHoursPositive() { $this->assertSame(23, Carbon::createFromTime(0)->subHours(1)->hour); } public function testSubHoursZero() { $this->assertSame(0, Carbon::createFromTime(0)->subHours(0)->hour); } public function testSubHoursNegative() { $this->assertSame(1, Carbon::createFromTime(0)->subHours(-1)->hour); } public function testSubHour() { $this->assertSame(23, Carbon::createFromTime(0)->subHour()->hour); } public function testSubMinutesPositive() { $this->assertSame(59, Carbon::createFromTime(0, 0)->subMinutes(1)->minute); } public function testSubMinutesZero() { $this->assertSame(0, Carbon::createFromTime(0, 0)->subMinutes(0)->minute); } public function testSubMinutesNegative() { $this->assertSame(1, Carbon::createFromTime(0, 0)->subMinutes(-1)->minute); } public function testSubMinute() { $this->assertSame(59, Carbon::createFromTime(0, 0)->subMinute()->minute); } public function testSubSecondsPositive() { $this->assertSame(59, Carbon::createFromTime(0, 0, 0)->subSeconds(1)->second); } public function testSubSecondsZero() { $this->assertSame(0, Carbon::createFromTime(0, 0, 0)->subSeconds(0)->second); } public function testSubSecondsNegative() { $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->subSeconds(-1)->second); } public function testSubSecond() { $this->assertSame(59, Carbon::createFromTime(0, 0, 0)->subSecond()->second); } public function testSubMillisecondsPositive() { $this->assertSame(999, Carbon::createFromTime(0, 0, 0)->subMilliseconds(1)->millisecond); } public function testSubMillisecondsZero() { $this->assertSame(100, Carbon::createFromTime(0, 0, 0.1)->subMilliseconds(0)->millisecond); } public function testSubMillisecondsNegative() { $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->subMilliseconds(-1)->millisecond); $this->assertSame(101, Carbon::createFromTime(0, 0, 0.1)->subMilliseconds(-1)->millisecond); } public function testSubMillisecond() { $this->assertSame(99, Carbon::createFromTime(0, 0, 0.1)->subMillisecond()->millisecond); } public function testSubMicrosecondsPositive() { $this->assertSame(999999, Carbon::createFromTime(0, 0, 0)->subMicroseconds(1)->microsecond); } public function testSubMicrosecondsZero() { $this->assertSame(100000, Carbon::createFromTime(0, 0, 0.1)->subMicroseconds(0)->microsecond); } public function testSubMicrosecondsNegative() { $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->subMicroseconds(-1)->microsecond); $this->assertSame(100001, Carbon::createFromTime(0, 0, 0.1)->subMicroseconds(-1)->microsecond); } public function testSubMicrosecond() { $this->assertSame(99999, Carbon::createFromTime(0, 0, 0.1)->subMicrosecond()->microsecond); } /** * Test non plural methods with non default args. */ public function testSubYearPassingArg() { /** @var mixed $date */ $date = Carbon::createFromDate(1975); $this->assertSame(1973, $date->subYear(2)->year); } public function testSubMonthPassingArg() { /** @var mixed $date */ $date = Carbon::createFromDate(1975, 5, 1); $this->assertSame(3, $date->subMonth(2)->month); } public function testSubMonthNoOverflowPassingArg() { /** @var mixed $date */ $date = Carbon::createFromDate(2011, 4, 30); $date = $date->subMonthNoOverflow(2); $this->assertSame(2, $date->month); $this->assertSame(28, $date->day); } public function testSubDayPassingArg() { /** @var mixed $date */ $date = Carbon::createFromDate(1975, 5, 10); $this->assertSame(8, $date->subDay(2)->day); } public function testSubHourPassingArg() { /** @var mixed $date */ $date = Carbon::createFromTime(0); $this->assertSame(22, $date->subHour(2)->hour); } public function testSubMinutePassingArg() { /** @var mixed $date */ $date = Carbon::createFromTime(0); $this->assertSame(58, $date->subMinute(2)->minute); } public function testSubSecondPassingArg() { /** @var mixed $date */ $date = Carbon::createFromTime(0); $this->assertSame(58, $date->subSecond(2)->second); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/CreateSafeTest.php
tests/CarbonImmutable/CreateSafeTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\Exceptions\InvalidDateException; use Tests\AbstractTestCase; class CreateSafeTest extends AbstractTestCase { public function testInvalidDateExceptionProperties() { $e = new InvalidDateException('day', 'foo'); $this->assertSame('day', $e->getField()); $this->assertSame('foo', $e->getValue()); } public function testCreateSafeThrowsExceptionForSecondLowerThanZero() { $this->expectExceptionObject(new InvalidDateException('second', -1)); Carbon::createSafe(null, null, null, null, null, -1); } public function testCreateSafeThrowsExceptionForSecondGreaterThan59() { $this->expectExceptionObject(new InvalidDateException('second', 60)); Carbon::createSafe(null, null, null, null, null, 60); } public function testCreateSafeThrowsExceptionForMinuteLowerThanZero() { $this->expectExceptionObject(new InvalidDateException('minute', -1)); Carbon::createSafe(null, null, null, null, -1); } public function testCreateSafeThrowsExceptionForMinuteGreaterThan59() { $this->expectExceptionObject(new InvalidDateException('minute', 60)); Carbon::createSafe(null, null, null, null, 60, 25); } public function testCreateSafeThrowsExceptionForHourLowerThanZero() { $this->expectExceptionObject(new InvalidDateException('hour', -6)); Carbon::createSafe(null, null, null, -6); } public function testCreateSafeThrowsExceptionForHourGreaterThan24() { $this->expectExceptionObject(new InvalidDateException('hour', 25)); Carbon::createSafe(null, null, null, 25, 16, 15); } public function testCreateSafeThrowsExceptionForDayLowerThanZero() { $this->expectExceptionObject(new InvalidDateException('day', -5)); Carbon::createSafe(null, null, -5); } public function testCreateSafeThrowsExceptionForDayGreaterThan31() { $this->expectExceptionObject(new InvalidDateException('day', 32)); Carbon::createSafe(null, null, 32, 17, 16, 15); } public function testCreateSafeThrowsExceptionForMonthLowerThanZero() { $this->expectExceptionObject(new InvalidDateException('month', -4)); Carbon::createSafe(null, -4); } public function testCreateSafeThrowsExceptionForMonthGreaterThan12() { $this->expectExceptionObject(new InvalidDateException('month', 13)); Carbon::createSafe(null, 13, 5, 17, 16, 15); } public function testCreateSafeThrowsExceptionForYearLowerThanZero() { $this->expectExceptionObject(new InvalidDateException('year', -5)); Carbon::createSafe(-5); } public function testCreateSafeThrowsExceptionForYearGreaterThan12() { $this->expectExceptionObject(new InvalidDateException('year', 10000)); Carbon::createSafe(10000, 12, 5, 17, 16, 15); } public function testCreateSafeThrowsExceptionForInvalidDayInShortMonth() { $this->expectExceptionObject(new InvalidDateException('day', 31)); // 30 days in April Carbon::createSafe(2016, 4, 31, 17, 16, 15); } public function testCreateSafeThrowsExceptionForInvalidDayForFebruaryInLeapYear() { $this->expectExceptionObject(new InvalidDateException('day', 30)); // 29 days in February for a leap year $this->assertTrue(Carbon::create(2016, 2)->isLeapYear()); Carbon::createSafe(2016, 2, 30, 17, 16, 15); } public function testCreateSafePassesForFebruaryInLeapYear() { // 29 days in February for a leap year $this->assertSame(29, Carbon::createSafe(2016, 2, 29, 17, 16, 15)->day); } public function testCreateSafeThrowsExceptionForInvalidDayForFebruaryInNonLeapYear() { $this->expectExceptionObject(new InvalidDateException('day', 29)); // 28 days in February for a non-leap year $this->assertFalse(Carbon::create(2015, 2)->isLeapYear()); Carbon::createSafe(2015, 2, 29, 17, 16, 15); } public function testCreateSafePassesForInvalidDSTTime() { $message = ''; $date = null; try { // 1h jumped to 2h because of the DST, so 1h30 is not a safe date in PHP 5.4+ Carbon::createSafe(2014, 3, 30, 1, 30, 0, 'Europe/London'); } catch (InvalidDateException $exception) { $message = $exception->getMessage(); } $this->assertStringContainsString('hour : 1 is not a valid value.', $message); } public function testCreateSafePassesForValidDSTTime() { $this->assertSame(0, Carbon::createSafe(2014, 3, 30, 0, 30, 0, 'Europe/London')->hour); $this->assertSame(2, Carbon::createSafe(2014, 3, 30, 2, 30, 0, 'Europe/London')->hour); $this->assertSame(1, Carbon::createSafe(2014, 3, 30, 1, 30, 0, 'UTC')->hour); } public function testCreateSafeThrowsExceptionForWithNonIntegerValue() { $this->expectExceptionObject(new InvalidDateException('second', 15.1)); Carbon::createSafe(2015, 2, 10, 17, 16, 15.1); } public function testCreateSafePassesForFebruaryInNonLeapYear() { // 28 days in February for a non-leap year $this->assertSame(28, Carbon::createSafe(2015, 2, 28, 17, 16, 15)->day); } public function testCreateSafePasses() { $sd = Carbon::createSafe(2015, 2, 15, 17, 16, 15); $d = Carbon::create(2015, 2, 15, 17, 16, 15); $this->assertEquals($d, $sd); $this->assertCarbon($sd, 2015, 2, 15, 17, 16, 15); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/GettersTest.php
tests/CarbonImmutable/GettersTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use InvalidArgumentException; use PHPUnit\Framework\Attributes\DataProvider; use Tests\AbstractTestCase; class GettersTest extends AbstractTestCase { public function testGettersThrowExceptionOnUnknownGetter() { $this->expectExceptionObject(new InvalidArgumentException( "Unknown getter 'doesNotExit'", )); /** @var mixed $d */ $d = Carbon::create(1234, 5, 6, 7, 8, 9); $d->doesNotExit; } public function testGettersThrowExceptionOnUnknownOfGetter() { $this->expectExceptionObject(new InvalidArgumentException( "Unknown getter 'fooOfBar'", )); /** @var mixed $d */ $d = Carbon::create(1234, 5, 6, 7, 8, 9); $d->fooOfBar; } public function testYearGetter() { $d = Carbon::create(1234, 5, 6, 7, 8, 9); $this->assertSame(1234, $d->year); } public function testYearIsoGetter() { $d = Carbon::createFromDate(2012, 12, 31); $this->assertSame(2013, $d->yearIso); } public function testMonthGetter() { $d = Carbon::create(1234, 5, 6, 7, 8, 9); $this->assertSame(5, $d->month); } public function testDayGetter() { $d = Carbon::create(1234, 5, 6, 7, 8, 9); $this->assertSame(6, $d->day); } public function testHourGetter() { $d = Carbon::create(1234, 5, 6, 7, 8, 9); $this->assertSame(7, $d->hour); } public function testMinuteGetter() { $d = Carbon::create(1234, 5, 6, 7, 8, 9); $this->assertSame(8, $d->minute); } public function testSecondGetter() { $d = Carbon::create(1234, 5, 6, 7, 8, 9); $this->assertSame(9, $d->second); } public function testMicroGetter() { $micro = 345678; $d = Carbon::parse('2014-01-05 12:34:11.'.$micro); $this->assertSame($micro, $d->micro); } public function testMicroGetterWithDefaultNow() { $now = Carbon::getTestNow(); Carbon::setTestNow(null); $start = microtime(true); usleep(10000); $d = Carbon::now(); usleep(10000); $end = microtime(true); $microTime = $d->getTimestamp() + $d->micro / 1000000; $this->assertGreaterThan($start, $microTime); $this->assertLessThan($end, $microTime); Carbon::setTestNow($now); } public function testDayOfWeekGetter() { $d = Carbon::create(2012, 5, 7, 7, 8, 9); $this->assertSame(Carbon::MONDAY, $d->dayOfWeek); $d = Carbon::create(2012, 5, 8, 7, 8, 9); $this->assertSame(Carbon::TUESDAY, $d->dayOfWeek); $d = Carbon::create(2012, 5, 9, 7, 8, 9); $this->assertSame(Carbon::WEDNESDAY, $d->dayOfWeek); $d = Carbon::create(2012, 5, 10, 0, 0, 0); $this->assertSame(Carbon::THURSDAY, $d->dayOfWeek); $d = Carbon::create(2012, 5, 11, 23, 59, 59); $this->assertSame(Carbon::FRIDAY, $d->dayOfWeek); $d = Carbon::create(2012, 5, 12, 12, 0, 0); $this->assertSame(Carbon::SATURDAY, $d->dayOfWeek); $d = Carbon::create(2012, 5, 13, 12, 0, 0); $this->assertSame(Carbon::SUNDAY, $d->dayOfWeek); } public function testDayOfWeekIsoGetter() { $d = Carbon::create(2012, 5, 7, 7, 8, 9); $this->assertSame(1, $d->dayOfWeekIso); $d = Carbon::create(2012, 5, 8, 7, 8, 9); $this->assertSame(2, $d->dayOfWeekIso); $d = Carbon::create(2012, 5, 9, 7, 8, 9); $this->assertSame(3, $d->dayOfWeekIso); $d = Carbon::create(2012, 5, 10, 0, 0, 0); $this->assertSame(4, $d->dayOfWeekIso); $d = Carbon::create(2012, 5, 11, 23, 59, 59); $this->assertSame(5, $d->dayOfWeekIso); $d = Carbon::create(2012, 5, 12, 12, 0, 0); $this->assertSame(6, $d->dayOfWeekIso); $d = Carbon::create(2012, 5, 13, 12, 0, 0); $this->assertSame(7, $d->dayOfWeekIso); } public function testDayOfYearGetter() { $d = Carbon::createFromDate(2012, 5, 7); $this->assertSame(128, $d->dayOfYear); } public function testDaysInMonthGetter() { $d = Carbon::createFromDate(2012, 5, 7); $this->assertSame(31, $d->daysInMonth); } public function testTimestampGetter() { $d = Carbon::create(); $d = $d->setTimezone('GMT'); $this->assertSame(0, $d->setDateTime(1970, 1, 1, 0, 0, 0)->timestamp); } public function testGetAge() { $d = Carbon::now(); $this->assertSame(0, $d->age); } public function testGetAgeWithRealAge() { $d = Carbon::createFromDate(1975, 5, 21); $age = (int) (substr((string) ((int) (date('Ymd')) - (int) (date('Ymd', $d->timestamp))), 0, -4)); $this->assertSame($age, $d->age); } public static function dataForTestQuarter(): array { return [ [1, 1], [2, 1], [3, 1], [4, 2], [5, 2], [6, 2], [7, 3], [8, 3], [9, 3], [10, 4], [11, 4], [12, 4], ]; } #[DataProvider('dataForTestQuarter')] public function testQuarterFirstOfMonth(int $month, int $quarter) { $c = Carbon::create(2015, $month, 1)->startOfMonth(); $this->assertSame($quarter, $c->quarter); } #[DataProvider('dataForTestQuarter')] public function testQuarterMiddleOfMonth(int $month, int $quarter) { $c = Carbon::create(2015, $month, 15, 12, 13, 14); $this->assertSame($quarter, $c->quarter); } #[DataProvider('dataForTestQuarter')] public function testQuarterLastOfMonth(int $month, int $quarter) { $c = Carbon::create(2015, $month, 1)->endOfMonth(); $this->assertSame($quarter, $c->quarter); } public function testGetLocalTrue() { // Default timezone has been set to America/Toronto in AbstractTestCase.php // @see : https://en.wikipedia.org/wiki/List_of_UTC_time_offsets $this->assertTrue(Carbon::createFromDate(2012, 1, 1, 'America/Toronto')->local); $this->assertTrue(Carbon::createFromDate(2012, 1, 1, 'America/New_York')->local); } public function testGetLocalFalse() { $this->assertFalse(Carbon::createFromDate(2012, 7, 1, 'UTC')->local); $this->assertFalse(Carbon::createFromDate(2012, 7, 1, 'Europe/London')->local); } public function testGetUtcFalse() { $this->assertFalse(Carbon::createFromDate(2013, 1, 1, 'America/Toronto')->utc); $this->assertFalse(Carbon::createFromDate(2013, 1, 1, 'Europe/Paris')->utc); } public function testGetUtcTrue() { $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Atlantic/Reykjavik')->utc); $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Europe/Lisbon')->utc); $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Africa/Casablanca')->utc); $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Africa/Dakar')->utc); $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Europe/Dublin')->utc); $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Europe/London')->utc); $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'UTC')->utc); $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'GMT')->utc); } public function testGetDstFalse() { $this->assertFalse(Carbon::createFromDate(2012, 1, 1, 'America/Toronto')->dst); $this->assertFalse(Carbon::createFromDate(2012, 1, 1, 'America/Toronto')->isDST()); } public function testGetDstTrue() { $this->assertTrue(Carbon::createFromDate(2012, 7, 1, 'America/Toronto')->dst); $this->assertTrue(Carbon::createFromDate(2012, 7, 1, 'America/Toronto')->isDST()); } public function testGetMidDayAt() { $d = Carbon::now(); $this->assertSame(12, $d->getMidDayAt()); } public function testOffsetForTorontoWithDST() { $this->assertSame(-18000, Carbon::createFromDate(2012, 1, 1, 'America/Toronto')->offset); } public function testOffsetForTorontoNoDST() { $this->assertSame(-14400, Carbon::createFromDate(2012, 6, 1, 'America/Toronto')->offset); } public function testOffsetForGMT() { $this->assertSame(0, Carbon::createFromDate(2012, 6, 1, 'GMT')->offset); } public function testOffsetHoursForTorontoWithDST() { $this->assertSame(-5, Carbon::createFromDate(2012, 1, 1, 'America/Toronto')->offsetHours); } public function testOffsetHoursForTorontoNoDST() { $this->assertSame(-4, Carbon::createFromDate(2012, 6, 1, 'America/Toronto')->offsetHours); } public function testOffsetHoursForGMT() { $this->assertSame(0, Carbon::createFromDate(2012, 6, 1, 'GMT')->offsetHours); } public function testIsLeapYearTrue() { $this->assertTrue(Carbon::createFromDate(2012, 1, 1)->isLeapYear()); } public function testIsLeapYearFalse() { $this->assertFalse(Carbon::createFromDate(2011, 1, 1)->isLeapYear()); } public function testIsLongYearTrue() { $this->assertTrue(Carbon::createFromDate(2015, 1, 1)->isLongYear()); } public function testIsLongYearFalse() { $this->assertFalse(Carbon::createFromDate(2016, 1, 1)->isLongYear()); } public function testWeekOfMonth() { $this->assertSame(5, Carbon::createFromDate(2012, 9, 30)->weekOfMonth); $this->assertSame(4, Carbon::createFromDate(2012, 9, 28)->weekOfMonth); $this->assertSame(3, Carbon::createFromDate(2012, 9, 20)->weekOfMonth); $this->assertSame(2, Carbon::createFromDate(2012, 9, 8)->weekOfMonth); $this->assertSame(1, Carbon::createFromDate(2012, 9, 1)->weekOfMonth); } public function testWeekNumberInMonthIsNotFromTheBeginning() { $this->assertSame(5, Carbon::createFromDate(2017, 2, 28)->weekNumberInMonth); $this->assertSame(5, Carbon::createFromDate(2017, 2, 27)->weekNumberInMonth); $this->assertSame(4, Carbon::createFromDate(2017, 2, 26)->weekNumberInMonth); $this->assertSame(4, Carbon::createFromDate(2017, 2, 20)->weekNumberInMonth); $this->assertSame(3, Carbon::createFromDate(2017, 2, 19)->weekNumberInMonth); $this->assertSame(3, Carbon::createFromDate(2017, 2, 13)->weekNumberInMonth); $this->assertSame(2, Carbon::createFromDate(2017, 2, 12)->weekNumberInMonth); $this->assertSame(2, Carbon::createFromDate(2017, 2, 6)->weekNumberInMonth); $this->assertSame(1, Carbon::createFromDate(2017, 2, 1)->weekNumberInMonth); } public function testWeekOfYearFirstWeek() { $this->assertSame(52, Carbon::createFromDate(2012, 1, 1)->weekOfYear); $this->assertSame(1, Carbon::createFromDate(2012, 1, 2)->weekOfYear); } public function testWeekOfYearLastWeek() { $this->assertSame(52, Carbon::createFromDate(2012, 12, 30)->weekOfYear); $this->assertSame(1, Carbon::createFromDate(2012, 12, 31)->weekOfYear); } public function testGetTimezone() { $dt = Carbon::createFromDate(2000, 1, 1, 'America/Toronto'); $this->assertSame('America/Toronto', $dt->timezone->getName()); $dt = Carbon::createFromDate(2000, 1, 1, -5); $this->assertSame('America/Chicago', $dt->timezone->getName()); $dt = Carbon::createFromDate(2000, 1, 1, '-5'); $this->assertSame('-05:00', $dt->timezone->getName()); } public function testGetTz() { $dt = Carbon::createFromDate(2000, 1, 1, 'America/Toronto'); $this->assertSame('America/Toronto', $dt->tz->getName()); $dt = Carbon::createFromDate(2000, 1, 1, -5); $this->assertSame('America/Chicago', $dt->tz->getName()); $dt = Carbon::createFromDate(2000, 1, 1, '-5'); $this->assertSame('-05:00', $dt->tz->getName()); } public function testGetTimezoneName() { $dt = Carbon::createFromDate(2000, 1, 1, 'America/Toronto'); $this->assertSame('America/Toronto', $dt->timezoneName); $dt = Carbon::createFromDate(2000, 1, 1, -5); $this->assertSame('America/Chicago', $dt->timezoneName); $dt = Carbon::createFromDate(2000, 1, 1, '-5'); $this->assertSame('-05:00', $dt->timezoneName); } public function testGetTzName() { $dt = Carbon::createFromDate(2000, 1, 1, 'America/Toronto'); $this->assertSame('America/Toronto', $dt->tzName); $dt = Carbon::createFromDate(2000, 1, 1, -5); $this->assertSame('America/Chicago', $dt->timezoneName); $dt = Carbon::createFromDate(2000, 1, 1, '-5'); $this->assertSame('-05:00', $dt->timezoneName); } public function testShortDayName() { $dt = Carbon::createFromDate(2018, 8, 6); $this->assertSame('Mon', $dt->shortDayName); $this->assertSame('lun.', $dt->locale('fr')->shortDayName); } public function testMinDayName() { $dt = Carbon::createFromDate(2018, 8, 6); $this->assertSame('Mo', $dt->minDayName); $this->assertSame('lu', $dt->locale('fr')->minDayName); } public function testShortMonthName() { $dt = Carbon::createFromDate(2018, 7, 6); $this->assertSame('Jul', $dt->shortMonthName); $this->assertSame('juil.', $dt->locale('fr')->shortMonthName); } public function testGetDays() { $days = [ Carbon::SUNDAY => 'Sunday', Carbon::MONDAY => 'Monday', Carbon::TUESDAY => 'Tuesday', Carbon::WEDNESDAY => 'Wednesday', Carbon::THURSDAY => 'Thursday', Carbon::FRIDAY => 'Friday', Carbon::SATURDAY => 'Saturday', ]; $this->assertSame($days, Carbon::getDays()); } public function testUnitOfUnit() { $date = Carbon::createFromDate(2018, 7, 6); $this->assertSame(6, $date->dayOfQuarter); $date = Carbon::createFromDate(2018, 8, 6); $this->assertSame(6 + 31, $date->dayOfQuarter); $date = Carbon::create(2018, 4, 6, 4, 50, 0, 'UTC'); $this->assertSame((95 * 24 + 4) * 60 + 50, $date->minuteOfYear); $date = Carbon::create(2018, 4, 6, 4, 50, 0, 'America/Toronto'); $this->assertSame((95 * 24 + 3) * 60 + 50, $date->minuteOfYear); $date = Carbon::create(2018, 4, 6, 4, 50, 0, 'America/Toronto'); $this->assertSame(0, $date->yearOfMinute); $date = Carbon::create(2018, 4, 6, 4, 50, 0, 'America/Toronto'); $this->assertSame(1, $date->dayOfMinute); } public function testUnitOfUnitMethod() { $date = Carbon::createFromDate(2018, 7, 6); $this->assertSame(6, $date->dayOfQuarter()); $date = Carbon::createFromDate(2018, 8, 6); $this->assertSame(6 + 31, $date->dayOfQuarter()); $date = Carbon::create(2018, 4, 6, 4, 50, 0, 'UTC'); $this->assertSame((95 * 24 + 4) * 60 + 50, $date->minuteOfYear()); $date = Carbon::create(2018, 4, 6, 4, 50, 0, 'America/Toronto'); $this->assertSame((95 * 24 + 3) * 60 + 50, $date->minuteOfYear()); $date = Carbon::create(2018, 4, 6, 4, 50, 0, 'America/Toronto'); $this->assertSame(0, $date->yearOfMinute()); $date = Carbon::create(2018, 4, 6, 4, 50, 0, 'America/Toronto'); $this->assertSame(1, $date->dayOfMinute()); } public function testUnitInUnit() { $date = Carbon::createFromDate(2018, 7, 6); $this->assertSame(7, $date->daysInWeek); $date = Carbon::createFromDate(2018, 8, 6); $this->assertSame(92, $date->daysInQuarter); $date = Carbon::create(2018, 4, 6, 4, 50, 0, 'UTC'); $this->assertSame(365 * 24 * 60, $date->minutesInYear); $date = Carbon::create(2018, 4, 6, 4, 50, 0, 'America/Toronto'); $this->assertSame(365 * 24 * 60, $date->minutesInYears); $date = Carbon::create(2024, 4, 6, 4, 50, 0, 'America/Toronto'); $this->assertSame(366 * 24 * 60, $date->minuteInYear); $date = Carbon::create(2024, 4, 6, 4, 50, 0, 'America/Toronto'); $this->assertSame(0, $date->yearsInMinute); $date = Carbon::create(2024, 4, 6, 4, 50, 0, 'America/Toronto'); $this->assertSame(0, $date->daysInMinute); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/CreateFromTimestampTest.php
tests/CarbonImmutable/CreateFromTimestampTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use DateTimeZone; use Tests\AbstractTestCase; class CreateFromTimestampTest extends AbstractTestCase { public function testCreateReturnsDatingInstance() { $d = Carbon::createFromTimestamp(Carbon::create(1975, 5, 21, 22, 32, 5, 'UTC')->timestamp); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5); } public function testCreateFromTimestampMs() { $baseTimestamp = Carbon::create(1975, 5, 21, 22, 32, 5, 'UTC')->timestamp * 1000; $timestamp = $baseTimestamp + 321; $d = Carbon::createFromTimestampMs($timestamp); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5, 321000); $timestamp = $baseTimestamp + 321.8; $d = Carbon::createFromTimestampMs($timestamp); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5, 321800); $timestamp = $baseTimestamp + 321.84; $d = Carbon::createFromTimestampMs($timestamp); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5, 321840); $timestamp = $baseTimestamp + 321.847; $d = Carbon::createFromTimestampMs($timestamp); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5, 321847); $timestamp = $baseTimestamp + 321.8474; $d = Carbon::createFromTimestampMs($timestamp); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5, 321847); $timestamp = $baseTimestamp + 321.8479; $d = Carbon::createFromTimestampMs($timestamp); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5, 321848); } public function testCreateFromTimestampMsUTC() { // Toronto is GMT-04:00 in May $baseTimestamp = Carbon::create(1975, 5, 21, 22, 32, 5)->timestamp * 1000; $timestamp = $baseTimestamp + 321; $d = Carbon::createFromTimestampMsUTC($timestamp); $this->assertCarbon($d, 1975, 5, 22, 2, 32, 5, 321000); $timestamp = $baseTimestamp + 321.8; $d = Carbon::createFromTimestampMsUTC($timestamp); $this->assertCarbon($d, 1975, 5, 22, 2, 32, 5, 321800); $timestamp = $baseTimestamp + 321.84; $d = Carbon::createFromTimestampMsUTC($timestamp); $this->assertCarbon($d, 1975, 5, 22, 2, 32, 5, 321840); $timestamp = $baseTimestamp + 321.847; $d = Carbon::createFromTimestampMsUTC($timestamp); $this->assertCarbon($d, 1975, 5, 22, 2, 32, 5, 321847); $timestamp = $baseTimestamp + 321.8474; $d = Carbon::createFromTimestampMsUTC($timestamp); $this->assertCarbon($d, 1975, 5, 22, 2, 32, 5, 321847); $timestamp = $baseTimestamp + 321.8479; $d = Carbon::createFromTimestampMsUTC($timestamp); $this->assertCarbon($d, 1975, 5, 22, 2, 32, 5, 321848); $d = Carbon::createFromTimestampMsUTC(1); $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0, 1000); $d = Carbon::createFromTimestampMsUTC(60); $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0, 60000); $d = Carbon::createFromTimestampMsUTC(1000); $this->assertCarbon($d, 1970, 1, 1, 0, 0, 1, 0); $d = Carbon::createFromTimestampMsUTC(-0.04); $this->assertCarbon($d, 1969, 12, 31, 23, 59, 59, 999960); } public function testComaDecimalSeparatorLocale() { $date = new Carbon('2017-07-29T13:57:27.123456Z'); $this->assertSame('2017-07-29 13:57:27.123456 Z', $date->format('Y-m-d H:i:s.u e')); $date = Carbon::createFromFormat('Y-m-d\TH:i:s.uT', '2017-07-29T13:57:27.123456Z'); $this->assertSame('2017-07-29 13:57:27.123456 Z', $date->format('Y-m-d H:i:s.u e')); $timestamp = Carbon::create(1975, 5, 21, 22, 32, 5, 'UTC')->timestamp * 1000 + 321; $d = Carbon::createFromTimestampMs($timestamp); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5, 321000); $locale = setlocale(LC_ALL, '0'); if (setlocale(LC_ALL, 'fr_FR.UTF-8', 'fr_FR.utf8', 'French_France.UTF8') === false) { $this->markTestSkipped('testComaDecimalSeparatorLocale test need fr_FR.UTF-8.'); } $timestamp = Carbon::create(1975, 5, 21, 22, 32, 5, 'UTC')->timestamp * 1000 + 321; $d = Carbon::createFromTimestampMs($timestamp); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5, 321000); $date = new Carbon('2017-07-29T13:57:27.123456Z'); $this->assertSame('2017-07-29 13:57:27.123456 Z', $date->format('Y-m-d H:i:s.u e')); $date = Carbon::createFromFormat('Y-m-d\TH:i:s.uT', '2017-07-29T13:57:27.123456Z'); $this->assertSame('2017-07-29 13:57:27.123456 Z', $date->format('Y-m-d H:i:s.u e')); $timestamp = Carbon::create(1975, 5, 21, 22, 32, 5, 'UTC')->timestamp * 1000 + 321; $d = Carbon::createFromTimestampMs($timestamp); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5, 321000); setlocale(LC_ALL, $locale); } public function testCreateFromTimestampUsesNoTimezone() { $d = Carbon::createFromTimestamp(0); // UTC by default $this->assertSame(1970, $d->year); $this->assertSame(0, $d->offset); } public function testCreateFromTimestampUsesDefaultTimezone() { $d = Carbon::createFromTimestamp(0, 'America/Toronto'); // We know Toronto is -5 since no DST in Jan $this->assertSame(1969, $d->year); $this->assertSame(-5 * 3600, $d->offset); } public function testCreateFromTimestampWithDateTimeZone() { $d = Carbon::createFromTimestamp(0, new DateTimeZone('UTC')); $this->assertSame('UTC', $d->tzName); $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0); } public function testCreateFromTimestampWithString() { $d = Carbon::createFromTimestamp(0, 'UTC'); $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0); $this->assertSame(0, $d->offset); $this->assertSame('UTC', $d->tzName); } public function testCreateFromTimestampGMTDoesNotUseDefaultTimezone() { $d = Carbon::createFromTimestampUTC(0); $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0); $this->assertSame(0, $d->offset); } /** * Ensures DST php bug does not affect createFromTimestamp in DST change. * * @see https://github.com/briannesbitt/Carbon/issues/1951 */ public function testCreateFromTimestampInDstChange() { $this->assertSame( '2019-11-03T01:00:00-04:00', Carbon::createFromTimestamp(1572757200, 'America/New_York')->toIso8601String(), ); $this->assertSame( '2019-11-03T01:00:00-05:00', Carbon::createFromTimestamp(1572757200 + 3600, 'America/New_York')->toIso8601String(), ); $this->assertSame( '2019-11-03T01:00:00-04:00', Carbon::createFromTimestampMs(1572757200000, 'America/New_York')->toIso8601String(), ); $this->assertSame( '2019-11-03T01:00:00-05:00', Carbon::createFromTimestampMs(1572757200000 + 3600000, 'America/New_York')->toIso8601String(), ); } public function testCreateFromMicrotimeFloat() { $microtime = 1600887164.88952298; $d = Carbon::createFromTimestamp($microtime); $this->assertSame('+00:00', $d->tzName); $this->assertSame('2020-09-23 18:52:44.889523', $d->format('Y-m-d H:i:s.u')); $this->assertSame('1600887164.889523', $d->format('U.u')); $d = Carbon::createFromTimestamp($microtime, 'America/Toronto'); $this->assertSame('America/Toronto', $d->tzName); $this->assertSame('2020-09-23 14:52:44.889523', $d->format('Y-m-d H:i:s.u')); $this->assertSame('1600887164.889523', $d->format('U.u')); $microtime = 1600887164.0603; $d = Carbon::createFromTimestamp($microtime); $this->assertSame('+00:00', $d->tzName); $this->assertSame('2020-09-23 18:52:44.060300', $d->format('Y-m-d H:i:s.u')); $this->assertSame('1600887164.060300', $d->format('U.u')); $d = Carbon::createFromTimestamp($microtime, 'America/Toronto'); $this->assertSame('America/Toronto', $d->tzName); $this->assertSame('2020-09-23 14:52:44.060300', $d->format('Y-m-d H:i:s.u')); $this->assertSame('1600887164.060300', $d->format('U.u')); $this->assertSame('010000', Carbon::createFromTimestamp(0.01)->format('u')); } public function testCreateFromMicrotimeStrings() { $microtime = '0.88951247 1600887164'; $d = Carbon::createFromTimestamp($microtime, 'America/Toronto'); $this->assertSame('America/Toronto', $d->tzName); $this->assertSame('2020-09-23 14:52:44.889512', $d->format('Y-m-d H:i:s.u')); $this->assertSame('1600887164.889512', $d->format('U.u')); $d = Carbon::createFromTimestamp($microtime); $this->assertSame('+00:00', $d->tzName); $this->assertSame('2020-09-23 18:52:44.889512', $d->format('Y-m-d H:i:s.u')); $this->assertSame('1600887164.889512', $d->format('U.u')); $microtime = '0.88951247/1600887164/12.56'; $d = Carbon::createFromTimestamp($microtime, 'America/Toronto'); $this->assertSame('America/Toronto', $d->tzName); $this->assertSame('2020-09-23 14:52:57.449512', $d->format('Y-m-d H:i:s.u')); $this->assertSame('1600887177.449512', $d->format('U.u')); $d = Carbon::createFromTimestamp($microtime); $this->assertSame('+00:00', $d->tzName); $this->assertSame('2020-09-23 18:52:57.449512', $d->format('Y-m-d H:i:s.u')); $this->assertSame('1600887177.449512', $d->format('U.u')); $d = Carbon::createFromTimestamp('-10.6', 'America/Toronto'); $this->assertSame('1969-12-31 18:59:49.400000 -05:00', $d->format('Y-m-d H:i:s.u P')); $d = Carbon::createFromTimestamp('-10.6'); $this->assertSame('1969-12-31 23:59:49.400000 +00:00', $d->format('Y-m-d H:i:s.u P')); $d = new Carbon('@-10.6'); $this->assertSame('1969-12-31 23:59:49.400000 +00:00', $d->format('Y-m-d H:i:s.u P')); } public function testCreateFromMicrotimeUTCFloat() { $microtime = 1600887164.88952298; $d = Carbon::createFromTimestampUTC($microtime); $this->assertSame('+00:00', $d->tzName); $this->assertSame('2020-09-23 18:52:44.889523', $d->format('Y-m-d H:i:s.u')); $this->assertSame('1600887164.889523', $d->format('U.u')); } public function testCreateFromMicrotimeUTCStrings() { $microtime = '0.88951247 1600887164'; $d = Carbon::createFromTimestampUTC($microtime); $this->assertSame('+00:00', $d->tzName); $this->assertSame('2020-09-23 18:52:44.889512', $d->format('Y-m-d H:i:s.u')); $this->assertSame('1600887164.889512', $d->format('U.u')); $microtime = '0.88951247/1600887164/12.56'; $d = Carbon::createFromTimestampUTC($microtime); $this->assertSame('+00:00', $d->tzName); $this->assertSame('2020-09-23 18:52:57.449512', $d->format('Y-m-d H:i:s.u')); $this->assertSame('1600887177.449512', $d->format('U.u')); } public function testNegativeIntegerTimestamp() { $this->assertSame( '1969-12-31 18:59:59.000000 -05:00', Carbon::createFromTimestamp(-1, 'America/Toronto')->format('Y-m-d H:i:s.u P'), ); $this->assertSame( '1969-12-31 23:59:59.000000 +00:00', Carbon::createFromTimestamp(-1)->format('Y-m-d H:i:s.u P'), ); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/PhpBug72338Test.php
tests/CarbonImmutable/PhpBug72338Test.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Tests\AbstractTestCase; /** * The problem is, that $date->setTimezone($tz) with $tz in 'HH:MM' notation (["timezone_type"]=>int(1)) put DateTime object * on inconsistent state. It looks like internal timestamp becomes changed and it affects to such functions: * * * $date->modify() uses changed timestamp and result is wrong * * * $date->setTimezone($tz) settle this changed timestamp, even in case if $tz is not in 'HH:MM' format * * * $date->format('U') returns changed timestamp * * @link https://bugs.php.net/bug.php?id=72338 This bug on bugs.php.net * * @internal I use days changing in tests because using seconds|minute|hours may run setTimezone within. */ class PhpBug72338Test extends AbstractTestCase { /** * Ensures that modify don't use changed timestamp */ public function testModify() { $date = Carbon::createFromTimestamp(0)->setTimezone('+02:00')->modify('+1 day'); $this->assertSame('86400', $date->format('U')); } /** * Ensures that $date->format('U') returns unchanged timestamp */ public function testTimestamp() { $date = Carbon::createFromTimestamp(0)->setTimezone('+02:00'); $this->assertSame('0', $date->format('U')); } /** * Ensures that date created from string with timezone and with same timezone set by setTimezone() is equal */ public function testEqualSetAndCreate() { $date = Carbon::createFromTimestamp(0)->setTimezone('+02:00'); $date1 = new Carbon('1970-01-01T02:00:00+02:00'); $this->assertSame($date->format('U'), $date1->format('U')); } /** * Ensures that second call to setTimezone() don't changing timestamp */ public function testSecondSetTimezone() { $date = Carbon::createFromTimestamp(0)->setTimezone('+02:00')->setTimezone('Europe/Moscow'); $this->assertSame('0', $date->format('U')); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/CreateTest.php
tests/CarbonImmutable/CreateTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\Exceptions\InvalidTimeZoneException; use DateTime; use DateTimeZone; use InvalidArgumentException; use Tests\AbstractTestCase; class CreateTest extends AbstractTestCase { public function testCreateReturnsDatingInstance() { $d = Carbon::create(); $this->assertInstanceOfCarbon($d); } public function testCreateWithDefaults() { $d = Carbon::create(); $this->assertSame($d->getTimestamp(), Carbon::create('0000-01-01 00:00:00')->getTimestamp()); } public function testCreateWithNull() { $d = Carbon::create(null, null, null, null, null, null); $this->assertSame($d->getTimestamp(), Carbon::now()->getTimestamp()); } public function testCreateAsParseAlias() { $d = Carbon::create('2019-02-05 12:30:06.99', 'Asia/Tokyo'); $this->assertSame('2019-02-05 12:30:06.990000 Asia/Tokyo', $d->format('Y-m-d H:i:s.u e')); } public function testCreateWithYear() { $d = Carbon::create(2012); $this->assertSame(2012, $d->year); } public function testCreateHandlesNegativeYear() { $c = Carbon::create(-1, 10, 12, 1, 2, 3); $this->assertCarbon($c, -1, 10, 12, 1, 2, 3); } public function testCreateHandlesFiveDigitsPositiveYears() { $c = Carbon::create(999999999, 10, 12, 1, 2, 3); $this->assertCarbon($c, 999999999, 10, 12, 1, 2, 3); } public function testCreateHandlesFiveDigitsNegativeYears() { $c = Carbon::create(-999999999, 10, 12, 1, 2, 3); $this->assertCarbon($c, -999999999, 10, 12, 1, 2, 3); } public function testCreateWithMonth() { $d = Carbon::create(null, 3); $this->assertSame(3, $d->month); } public function testCreateWithInvalidMonth() { $this->expectExceptionObject(new InvalidArgumentException( 'month must be between 0 and 99, -5 given', )); Carbon::create(null, -5); } public function testCreateMonthWraps() { $d = Carbon::create(2011, 0, 1, 0, 0, 0); $this->assertCarbon($d, 2010, 12, 1, 0, 0, 0); } public function testCreateWithDay() { $d = Carbon::create(null, null, 21); $this->assertSame(21, $d->day); } public function testCreateWithInvalidDay() { $this->expectExceptionObject(new InvalidArgumentException( 'day must be between 0 and 99, -4 given', )); Carbon::create(null, null, -4); } public function testCreateDayWraps() { $d = Carbon::create(2011, 1, 40, 0, 0, 0); $this->assertCarbon($d, 2011, 2, 9, 0, 0, 0); } public function testCreateWithHourAndDefaultMinSecToZero() { $d = Carbon::create(null, null, null, 14); $this->assertSame(14, $d->hour); $this->assertSame(0, $d->minute); $this->assertSame(0, $d->second); } public function testCreateWithInvalidHour() { $this->expectExceptionObject(new InvalidArgumentException( 'hour must be between 0 and 99, -1 given', )); Carbon::create(null, null, null, -1); } public function testCreateHourWraps() { $d = Carbon::create(2011, 1, 1, 24, 0, 0); $this->assertCarbon($d, 2011, 1, 2, 0, 0, 0); } public function testCreateWithMinute() { $d = Carbon::create(null, null, null, null, 58); $this->assertSame(58, $d->minute); } public function testCreateWithInvalidMinute() { $this->expectExceptionObject(new InvalidArgumentException( 'minute must be between 0 and 99, -2 given', )); Carbon::create(2011, 1, 1, 0, -2, 0); } public function testCreateMinuteWraps() { $d = Carbon::create(2011, 1, 1, 0, 62, 0); $this->assertCarbon($d, 2011, 1, 1, 1, 2, 0); } public function testCreateWithSecond() { $d = Carbon::create(null, null, null, null, null, 59); $this->assertSame(59, $d->second); } public function testCreateWithInvalidSecond() { $this->expectExceptionObject(new InvalidArgumentException( 'second must be between 0 and 99, -2 given', )); Carbon::create(null, null, null, null, null, -2); } public function testCreateSecondsWrap() { $d = Carbon::create(2012, 1, 1, 0, 0, 61); $this->assertCarbon($d, 2012, 1, 1, 0, 1, 1); } public function testCreateWithDateTimeZone() { $d = Carbon::create(2012, 1, 1, 0, 0, 0, new DateTimeZone('Europe/London')); $this->assertCarbon($d, 2012, 1, 1, 0, 0, 0); $this->assertSame('Europe/London', $d->tzName); } public function testCreateWithTimeZoneString() { $d = Carbon::create(2012, 1, 1, 0, 0, 0, 'Europe/London'); $this->assertCarbon($d, 2012, 1, 1, 0, 0, 0); $this->assertSame('Europe/London', $d->tzName); } public function testMake() { $this->assertCarbon(Carbon::make('2017-01-05'), 2017, 1, 5, 0, 0, 0); $this->assertCarbon(Carbon::make(new DateTime('2017-01-05')), 2017, 1, 5, 0, 0, 0); $this->assertCarbon(Carbon::make(new Carbon('2017-01-05')), 2017, 1, 5, 0, 0, 0); $this->assertNull(Carbon::make(3)); } public function testCreateWithInvalidTimezoneOffset() { $this->expectExceptionObject(new InvalidTimeZoneException( 'Unknown or bad timezone (-28236)', )); Carbon::createFromDate(2000, 1, 1, -28236); } public function testCreateWithValidTimezoneOffset() { $dt = Carbon::createFromDate(2000, 1, 1, -4); $this->assertSame('America/New_York', $dt->tzName); $dt = Carbon::createFromDate(2000, 1, 1, '-4'); $this->assertSame('-04:00', $dt->tzName); } public function testParseFromLocale() { $date = Carbon::parseFromLocale('23 Okt 2019', 'de'); $this->assertSame('Wednesday, October 23, 2019 12:00 AM America/Toronto', $date->isoFormat('LLLL zz')); $date = Carbon::parseFromLocale('23 Okt 2019', 'de', 'Europe/Berlin')->locale('de'); $this->assertSame('Mittwoch, 23. Oktober 2019 00:00 Europe/Berlin', $date->isoFormat('LLLL zz')); $date = Carbon::parseFromLocale('23 červenec 2019', 'cs'); $this->assertSame('2019-07-23', $date->format('Y-m-d')); $date = Carbon::parseFromLocale('23 červen 2019', 'cs'); $this->assertSame('2019-06-23', $date->format('Y-m-d')); Carbon::setTestNow('2021-01-26 15:45:13'); $date = Carbon::parseFromLocale('завтра', 'ru'); $this->assertSame('2021-01-27 00:00:00', $date->format('Y-m-d H:i:s')); } public function testParseFromLocaleWithDefaultLocale() { Carbon::setLocale('fr'); $date = Carbon::parseFromLocale('Dimanche'); $this->assertSame('dimanche', $date->dayName); $date = Carbon::parseFromLocale('Lundi'); $this->assertSame('lundi', $date->dayName); } public function testCreateFromLocaleFormat() { $date = Carbon::createFromLocaleFormat('Y M d H,i,s', 'zh_CN', '2019 四月 4 12,04,21'); $this->assertSame('Thursday, April 4, 2019 12:04 PM America/Toronto', $date->isoFormat('LLLL zz')); $date = Carbon::createFromLocaleFormat('Y M d H,i,s', 'zh_TW', '2019 四月 4 12,04,21', 'Asia/Shanghai')->locale('zh'); $this->assertSame('2019年4月4日星期四 中午 12点04分 Asia/Shanghai', $date->isoFormat('LLLL zz')); $this->assertSame( '2022-12-05 America/Mexico_City', Carbon::createFromLocaleFormat('d * F * Y', 'es', '05 de diciembre de 2022', 'America/Mexico_City') ->format('Y-m-d e') ); $this->assertSame( '2022-12-05 America/Mexico_City', Carbon::createFromLocaleFormat('d \of F \of Y', 'es', '05 de diciembre de 2022', 'America/Mexico_City') ->format('Y-m-d e') ); $this->assertSame( '2022-12-05 America/Mexico_City', Carbon::createFromLocaleFormat('d \o\f F \o\f Y', 'es', '05 de diciembre de 2022', 'America/Mexico_City') ->format('Y-m-d e') ); $this->assertSame( '2022-12-05 America/Mexico_City', Carbon::createFromLocaleFormat('d \d\e F \d\e Y', 'es', '05 de diciembre de 2022', 'America/Mexico_City') ->format('Y-m-d e') ); $this->assertSame( '2022-12-05 America/Mexico_City', Carbon::createFromLocaleFormat('d \n\o\t F \n\o\t Y', 'es', '05 not diciembre not 2022', 'America/Mexico_City') ->format('Y-m-d e') ); } public function testCreateFromIsoFormat() { $date = Carbon::createFromIsoFormat('!YYYYY MMMM D', '2019 April 4'); $this->assertSame('Thursday, April 4, 2019 12:00 AM America/Toronto', $date->isoFormat('LLLL zz')); } public function testCreateFromIsoFormatException() { $this->expectExceptionObject(new InvalidArgumentException( 'Format wo not supported for creation.', )); Carbon::createFromIsoFormat('YY D wo', '2019 April 4'); } public function testCreateFromLocaleIsoFormat() { $date = Carbon::createFromLocaleIsoFormat('YYYY MMMM D HH,mm,ss', 'zh_TW', '2019 四月 4 12,04,21'); $this->assertSame('Thursday, April 4, 2019 12:04 PM America/Toronto', $date->isoFormat('LLLL zz')); $date = Carbon::createFromLocaleIsoFormat('LLL zz', 'zh', '2019年4月4日 下午 2点04分 Asia/Shanghai'); $this->assertSame('Thursday, April 4, 2019 2:04 PM Asia/Shanghai', $date->isoFormat('LLLL zz')); $this->assertSame('2019年4月4日星期四 下午 2点04分 Asia/Shanghai', $date->locale('zh')->isoFormat('LLLL zz')); $date = Carbon::createFromLocaleIsoFormat('llll', 'fr_CA', 'mar. 24 juil. 2018 08:34'); $this->assertSame('2018-07-24 08:34', $date->format('Y-m-d H:i')); } public function testStartOfTime() { $this->assertTrue(Carbon::startOfTime()->isStartOfTime()); $this->assertTrue(Carbon::startOfTime()->toImmutable()->isStartOfTime()); } public function testEndOfTime() { $this->assertTrue(Carbon::endOfTime()->isEndOfTime()); $this->assertTrue(Carbon::endOfTime()->toImmutable()->isEndOfTime()); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/DayOfWeekModifiersTest.php
tests/CarbonImmutable/DayOfWeekModifiersTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Tests\AbstractTestCase; class DayOfWeekModifiersTest extends AbstractTestCase { public function testGetWeekendDays() { $this->assertSame([Carbon::SATURDAY, Carbon::SUNDAY], Carbon::getWeekendDays()); } public function testSetWeekendDays() { Carbon::setWeekendDays([Carbon::THURSDAY, Carbon::FRIDAY]); $this->assertSame([Carbon::THURSDAY, Carbon::FRIDAY], Carbon::getWeekendDays()); $this->assertTrue(Carbon::createFromDate(2018, 2, 16)->isWeekend()); Carbon::setWeekendDays([Carbon::SATURDAY, Carbon::SUNDAY]); $this->assertSame([Carbon::SATURDAY, Carbon::SUNDAY], Carbon::getWeekendDays()); $this->assertFalse(Carbon::createFromDate(2018, 2, 16)->isWeekend()); } public function testStartOfWeek() { $d = Carbon::create(1980, 8, 7, 12, 11, 9)->startOfWeek(); $this->assertCarbon($d, 1980, 8, 4, 0, 0, 0); } public function testStartOfWeekFromWeekStart() { $d = Carbon::createFromDate(1980, 8, 4)->startOfWeek(); $this->assertCarbon($d, 1980, 8, 4, 0, 0, 0); } public function testStartOfWeekCrossingYearBoundary() { $d = Carbon::createFromDate(2013, 12, 31, 'GMT'); $d2 = $d->startOfWeek(); $this->assertCarbon($d, 2013, 12, 31); $this->assertCarbon($d2, 2013, 12, 30, 0, 0, 0); } public function testEndOfWeek() { $d = Carbon::create(1980, 8, 7, 11, 12, 13)->endOfWeek(); $this->assertCarbon($d, 1980, 8, 10, 23, 59, 59); } public function testEndOfWeekFromWeekEnd() { $d = Carbon::createFromDate(1980, 8, 9)->endOfWeek(); $this->assertCarbon($d, 1980, 8, 10, 23, 59, 59); } public function testEndOfWeekCrossingYearBoundary() { $d = Carbon::createFromDate(2013, 12, 31, 'GMT'); $d2 = $d->endOfWeek(); $this->assertCarbon($d, 2013, 12, 31); $this->assertCarbon($d2, 2014, 1, 5, 23, 59, 59); } /** * @see https://github.com/briannesbitt/Carbon/issues/735 */ public function testStartOrEndOfWeekFromWeekWithUTC() { $d = Carbon::create(2016, 7, 27, 17, 13, 7, 'UTC'); $this->assertCarbon($d->copy()->startOfWeek(), 2016, 7, 25, 0, 0, 0); $this->assertCarbon($d->copy()->endOfWeek(), 2016, 7, 31, 23, 59, 59); } /** * @see https://github.com/briannesbitt/Carbon/issues/735 */ public function testStartOrEndOfWeekFromWeekWithOtherTimezone() { $d = Carbon::create(2016, 7, 27, 17, 13, 7, 'America/New_York'); $this->assertCarbon($d->copy()->startOfWeek(), 2016, 7, 25, 0, 0, 0); $this->assertCarbon($d->copy()->endOfWeek(), 2016, 7, 31, 23, 59, 59); } public function testNext() { $d = Carbon::createFromDate(1975, 5, 21)->next(); $this->assertCarbon($d, 1975, 5, 28, 0, 0, 0); } public function testNextMonday() { $d = Carbon::createFromDate(1975, 5, 21)->next(Carbon::MONDAY); $this->assertCarbon($d, 1975, 5, 26, 0, 0, 0); } public function testNextSaturday() { $d = Carbon::createFromDate(1975, 5, 21)->next(6); $this->assertCarbon($d, 1975, 5, 24, 0, 0, 0); } public function testNextTimestamp() { $d = Carbon::createFromDate(1975, 11, 14)->next(); $this->assertCarbon($d, 1975, 11, 21, 0, 0, 0); } public function testPrevious() { $d = Carbon::createFromDate(1975, 5, 21)->previous(); $this->assertCarbon($d, 1975, 5, 14, 0, 0, 0); } public function testPreviousMonday() { $d = Carbon::createFromDate(1975, 5, 21)->previous(Carbon::MONDAY); $this->assertCarbon($d, 1975, 5, 19, 0, 0, 0); } public function testPreviousSaturday() { $d = Carbon::createFromDate(1975, 5, 21)->previous(6); $this->assertCarbon($d, 1975, 5, 17, 0, 0, 0); } public function testPreviousTimestamp() { $d = Carbon::createFromDate(1975, 11, 28)->previous(); $this->assertCarbon($d, 1975, 11, 21, 0, 0, 0); } public function testFirstDayOfMonth() { $d = Carbon::createFromDate(1975, 11, 21)->firstOfMonth(); $this->assertCarbon($d, 1975, 11, 1, 0, 0, 0); } public function testFirstWednesdayOfMonth() { $d = Carbon::createFromDate(1975, 11, 21)->firstOfMonth(Carbon::WEDNESDAY); $this->assertCarbon($d, 1975, 11, 5, 0, 0, 0); } public function testFirstFridayOfMonth() { $d = Carbon::createFromDate(1975, 11, 21)->firstOfMonth(5); $this->assertCarbon($d, 1975, 11, 7, 0, 0, 0); } public function testLastDayOfMonth() { $d = Carbon::createFromDate(1975, 12, 5)->lastOfMonth(); $this->assertCarbon($d, 1975, 12, 31, 0, 0, 0); } public function testLastTuesdayOfMonth() { $d = Carbon::createFromDate(1975, 12, 1)->lastOfMonth(Carbon::TUESDAY); $this->assertCarbon($d, 1975, 12, 30, 0, 0, 0); } public function testLastFridayOfMonth() { $d = Carbon::createFromDate(1975, 12, 5)->lastOfMonth(5); $this->assertCarbon($d, 1975, 12, 26, 0, 0, 0); } public function testNthOfMonthOutsideScope() { $this->assertFalse(Carbon::createFromDate(1975, 12, 5)->nthOfMonth(6, Carbon::MONDAY)); } public function testNthOfMonthOutsideYear() { $this->assertFalse(Carbon::createFromDate(1975, 12, 5)->nthOfMonth(55, Carbon::MONDAY)); } public function test2ndMondayOfMonth() { $d = Carbon::createFromDate(1975, 12, 5)->nthOfMonth(2, Carbon::MONDAY); $this->assertCarbon($d, 1975, 12, 8, 0, 0, 0); } public function test3rdWednesdayOfMonth() { $d = Carbon::createFromDate(1975, 12, 5)->nthOfMonth(3, 3); $this->assertCarbon($d, 1975, 12, 17, 0, 0, 0); } public function testFirstDayOfQuarter() { $d = Carbon::createFromDate(1975, 11, 21)->firstOfQuarter(); $this->assertCarbon($d, 1975, 10, 1, 0, 0, 0); } public function testFirstWednesdayOfQuarter() { $d = Carbon::createFromDate(1975, 11, 21)->firstOfQuarter(Carbon::WEDNESDAY); $this->assertCarbon($d, 1975, 10, 1, 0, 0, 0); } public function testFirstFridayOfQuarter() { $d = Carbon::createFromDate(1975, 11, 21)->firstOfQuarter(5); $this->assertCarbon($d, 1975, 10, 3, 0, 0, 0); } public function testFirstOfQuarterFromADayThatWillNotExistInTheFirstMonth() { $d = Carbon::createFromDate(2014, 5, 31)->firstOfQuarter(); $this->assertCarbon($d, 2014, 4, 1, 0, 0, 0); } public function testLastDayOfQuarter() { $d = Carbon::createFromDate(1975, 8, 5)->lastOfQuarter(); $this->assertCarbon($d, 1975, 9, 30, 0, 0, 0); } public function testLastTuesdayOfQuarter() { $d = Carbon::createFromDate(1975, 8, 1)->lastOfQuarter(Carbon::TUESDAY); $this->assertCarbon($d, 1975, 9, 30, 0, 0, 0); } public function testLastFridayOfQuarter() { $d = Carbon::createFromDate(1975, 7, 5)->lastOfQuarter(5); $this->assertCarbon($d, 1975, 9, 26, 0, 0, 0); } public function testLastOfQuarterFromADayThatWillNotExistInTheLastMonth() { $d = Carbon::createFromDate(2014, 5, 31)->lastOfQuarter(); $this->assertCarbon($d, 2014, 6, 30, 0, 0, 0); } public function testNthOfQuarterOutsideScope() { $this->assertFalse(Carbon::createFromDate(1975, 1, 5)->nthOfQuarter(20, Carbon::MONDAY)); } public function testNthOfQuarterOutsideYear() { $this->assertFalse(Carbon::createFromDate(1975, 1, 5)->nthOfQuarter(55, Carbon::MONDAY)); } public function testNthOfQuarterFromADayThatWillNotExistInTheFirstMonth() { $d = Carbon::createFromDate(2014, 5, 31)->nthOfQuarter(2, Carbon::MONDAY); $this->assertCarbon($d, 2014, 4, 14, 0, 0, 0); } public function test2ndMondayOfQuarter() { $d = Carbon::createFromDate(1975, 8, 5)->nthOfQuarter(2, Carbon::MONDAY); $this->assertCarbon($d, 1975, 7, 14, 0, 0, 0); } public function test3rdWednesdayOfQuarter() { $d = Carbon::createFromDate(1975, 8, 5)->nthOfQuarter(3, 3); $this->assertCarbon($d, 1975, 7, 16, 0, 0, 0); } public function testFirstDayOfYear() { $d = Carbon::createFromDate(1975, 11, 21)->firstOfYear(); $this->assertCarbon($d, 1975, 1, 1, 0, 0, 0); } public function testFirstWednesdayOfYear() { $d = Carbon::createFromDate(1975, 11, 21)->firstOfYear(Carbon::WEDNESDAY); $this->assertCarbon($d, 1975, 1, 1, 0, 0, 0); } public function testFirstFridayOfYear() { $d = Carbon::createFromDate(1975, 11, 21)->firstOfYear(5); $this->assertCarbon($d, 1975, 1, 3, 0, 0, 0); } public function testLastDayOfYear() { $d = Carbon::createFromDate(1975, 8, 5)->lastOfYear(); $this->assertCarbon($d, 1975, 12, 31, 0, 0, 0); } public function testLastTuesdayOfYear() { $d = Carbon::createFromDate(1975, 8, 1)->lastOfYear(Carbon::TUESDAY); $this->assertCarbon($d, 1975, 12, 30, 0, 0, 0); } public function testLastFridayOfYear() { $d = Carbon::createFromDate(1975, 7, 5)->lastOfYear(5); $this->assertCarbon($d, 1975, 12, 26, 0, 0, 0); } public function testNthOfYearOutsideScope() { $this->assertFalse(Carbon::createFromDate(1975, 1, 5)->nthOfYear(55, Carbon::MONDAY)); } public function test2ndMondayOfYear() { $d = Carbon::createFromDate(1975, 8, 5)->nthOfYear(2, Carbon::MONDAY); $this->assertCarbon($d, 1975, 1, 13, 0, 0, 0); } public function test3rdWednesdayOfYear() { $d = Carbon::createFromDate(1975, 8, 5)->nthOfYear(3, 3); $this->assertCarbon($d, 1975, 1, 15, 0, 0, 0); } public function testNextWeekday() { // Friday to Monday $d = Carbon::create(2016, 7, 15)->nextWeekday(); $this->assertCarbon($d, 2016, 7, 18); // Saturday to Monday $d = Carbon::create(2016, 7, 16)->nextWeekday(); $this->assertCarbon($d, 2016, 7, 18); // Sunday to Monday $d = Carbon::create(2016, 7, 16)->nextWeekday(); $this->assertCarbon($d, 2016, 7, 18); // Monday to Tuesday $d = Carbon::create(2016, 7, 17)->nextWeekday(); $this->assertCarbon($d, 2016, 7, 18); } public function testPreviousWeekday() { // Tuesday to Monday $d = Carbon::create(2016, 7, 19)->previousWeekday(); $this->assertCarbon($d, 2016, 7, 18); // Monday to Friday $d = Carbon::create(2016, 7, 18)->previousWeekday(); $this->assertCarbon($d, 2016, 7, 15); // Sunday to Friday $d = Carbon::create(2016, 7, 17)->previousWeekday(); $this->assertCarbon($d, 2016, 7, 15); // Saturday to Friday $d = Carbon::create(2016, 7, 16)->previousWeekday(); $this->assertCarbon($d, 2016, 7, 15); } public function testNextWeekendDay() { // Thursday to Saturday $d = Carbon::create(2016, 7, 14)->nextWeekendDay(); $this->assertCarbon($d, 2016, 7, 16); // Friday to Saturday $d = Carbon::create(2016, 7, 15)->nextWeekendDay(); $this->assertCarbon($d, 2016, 7, 16); // Saturday to Sunday $d = Carbon::create(2016, 7, 16)->nextWeekendDay(); $this->assertCarbon($d, 2016, 7, 17); // Sunday to Saturday $d = Carbon::create(2016, 7, 17)->nextWeekendDay(); $this->assertCarbon($d, 2016, 7, 23); } public function testPreviousWeekendDay() { // Thursday to Sunday $d = Carbon::create(2016, 7, 14)->previousWeekendDay(); $this->assertCarbon($d, 2016, 7, 10); // Friday to Sunday $d = Carbon::create(2016, 7, 15)->previousWeekendDay(); $this->assertCarbon($d, 2016, 7, 10); // Saturday to Sunday $d = Carbon::create(2016, 7, 16)->previousWeekendDay(); $this->assertCarbon($d, 2016, 7, 10); // Sunday to Saturday $d = Carbon::create(2016, 7, 17)->previousWeekendDay(); $this->assertCarbon($d, 2016, 7, 16); } public function testWeekStartAndEndWithAutoMode() { $this->assertSame('Monday', Carbon::now()->startOfWeek()->dayName); Carbon::setLocale('en_UM'); $this->assertSame('Sunday', Carbon::now()->startOfWeek()->dayName); Carbon::setLocale('en_US'); $this->assertSame('Sunday', Carbon::now()->startOfWeek()->dayName); Carbon::setLocale('en'); $this->assertSame('Monday', Carbon::now()->startOfWeek()->dayName); Carbon::setLocale('es_US'); $this->assertSame('domingo', Carbon::now()->startOfWeek()->dayName); Carbon::setLocale('en_GB'); $this->assertSame('Monday', Carbon::now()->startOfWeek()->dayName); Carbon::setLocale('en_UM'); $this->assertSame('Saturday', Carbon::now()->endOfWeek()->dayName); Carbon::setLocale('en_US'); $this->assertSame('Saturday', Carbon::now()->endOfWeek()->dayName); Carbon::setLocale('en'); $this->assertSame('Sunday', Carbon::now()->endOfWeek()->dayName); Carbon::setLocale('es_US'); $this->assertSame('sábado', Carbon::now()->endOfWeek()->dayName); Carbon::setLocale('en_GB'); $this->assertSame('Sunday', Carbon::now()->endOfWeek()->dayName); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/AddTest.php
tests/CarbonImmutable/AddTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\CarbonInterval; use Carbon\Unit; use DateTimeImmutable; use Tests\AbstractTestCase; class AddTest extends AbstractTestCase { public function testAddMethod() { $this->assertSame(1977, Carbon::createFromDate(1975)->add(2, 'year')->year); $this->assertSame(1977, Carbon::createFromDate(1975)->add('year', 2)->year); $this->assertSame(1977, Carbon::createFromDate(1975)->add(2, Unit::Year)->year); $this->assertSame(1977, Carbon::createFromDate(1975)->add(Unit::Year, 2)->year); $this->assertSame(1977, Carbon::createFromDate(1975)->add('2 years')->year); $lastNegated = null; $date = Carbon::createFromDate(1975)->add( function (DateTimeImmutable $date, bool $negated = false) use (&$lastNegated): DateTimeImmutable { $lastNegated = $negated; return new DateTimeImmutable($date->format('Y-m-d H:i:s').' + 2 years'); }, ); $this->assertInstanceOf(Carbon::class, $date); $this->assertSame(1977, $date->year); $this->assertFalse($lastNegated); /** @var CarbonInterval $interval */ $interval = include __DIR__.'/../Fixtures/dynamicInterval.php'; $originalDate = Carbon::parse('2020-06-04'); $date = $originalDate->add($interval); $this->assertInstanceOf(Carbon::class, $date); $this->assertSame('2020-06-08', $date->format('Y-m-d')); $this->assertNotSame($date, $originalDate); $date = Carbon::parse('2020-06-23')->add($interval); $this->assertInstanceOf(Carbon::class, $date); $this->assertSame('2020-07-16', $date->format('Y-m-d')); } public function testAddYearsPositive() { $this->assertSame(1976, Carbon::createFromDate(1975)->addYears(1)->year); } public function testAddYearsZero() { $this->assertSame(1975, Carbon::createFromDate(1975)->addYears(0)->year); } public function testAddYearsNegative() { $this->assertSame(1974, Carbon::createFromDate(1975)->addYears(-1)->year); } public function testAddYear() { $this->assertSame(1976, Carbon::createFromDate(1975)->addYear()->year); $this->assertSame(1977, Carbon::createFromDate(1975)->add(2, 'year')->year); $this->assertSame(1977, Carbon::createFromDate(1975)->add(2, 'years')->year); $this->assertSame(1977, Carbon::createFromDate(1975)->add(CarbonInterval::years(2))->year); } public function testAddDaysPositive() { $this->assertSame(1, Carbon::createFromDate(1975, 5, 31)->addDays(1)->day); } public function testAddDaysZero() { $this->assertSame(31, Carbon::createFromDate(1975, 5, 31)->addDays(0)->day); } public function testAddDaysNegative() { $this->assertSame(30, Carbon::createFromDate(1975, 5, 31)->addDays(-1)->day); } public function testAddDay() { $this->assertSame(1, Carbon::createFromDate(1975, 5, 31)->addDay()->day); } public function testAddOverflow() { $this->assertSame( '2021-03-03', Carbon::parse('2021-01-31')->add(1, 'months', true)->format('Y-m-d'), ); $this->assertSame( '2021-03-03', Carbon::parse('2021-01-31')->add(1, 'months')->format('Y-m-d'), ); $this->assertSame( '2021-02-28', Carbon::parse('2021-01-31')->add(1, 'months', false)->format('Y-m-d'), ); } public function testAddWeekdaysPositive() { $dt = Carbon::create(2012, 1, 4, 13, 2, 1)->addWeekdays(9); $this->assertSame(17, $dt->day); // test for https://bugs.php.net/bug.php?id=54909 $this->assertSame(13, $dt->hour); $this->assertSame(2, $dt->minute); $this->assertSame(1, $dt->second); } public function testAddWeekdaysZero() { $this->assertSame(4, Carbon::createFromDate(2012, 1, 4)->addWeekdays(0)->day); } public function testAddWeekdaysNegative() { $this->assertSame(18, Carbon::createFromDate(2012, 1, 31)->addWeekdays(-9)->day); } public function testAddWeekday() { $this->assertSame(9, Carbon::createFromDate(2012, 1, 6)->addWeekday()->day); } public function testAddWeekdayDuringWeekend() { $this->assertSame(9, Carbon::createFromDate(2012, 1, 7)->addWeekday()->day); } public function testAddWeeksPositive() { $this->assertSame(28, Carbon::createFromDate(1975, 5, 21)->addWeeks(1)->day); } public function testAddWeeksZero() { $this->assertSame(21, Carbon::createFromDate(1975, 5, 21)->addWeeks(0)->day); } public function testAddWeeksNegative() { $this->assertSame(14, Carbon::createFromDate(1975, 5, 21)->addWeeks(-1)->day); } public function testAddWeek() { $this->assertSame(28, Carbon::createFromDate(1975, 5, 21)->addWeek()->day); } public function testAddHoursPositive() { $this->assertSame(1, Carbon::createFromTime(0)->addHours(1)->hour); } public function testAddHoursZero() { $this->assertSame(0, Carbon::createFromTime(0)->addHours(0)->hour); } public function testAddHoursNegative() { $this->assertSame(23, Carbon::createFromTime(0)->addHours(-1)->hour); } public function testAddHour() { $this->assertSame(1, Carbon::createFromTime(0)->addHour()->hour); } public function testAddMinutesPositive() { $this->assertSame(1, Carbon::createFromTime(0, 0)->addMinutes(1)->minute); } public function testAddMinutesZero() { $this->assertSame(0, Carbon::createFromTime(0, 0)->addMinutes(0)->minute); } public function testAddMinutesNegative() { $this->assertSame(59, Carbon::createFromTime(0, 0)->addMinutes(-1)->minute); } public function testAddMinute() { $this->assertSame(1, Carbon::createFromTime(0, 0)->addMinute()->minute); } public function testAddSecondsPositive() { $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->addSeconds(1)->second); } public function testAddSecondsZero() { $this->assertSame(0, Carbon::createFromTime(0, 0, 0)->addSeconds(0)->second); } public function testAddSecondsNegative() { $this->assertSame(59, Carbon::createFromTime(0, 0, 0)->addSeconds(-1)->second); } public function testAddDecimalSeconds() { $this->assertSame( '1999-12-31 23:59:58.500000', Carbon::parse('2000-01-01 00:00:00')->addSeconds(-1.5)->format('Y-m-d H:i:s.u'), ); $this->assertSame( '2000-01-01 00:00:01.500000', Carbon::parse('2000-01-01 00:00:00')->addSeconds(1.5)->format('Y-m-d H:i:s.u'), ); $this->assertSame( '1999-12-31 23:59:58.500000', Carbon::parse('2000-01-01 00:00:00')->addRealSeconds(-1.5)->format('Y-m-d H:i:s.u'), ); $this->assertSame( '2000-01-01 00:00:01.500000', Carbon::parse('2000-01-01 00:00:00')->addRealSeconds(1.5)->format('Y-m-d H:i:s.u'), ); } public function testAddSecond() { $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->addSecond()->second); } public function testAddMillisecondsPositive() { $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->addMilliseconds(1)->millisecond); } public function testAddMillisecondsZero() { $this->assertSame(100, Carbon::createFromTime(0, 0, 0.1)->addMilliseconds(0)->millisecond); } public function testAddMillisecondsNegative() { $this->assertSame(999, Carbon::createFromTime(0, 0, 0)->addMilliseconds(-1)->millisecond); $this->assertSame(99, Carbon::createFromTime(0, 0, 0.1)->addMilliseconds(-1)->millisecond); } public function testAddMillisecond() { $this->assertSame(101, Carbon::createFromTime(0, 0, 0.1)->addMillisecond()->millisecond); } public function testAddMicrosecondsPositive() { $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->addMicroseconds(1)->microsecond); } public function testAddMicrosecondsZero() { $this->assertSame(100000, Carbon::createFromTime(0, 0, 0.1)->addMicroseconds(0)->microsecond); } public function testAddMicrosecondsNegative() { $this->assertSame(999999, Carbon::createFromTime(0, 0, 0)->addMicroseconds(-1)->microsecond); $this->assertSame(99999, Carbon::createFromTime(0, 0, 0.1)->addMicroseconds(-1)->microsecond); } public function testAddMicrosecond() { $this->assertSame(100001, Carbon::createFromTime(0, 0, 0.1)->addMicrosecond()->microsecond); } /** * Test non plural methods with non default args. */ public function testAddYearPassingArg() { /** @var mixed $date */ $date = Carbon::createFromDate(1975); $this->assertSame(1977, $date->addYear(2)->year); } public function testAddDayPassingArg() { /** @var mixed $date */ $date = Carbon::createFromDate(1975, 5, 10); $this->assertSame(12, $date->addDay(2)->day); } public function testAddHourPassingArg() { /** @var mixed $date */ $date = Carbon::createFromTime(10); $this->assertSame(12, $date->addHour(2)->hour); } public function testAddMinutePassingArg() { /** @var mixed $date */ $date = Carbon::createFromTime(0); $this->assertSame(2, $date->addMinute(2)->minute); } public function testAddSecondPassingArg() { /** @var mixed $date */ $date = Carbon::createFromTime(0); $this->assertSame(2, $date->addSecond(2)->second); } public function testAddQuarter() { $this->assertSame(8, Carbon::createFromDate(1975, 5, 6)->addQuarter()->month); } public function testAddQuarterNegative() { /** @var mixed $date */ $date = Carbon::createFromDate(1975, 5, 6); $this->assertSame(2, $date->addQuarter(-1)->month); } public function testSubQuarter() { $this->assertSame(2, Carbon::createFromDate(1975, 5, 6)->subQuarter()->month); } public function testSubQuarterNegative() { $this->assertCarbon(Carbon::createFromDate(1975, 5, 6)->subQuarters(2), 1974, 11, 6); } public function testAddCentury() { $this->assertSame(2075, Carbon::createFromDate(1975)->addCentury()->year); /** @var mixed $date */ $date = Carbon::createFromDate(1975); $this->assertSame(2075, $date->addCentury(1)->year); /** @var mixed $date */ $date = Carbon::createFromDate(1975); $this->assertSame(2175, $date->addCentury(2)->year); } public function testAddCenturyNegative() { /** @var mixed $date */ $date = Carbon::createFromDate(1975); $this->assertSame(1875, $date->addCentury(-1)->year); /** @var mixed $date */ $date = Carbon::createFromDate(1975); $this->assertSame(1775, $date->addCentury(-2)->year); } public function testAddCenturies() { $this->assertSame(2075, Carbon::createFromDate(1975)->addCenturies(1)->year); $this->assertSame(2175, Carbon::createFromDate(1975)->addCenturies(2)->year); } public function testAddCenturiesNegative() { $this->assertSame(1875, Carbon::createFromDate(1975)->addCenturies(-1)->year); $this->assertSame(1775, Carbon::createFromDate(1975)->addCenturies(-2)->year); } public function testSubCentury() { $this->assertSame(1875, Carbon::createFromDate(1975)->subCentury()->year); /** @var mixed $date */ $date = Carbon::createFromDate(1975); $this->assertSame(1875, $date->subCentury(1)->year); /** @var mixed $date */ $date = Carbon::createFromDate(1975); $this->assertSame(1775, $date->subCentury(2)->year); } public function testSubCenturyNegative() { /** @var mixed $date */ $date = Carbon::createFromDate(1975); $this->assertSame(2075, $date->subCentury(-1)->year); /** @var mixed $date */ $date = Carbon::createFromDate(1975); $this->assertSame(2175, $date->subCentury(-2)->year); } public function testSubCenturies() { $this->assertSame(1875, Carbon::createFromDate(1975)->subCenturies(1)->year); $this->assertSame(1775, Carbon::createFromDate(1975)->subCenturies(2)->year); } public function testSubCenturiesNegative() { $this->assertSame(2075, Carbon::createFromDate(1975)->subCenturies(-1)->year); $this->assertSame(2175, Carbon::createFromDate(1975)->subCenturies(-2)->year); } public function testAddYearNoOverflow() { $this->assertCarbon(Carbon::createFromDate(2016, 2, 29)->addYearNoOverflow(), 2017, 2, 28); } public function testAddYearWithOverflow() { $this->assertCarbon(Carbon::createFromDate(2016, 2, 29)->addYearWithOverflow(), 2017, 3, 1); } public function testAddYearNoOverflowPassingArg() { $this->assertCarbon(Carbon::createFromDate(2016, 2, 29)->addYearsNoOverflow(2), 2018, 2, 28); } public function testAddYearWithOverflowPassingArg() { $this->assertCarbon(Carbon::createFromDate(2016, 2, 29)->addYearsWithOverflow(2), 2018, 3, 1); } public function testSubYearNoOverflowPassingArg() { $this->assertCarbon(Carbon::createFromDate(2016, 2, 29)->subYearsNoOverflow(2), 2014, 2, 28); } public function testSubYearWithOverflowPassingArg() { $this->assertCarbon(Carbon::createFromDate(2016, 2, 29)->subYearsWithOverflow(2), 2014, 3, 1); } public function testSubYearNoOverflow() { $this->assertCarbon(Carbon::createFromDate(2016, 2, 29)->subYearNoOverflow(), 2015, 2, 28); } public function testSubYearWithOverflow() { $this->assertCarbon(Carbon::createFromDate(2016, 2, 29)->subYearWithOverflow(), 2015, 3, 1); } public function testUseYearsOverflow() { $this->assertTrue(Carbon::shouldOverflowYears()); $this->assertCarbon(Carbon::createFromDate(2016, 2, 29)->addYears(2), 2018, 3, 1); Carbon::useYearsOverflow(false); $this->assertFalse(Carbon::shouldOverflowYears()); $this->assertCarbon(Carbon::createFromDate(2016, 2, 29)->addYears(2), 2018, 2, 28); Carbon::resetYearsOverflow(); $this->assertTrue(Carbon::shouldOverflowYears()); $this->assertCarbon(Carbon::createFromDate(2016, 2, 29)->addYears(2), 2018, 3, 1); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/DiffTest.php
tests/CarbonImmutable/DiffTest.php
<?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. */ namespace Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\CarbonInterface; use Carbon\CarbonInterval; use Carbon\Exceptions\InvalidFormatException; use Carbon\Exceptions\UnknownUnitException; use Closure; use DateTime; use Tests\AbstractTestCase; use TypeError; class DiffTest extends AbstractTestCase { public function wrapWithTestNow(Closure $func, ?CarbonInterface $dt = null): void { parent::wrapWithTestNow($func, $dt ?: Carbon::createMidnightDate(2012, 1, 1)); } public function testDiffAsCarbonInterval() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertCarbonInterval($dt->diff($dt->copy()->addYear()), 1, 0, 0, 0, 0, 0); $this->assertTrue($dt->diff($dt)->isEmpty()); } public function testDiffInYearsPositive() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(1.0, $dt->diffInYears($dt->copy()->addYear())); } public function testDiffInYearsNegativeWithSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(-1.0, $dt->diffInYears($dt->copy()->subYear())); } public function testDiffInYearsNegativeNoSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(1.0, $dt->diffInYears($dt->copy()->subYear(), true)); } public function testDiffInYearsVsDefaultNow() { $this->wrapWithTestNow(function () { $this->assertSame(1.0, Carbon::now()->subYear()->diffInYears()); }); } public function testDiffInYearsEnsureIsTruncated() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(1, (int) $dt->diffInYears($dt->copy()->addYear()->addMonths(7))); } public function testDiffInQuartersPositive() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(1, (int) $dt->diffInQuarters($dt->copy()->addQuarter()->addDay())); } public function testDiffInQuartersNegativeWithSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(-4, (int) $dt->diffInQuarters($dt->copy()->subQuarters(4))); } public function testDiffInQuartersNegativeWithNoSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(4, (int) $dt->diffInQuarters($dt->copy()->subQuarters(4), true)); } public function testDiffInQuartersVsDefaultNow() { $this->wrapWithTestNow(function () { $this->assertSame(4, (int) Carbon::now()->subYear()->diffInQuarters()); }); } public function testDiffInQuartersEnsureIsTruncated() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(1, (int) $dt->diffInQuarters($dt->copy()->addQuarter()->addDays(12))); } public function testDiffInMonthsPositive() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(13, (int) $dt->diffInMonths($dt->copy()->addYear()->addMonth())); } public function testDiffInMonthsNegativeWithSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(-11, (int) $dt->diffInMonths($dt->copy()->subYear()->addMonth())); } public function testDiffInMonthsNegativeNoSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(11, (int) $dt->diffInMonths($dt->copy()->subYear()->addMonth(), true)); } public function testDiffInMonthsVsDefaultNow() { $this->wrapWithTestNow(function () { $this->assertSame(12, (int) Carbon::now()->subYear()->diffInMonths()); }); } public function testDiffInMonthsEnsureIsTruncated() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(1, (int) $dt->diffInMonths($dt->copy()->addMonth()->addDays(16))); } public function testDiffInDaysPositive() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(366.0, $dt->diffInDays($dt->copy()->addYear())); } public function testDiffInDaysNegativeWithSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(-365.0, $dt->diffInDays($dt->copy()->subYear())); } public function testDiffInDaysNegativeNoSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(365.0, $dt->diffInDays($dt->copy()->subYear(), true)); } public function testDiffInDaysVsDefaultNow() { $this->wrapWithTestNow(function () { $this->assertSame(7.0, Carbon::now()->subWeek()->diffInDays()); }); } public function testDiffInDaysEnsureIsTruncated() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(1, (int) $dt->diffInDays($dt->copy()->addDay()->addHours(13))); } public function testDiffInDaysFilteredPositiveWithMutated() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(5, $dt->diffInDaysFiltered(function (Carbon $date) { return $date->dayOfWeek === 1; }, $dt->copy()->endOfMonth())); } public function testDiffInDaysFilteredPositiveWithSecondObject() { $dt1 = Carbon::createFromDate(2000, 1, 1); $dt2 = Carbon::createFromDate(2000, 1, 31); $this->assertSame(5, $dt1->diffInDaysFiltered(function (Carbon $date) { return $date->dayOfWeek === Carbon::SUNDAY; }, $dt2)); } public function testDiffInDaysFilteredNegativeNoSignWithMutated() { $dt = Carbon::createFromDate(2000, 1, 31); $this->assertSame(-5, $dt->diffInDaysFiltered(function (Carbon $date) { return $date->dayOfWeek === Carbon::SUNDAY; }, $dt->copy()->startOfMonth())); } public function testDiffInDaysFilteredNegativeNoSignWithSecondObject() { $dt1 = Carbon::createFromDate(2000, 1, 31); $dt2 = Carbon::createFromDate(2000, 1, 1); $this->assertSame(5, $dt1->diffInDaysFiltered(function (Carbon $date) { return $date->dayOfWeek === Carbon::SUNDAY; }, $dt2, true)); } public function testDiffInDaysFilteredNegativeWithSignWithMutated() { $dt = Carbon::createFromDate(2000, 1, 31); $this->assertSame(-5, $dt->diffInDaysFiltered(function (Carbon $date) { return $date->dayOfWeek === 1; }, $dt->copy()->startOfMonth())); } public function testDiffInDaysFilteredNegativeWithSignWithSecondObject() { $dt1 = Carbon::createFromDate(2000, 1, 31); $dt2 = Carbon::createFromDate(2000, 1, 1); $this->assertSame(-5, $dt1->diffInDaysFiltered(function (Carbon $date) { return $date->dayOfWeek === Carbon::SUNDAY; }, $dt2)); } public function testDiffInHoursFiltered() { $dt1 = Carbon::createFromDate(2000, 1, 31)->endOfDay(); $dt2 = Carbon::createFromDate(2000, 1, 1)->startOfDay(); $this->assertSame(-31, $dt1->diffInHoursFiltered(function (Carbon $date) { return $date->hour === 9; }, $dt2)); } public function testDiffInHoursFilteredNegative() { $dt1 = Carbon::createFromDate(2000, 1, 31)->endOfDay(); $dt2 = Carbon::createFromDate(2000, 1, 1)->startOfDay(); $this->assertSame(-31, $dt1->diffInHoursFiltered(function (Carbon $date) { return $date->hour === 9; }, $dt2)); } public function testDiffInHoursFilteredWorkHoursPerWeek() { $dt1 = Carbon::createFromDate(2000, 1, 5)->endOfDay(); $dt2 = Carbon::createFromDate(2000, 1, 1)->startOfDay(); $this->assertSame(-40, $dt1->diffInHoursFiltered(function (Carbon $date) { return $date->hour > 8 && $date->hour < 17; }, $dt2)); } public function testDiffFilteredUsingMinutesPositiveWithMutated() { $dt = Carbon::createFromDate(2000, 1, 1)->startOfDay(); $this->assertSame(60, $dt->diffFiltered(CarbonInterval::minute(), function (Carbon $date) { return $date->hour === 12; }, Carbon::createFromDate(2000, 1, 1)->endOfDay())); } public function testDiffFilteredPositiveWithSecondObject() { $dt1 = Carbon::create(2000, 1, 1); $dt2 = $dt1->copy()->addSeconds(80); $this->assertSame(40, $dt1->diffFiltered(CarbonInterval::second(), function (Carbon $date) { return $date->second % 2 === 0; }, $dt2)); } public function testDiffFilteredNegativeNoSignWithMutated() { $dt = Carbon::createFromDate(2000, 1, 31); $this->assertSame(-2, $dt->diffFiltered(CarbonInterval::days(2), function (Carbon $date) { return $date->dayOfWeek === Carbon::SUNDAY; }, $dt->copy()->startOfMonth())); } public function testDiffFilteredNegativeNoSignWithSecondObject() { $dt1 = Carbon::createFromDate(2006, 1, 31); $dt2 = Carbon::createFromDate(2000, 1, 1); $this->assertSame(-7, $dt1->diffFiltered(CarbonInterval::year(), function (Carbon $date) { return $date->month === 1; }, $dt2)); } public function testDiffFilteredNegativeWithSignWithMutated() { $dt = Carbon::createFromDate(2000, 1, 31); $this->assertSame(-4, $dt->diffFiltered(CarbonInterval::week(), function (Carbon $date) { return $date->month === 12; }, $dt->copy()->subMonths(3), false)); } public function testDiffFilteredNegativeWithSignWithSecondObject() { $dt1 = Carbon::createFromDate(2001, 1, 31); $dt2 = Carbon::createFromDate(1999, 1, 1); $this->assertSame(-12, $dt1->diffFiltered(CarbonInterval::month(), function (Carbon $date) { return $date->year === 2000; }, $dt2, false)); } public function testBug188DiffWithSameDates() { $start = Carbon::create(2014, 10, 8, 15, 20, 0); $end = $start->copy(); $this->assertSame(0.0, $start->diffInDays($end)); $this->assertSame(0, $start->diffInWeekdays($end)); } public function testBug188DiffWithDatesOnlyHoursApart() { $start = Carbon::create(2014, 10, 8, 15, 20, 0); $end = $start->copy(); $this->assertSame(0.0, $start->diffInDays($end)); $this->assertSame(0, $start->diffInWeekdays($end)); } public function testBug188DiffWithSameDates1DayApart() { $start = Carbon::create(2014, 10, 8, 15, 20, 0); $end = $start->copy()->addDay(); $this->assertSame(1.0, $start->diffInDays($end)); $this->assertSame(1, $start->diffInWeekdays($end)); } public function testBug188DiffWithDatesOnTheWeekend() { $start = Carbon::create(2014, 1, 1, 0, 0, 0); $start = $start->next(Carbon::SATURDAY); $end = $start->copy()->addDay(); $this->assertSame(1.0, $start->diffInDays($end)); $this->assertSame(0, $start->diffInWeekdays($end)); } public function testDiffInWeekdaysPositive() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(21, $dt->diffInWeekdays($dt->copy()->addMonth())); } public function testDiffInWeekdaysNegativeNoSign() { $dt = Carbon::createFromDate(2000, 1, 31); $this->assertSame(20, $dt->diffInWeekdays($dt->copy()->startOfMonth(), true)); } public function testDiffInWeekdaysNegativeWithSign() { $dt = Carbon::createFromDate(2000, 1, 31); $this->assertSame(-20, $dt->diffInWeekdays($dt->copy()->startOfMonth())); } public function testDiffInWeekendDaysPositive() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(10, $dt->diffInWeekendDays($dt->copy()->endOfMonth())); } public function testDiffInWeekendDaysNegativeNoSign() { $dt = Carbon::createFromDate(2000, 1, 31); $this->assertSame(10, $dt->diffInWeekendDays($dt->copy()->startOfMonth(), true)); } public function testDiffInWeekendDaysNegativeWithSign() { $dt = Carbon::createFromDate(2000, 1, 31); $this->assertSame(-10, $dt->diffInWeekendDays($dt->copy()->startOfMonth())); } public function testDiffInWeeksPositive() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(52, (int) $dt->diffInWeeks($dt->copy()->addYear())); } public function testDiffInWeeksNegativeWithSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(-52, (int) $dt->diffInWeeks($dt->copy()->subYear())); } public function testDiffInWeeksNegativeNoSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(52, (int) $dt->diffInWeeks($dt->copy()->subYear(), true)); } public function testDiffInWeeksVsDefaultNow() { $this->wrapWithTestNow(function () { $this->assertSame(1.0, Carbon::now()->subWeek()->diffInWeeks()); }); } public function testDiffInWeeksEnsureIsTruncated() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(0.86, round($dt->diffInWeeks($dt->copy()->addWeek()->subDay()), 2)); } public function testDiffInHoursPositive() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(26.0, $dt->diffInHours($dt->copy()->addDay()->addHours(2))); } public function testDiffInHoursNegativeWithSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(-22.0, $dt->diffInHours($dt->copy()->subDay()->addHours(2))); } public function testDiffInHoursNegativeNoSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(22.0, $dt->diffInHours($dt->copy()->subDay()->addHours(2), true)); } public function testDiffInHoursVsDefaultNow() { $this->wrapWithTestNow(function () { $this->assertSame(48.0, Carbon::now()->subDays(2)->diffInHours()); }, Carbon::create(2012, 1, 15)); } public function testDiffInHoursEnsureIsTruncated() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(1.52, round($dt->diffInHours($dt->copy()->addHour()->addMinutes(31)), 2)); } public function testDiffInHoursWithTimezones() { date_default_timezone_set('Africa/Algiers'); Carbon::setTestNow(); $dtToronto = Carbon::create(2012, 1, 1, 0, 0, 0, 'America/Toronto'); $dtVancouver = Carbon::create(2012, 1, 1, 0, 0, 0, 'America/Vancouver'); $this->assertSame(-3.0, $dtVancouver->diffInHours($dtToronto), 'Midnight in Toronto is 3 hours from midnight in Vancouver'); $dtToronto = Carbon::createFromDate(2012, 1, 1, 'America/Toronto'); usleep(2); $dtVancouver = Carbon::createFromDate(2012, 1, 1, 'America/Vancouver'); $this->assertSame(0, ((int) round($dtVancouver->diffInHours($dtToronto))) % 24); $dtToronto = Carbon::createMidnightDate(2012, 1, 1, 'America/Toronto'); $dtVancouver = Carbon::createMidnightDate(2012, 1, 1, 'America/Vancouver'); $this->assertSame(-3.0, $dtVancouver->diffInHours($dtToronto), 'Midnight in Toronto is 3 hours from midnight in Vancouver'); } public function testDiffInMinutesPositive() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(62.0, $dt->diffInMinutes($dt->copy()->addHour()->addMinutes(2))); } public function testDiffInMinutesPositiveALot() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(1502.0, $dt->diffInMinutes($dt->copy()->addHours(25)->addMinutes(2))); } public function testDiffInMinutesNegativeWithSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(-58.0, $dt->diffInMinutes($dt->copy()->subHour()->addMinutes(2))); } public function testDiffInMinutesNegativeNoSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(58.0, $dt->diffInMinutes($dt->copy()->subHour()->addMinutes(2), true)); } public function testDiffInMinutesVsDefaultNow() { $this->wrapWithTestNow(function () { $this->assertSame(60.0, Carbon::now()->subHour()->diffInMinutes()); }); } public function testDiffInMinutesEnsureIsTruncated() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(1.52, round($dt->diffInMinutes($dt->copy()->addMinute()->addSeconds(31)), 2)); } public function testDiffInSecondsPositive() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(62.0, $dt->diffInSeconds($dt->copy()->addMinute()->addSeconds(2))); } public function testDiffInSecondsPositiveALot() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(7202.0, $dt->diffInSeconds($dt->copy()->addHours(2)->addSeconds(2))); } public function testDiffInSecondsNegativeWithSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(-58.0, $dt->diffInSeconds($dt->copy()->subMinute()->addSeconds(2))); } public function testDiffInSecondsNegativeNoSign() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(58.0, $dt->diffInSeconds($dt->copy()->subMinute()->addSeconds(2), true)); } public function testDiffInSecondsVsDefaultNow() { $this->wrapWithTestNow(function () { $this->assertSame(3600.0, Carbon::now()->subHour()->diffInSeconds()); }); } public function testDiffInSecondsEnsureIsTruncated() { $dt = Carbon::createFromDate(2000, 1, 1); $this->assertSame(1.0, $dt->diffInSeconds($dt->copy()->addSeconds((int) 1.9))); } public function testDiffInSecondsWithTimezones() { $dtOttawa = Carbon::createFromDate(2000, 1, 1, 'America/Toronto'); $dtVancouver = Carbon::createFromDate(2000, 1, 1, 'America/Vancouver'); $this->assertSame(0, $dtOttawa->diffInSeconds($dtVancouver) % (24 * 3600)); $dtOttawa = Carbon::createMidnightDate(2000, 1, 1, 'America/Toronto'); $dtVancouver = Carbon::createMidnightDate(2000, 1, 1, 'America/Vancouver'); $this->assertSame(3.0 * 60 * 60, $dtOttawa->diffInSeconds($dtVancouver)); } public function testDiffInSecondsWithTimezonesAndVsDefault() { $vanNow = Carbon::now('America/Vancouver'); $hereNow = $vanNow->copy()->setTimezone(Carbon::now()->tz); $this->wrapWithTestNow(function () use ($vanNow) { $this->assertSame(0.0, $vanNow->diffInSeconds()); }, $hereNow); } public function testDiffForHumansNowAndSecond() { $this->wrapWithTestNow(function () { $this->assertSame('0 seconds ago', Carbon::now()->diffForHumans()); }); } /** * @see https://github.com/briannesbitt/Carbon/issues/2136 */ public function testDiffInTheFuture() { Carbon::setTestNow('2020-07-22 09:15'); $this->assertSame( '1 week from now', Carbon::parse('2020-07-30 13:51:15') ->diffForHumans(['options' => CarbonInterface::ROUND]), ); } public function testDiffForHumansNowAndSecondWithTimezone() { $vanNow = Carbon::now('America/Vancouver'); $hereNow = $vanNow->copy()->setTimezone(Carbon::now()->tz); $this->wrapWithTestNow(function () use ($vanNow) { $this->assertSame('0 seconds ago', $vanNow->diffForHumans()); }, $hereNow); } public function testDiffForHumansNowAndSeconds() { $this->wrapWithTestNow(function () { $this->assertSame('2 seconds ago', Carbon::now()->subSeconds(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyMinute() { $this->wrapWithTestNow(function () { $this->assertSame('59 seconds ago', Carbon::now()->subSeconds(59)->diffForHumans()); }); } public function testDiffForHumansNowAndMinute() { $this->wrapWithTestNow(function () { $this->assertSame('1 minute ago', Carbon::now()->subMinute()->diffForHumans()); }); } public function testDiffForHumansNowAndMinutes() { $this->wrapWithTestNow(function () { $this->assertSame('2 minutes ago', Carbon::now()->subMinutes(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyHour() { $this->wrapWithTestNow(function () { $this->assertSame('59 minutes ago', Carbon::now()->subMinutes(59)->diffForHumans()); }); } public function testDiffForHumansNowAndHour() { $this->wrapWithTestNow(function () { $this->assertSame('1 hour ago', Carbon::now()->subHour()->diffForHumans()); }); } public function testDiffForHumansNowAndHours() { $this->wrapWithTestNow(function () { $this->assertSame('2 hours ago', Carbon::now()->subHours(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyDay() { $this->wrapWithTestNow(function () { $this->assertSame('23 hours ago', Carbon::now()->subHours(23)->diffForHumans()); }); } public function testDiffForHumansNowAndDay() { $this->wrapWithTestNow(function () { $this->assertSame('1 day ago', Carbon::now()->subDay()->diffForHumans()); }); } public function testDiffForHumansNowAndDays() { $this->wrapWithTestNow(function () { $this->assertSame('2 days ago', Carbon::now()->subDays(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyWeek() { $this->wrapWithTestNow(function () { $this->assertSame('6 days ago', Carbon::now()->subDays(6)->diffForHumans()); }); } public function testDiffForHumansNowAndWeek() { $this->wrapWithTestNow(function () { $this->assertSame('1 week ago', Carbon::now()->subWeek()->diffForHumans()); }); } public function testDiffForHumansNowAndWeeks() { $this->wrapWithTestNow(function () { $this->assertSame('2 weeks ago', Carbon::now()->subWeeks(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyMonth() { $this->wrapWithTestNow(function () { $this->assertSame('3 weeks ago', Carbon::now()->subWeeks(3)->diffForHumans()); }); } public function testDiffForHumansNowAndMonth() { Carbon::setTestNow('2018-12-01'); $this->assertSame('4 weeks ago', Carbon::now()->subWeeks(4)->diffForHumans()); $this->assertSame('1 month ago', Carbon::now()->subMonth()->diffForHumans()); } public function testDiffForHumansNowAndMonths() { $this->wrapWithTestNow(function () { $this->assertSame('2 months ago', Carbon::now()->subMonthsNoOverflow(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyYear() { $this->wrapWithTestNow(function () { $this->assertSame('11 months ago', Carbon::now()->subMonthsNoOverflow(11)->diffForHumans()); }); } public function testDiffForHumansNowAndYear() { $this->wrapWithTestNow(function () { $this->assertSame('1 year ago', Carbon::now()->subYear()->diffForHumans()); }); } public function testDiffForHumansNowAndYears() { $this->wrapWithTestNow(function () { $this->assertSame('2 years ago', Carbon::now()->subYears(2)->diffForHumans()); }); } public function testDiffForHumansNowAndFutureSecond() { $this->wrapWithTestNow(function () { $this->assertSame('1 second from now', Carbon::now()->addSecond()->diffForHumans()); }); } public function testDiffForHumansNowAndFutureSeconds() { $this->wrapWithTestNow(function () { $this->assertSame('2 seconds from now', Carbon::now()->addSeconds(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyFutureMinute() { $this->wrapWithTestNow(function () { $this->assertSame('59 seconds from now', Carbon::now()->addSeconds(59)->diffForHumans()); }); } public function testDiffForHumansNowAndFutureMinute() { $this->wrapWithTestNow(function () { $this->assertSame('1 minute from now', Carbon::now()->addMinute()->diffForHumans()); }); } public function testDiffForHumansNowAndFutureMinutes() { $this->wrapWithTestNow(function () { $this->assertSame('2 minutes from now', Carbon::now()->addMinutes(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyFutureHour() { $this->wrapWithTestNow(function () { $this->assertSame('59 minutes from now', Carbon::now()->addMinutes(59)->diffForHumans()); }); } public function testDiffForHumansNowAndFutureHour() { $this->wrapWithTestNow(function () { $this->assertSame('1 hour from now', Carbon::now()->addHour()->diffForHumans()); }); } public function testDiffForHumansNowAndFutureHours() { $this->wrapWithTestNow(function () { $this->assertSame('2 hours from now', Carbon::now()->addHours(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyFutureDay() { $this->wrapWithTestNow(function () { $this->assertSame('23 hours from now', Carbon::now()->addHours(23)->diffForHumans()); }); } public function testDiffForHumansNowAndFutureDay() { $this->wrapWithTestNow(function () { $this->assertSame('1 day from now', Carbon::now()->addDay()->diffForHumans()); }); } public function testDiffForHumansNowAndFutureDays() { $this->wrapWithTestNow(function () { $this->assertSame('2 days from now', Carbon::now()->addDays(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyFutureWeek() { $this->wrapWithTestNow(function () { $this->assertSame('6 days from now', Carbon::now()->addDays(6)->diffForHumans()); }); } public function testDiffForHumansNowAndFutureWeek() { $this->wrapWithTestNow(function () { $this->assertSame('1 week from now', Carbon::now()->addWeek()->diffForHumans()); }); } public function testDiffForHumansNowAndFutureWeeks() { $this->wrapWithTestNow(function () { $this->assertSame('2 weeks from now', Carbon::now()->addWeeks(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyFutureMonth() { $this->wrapWithTestNow(function () { $this->assertSame('3 weeks from now', Carbon::now()->addWeeks(3)->diffForHumans()); }); } public function testDiffForHumansNowAndFutureMonth() { $this->wrapWithTestNow(function () { $this->assertSame('4 weeks from now', Carbon::now()->addWeeks(4)->diffForHumans()); $this->assertSame('1 month from now', Carbon::now()->addMonth()->diffForHumans()); }); } public function testDiffForHumansNowAndFutureMonths() { $this->wrapWithTestNow(function () { $this->assertSame('2 months from now', Carbon::now()->addMonths(2)->diffForHumans()); }); } public function testDiffForHumansNowAndNearlyFutureYear() { $this->wrapWithTestNow(function () { $this->assertSame('11 months from now', Carbon::now()->addMonths(11)->diffForHumans()); }); } public function testDiffForHumansNowAndFutureYear() { $this->wrapWithTestNow(function () { $this->assertSame('1 year from now', Carbon::now()->addYear()->diffForHumans()); }); } public function testDiffForHumansNowAndFutureYears() { $this->wrapWithTestNow(function () { $this->assertSame('2 years from now', Carbon::now()->addYears(2)->diffForHumans()); }); } public function testDiffForHumansOtherAndSecond() { $this->wrapWithTestNow(function () { $this->assertSame('1 second before', Carbon::now()->diffForHumans(Carbon::now()->addSecond())); }); } public function testDiffForHumansOtherAndSeconds() { $this->wrapWithTestNow(function () { $this->assertSame('2 seconds before', Carbon::now()->diffForHumans(Carbon::now()->addSeconds(2))); }); } public function testDiffForHumansOtherAndNearlyMinute() { $this->wrapWithTestNow(function () { $this->assertSame('59 seconds before', Carbon::now()->diffForHumans(Carbon::now()->addSeconds(59))); }); } public function testDiffForHumansOtherAndMinute() { $this->wrapWithTestNow(function () { $this->assertSame('1 minute before', Carbon::now()->diffForHumans(Carbon::now()->addMinute())); }); } public function testDiffForHumansOtherAndMinutes() { $this->wrapWithTestNow(function () { $this->assertSame('2 minutes before', Carbon::now()->diffForHumans(Carbon::now()->addMinutes(2))); }); } public function testDiffForHumansOtherAndNearlyHour() { $this->wrapWithTestNow(function () { $this->assertSame('59 minutes before', Carbon::now()->diffForHumans(Carbon::now()->addMinutes(59))); }); } public function testDiffForHumansOtherAndHour() { $this->wrapWithTestNow(function () { $this->assertSame('1 hour before', Carbon::now()->diffForHumans(Carbon::now()->addHour())); }); } public function testDiffForHumansOtherAndHours() { $this->wrapWithTestNow(function () { $this->assertSame('2 hours before', Carbon::now()->diffForHumans(Carbon::now()->addHours(2))); }); } public function testDiffForHumansOtherAndNearlyDay() { $this->wrapWithTestNow(function () { $this->assertSame('23 hours before', Carbon::now()->diffForHumans(Carbon::now()->addHours(23))); }); } public function testDiffForHumansOtherAndDay() { $this->wrapWithTestNow(function () { $this->assertSame('1 day before', Carbon::now()->diffForHumans(Carbon::now()->addDay())); }); } public function testDiffForHumansOtherAndDays() { $this->wrapWithTestNow(function () { $this->assertSame('2 days before', Carbon::now()->diffForHumans(Carbon::now()->addDays(2))); }); } public function testDiffForHumansOtherAndNearlyWeek() { $this->wrapWithTestNow(function () { $this->assertSame('6 days before', Carbon::now()->diffForHumans(Carbon::now()->addDays(6))); }); } public function testDiffForHumansOverWeekWithDefaultPartsCount() { $this->wrapWithTestNow(function () { $this->assertSame('1 week ago', Carbon::now()->subDays(8)->diffForHumans()); }); } public function testDiffForHumansOverWeekWithPartsCount1() { $this->wrapWithTestNow(function () { $this->assertSame( '1 week ago', Carbon::now()->subDays(8)->diffForHumans(null, false, false, 1) ); }); } public function testDiffForHumansOverWeekWithPartsCount2() { $this->wrapWithTestNow(function () { $this->assertSame( '1 week 1 day ago', Carbon::now()->subDays(8)->diffForHumans(null, false, false, 2) ); }); } public function testDiffForHumansOverWeekWithMicrosecondsBuggyGap() { $this->wrapWithTestNow(function () { $this->assertSame( '23 hours 59 minutes 59 seconds after', Carbon::parse('2018-12-03 12:34:45.123456') ->diffForHumans('2018-12-02 12:34:45.123476', ['parts' => 3]) ); }); } public function testDiffForHumansOtherAndWeek() { $this->wrapWithTestNow(function () {
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
true
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/MacroTest.php
tests/CarbonImmutable/MacroTest.php
<?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 Tests\CarbonImmutable; use BadMethodCallException; use Carbon\CarbonImmutable as Carbon; use CarbonTimezoneTrait; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use SubCarbonImmutable; use Tests\AbstractTestCaseWithOldNow; use Tests\Carbon\Fixtures\FooBar; use Tests\CarbonImmutable\Fixtures\Mixin; class MacroTest extends AbstractTestCaseWithOldNow { #[RequiresPhpExtension('calendar')] public function testCarbonIsMacroableWhenNotCalledDynamically() { Carbon::macro('easterDays', function ($year = 2019) { return easter_days($year); }); /** @var mixed $now */ $now = Carbon::now(); $this->assertSame(22, $now->easterDays(2020)); $this->assertSame(31, $now->easterDays()); Carbon::macro('otherParameterName', function ($other = true) { return $other; }); $this->assertTrue($now->otherParameterName()); } #[RequiresPhpExtension('calendar')] public function testCarbonIsMacroableWhenNotCalledDynamicallyUsingThis() { Carbon::macro('diffFromEaster', function ($year) { /** @var Carbon $date */ $date = $this; return $date->toDateTime()->diff( Carbon::create($year, 3, 21) ->setTimezone($date->getTimezone()) ->addDays(easter_days($year)) ->endOfDay(), ); }); /** @var mixed $now */ $now = Carbon::now(); $this->assertSame(1020, $now->diffFromEaster(2020)->days); } #[RequiresPhpExtension('calendar')] public function testCarbonIsMacroableWhenCalledStatically() { Carbon::macro('easterDate', function ($year) { return Carbon::create($year, 3, 21)->addDays(easter_days($year)); }); $this->assertSame('05/04', Carbon::easterDate(2015)->format('d/m')); } public function testCarbonIsMacroableWithNonClosureCallables() { Carbon::macro('lower2', 'strtolower'); /** @var mixed $now */ $now = Carbon::now(); $this->assertSame('abc', $now->lower2('ABC')); $this->assertSame('abc', Carbon::lower2('ABC')); } public function testCarbonIsMixinable() { include_once __DIR__.'/Fixtures/Mixin.php'; $mixin = new Mixin(); Carbon::mixin($mixin); Carbon::setUserTimezone('America/Belize'); /** @var mixed $date */ $date = Carbon::parse('2000-01-01 12:00:00', 'UTC'); $this->assertSame('06:00 America/Belize', $date->userFormat('H:i e')); } public function testCarbonRaisesExceptionWhenStaticMacroIsNotFound() { $this->expectExceptionObject(new BadMethodCallException( 'Method Carbon\CarbonImmutable::nonExistingStaticMacro does not exist.', )); Carbon::nonExistingStaticMacro(); } public function testCarbonRaisesExceptionWhenMacroIsNotFound() { $this->expectExceptionObject(new BadMethodCallException( 'Method nonExistingMacro does not exist.', )); /** @var mixed $date */ $date = Carbon::now(); $date->nonExistingMacro(); } public function testTraitMixin() { Carbon::mixin(FooBar::class); Carbon::setTestNow('2019-07-19 00:00:00'); $this->assertSame('supergirl / Friday / immutable', Carbon::super('girl')); $this->assertSame('superboy / Thursday / immutable', Carbon::parse('2019-07-18')->super('boy')); $this->assertInstanceOf(Carbon::class, Carbon::me()); } public function testTraitWithNamedParameters() { require_once __DIR__.'/../Fixtures/CarbonTimezoneTrait.php'; Carbon::mixin(CarbonTimezoneTrait::class); $now = Carbon::now(); $now = eval("return \$now->toAppTz(tz: 'Europe/Paris');"); $this->assertSame('Europe/Paris', $now->format('e')); } public function testSerializationAfterTraitChaining() { require_once __DIR__.'/../Fixtures/CarbonTimezoneTrait.php'; Carbon::mixin(CarbonTimezoneTrait::class); Carbon::setTestNow('2023-05-24 14:49'); $date = Carbon::toAppTz(false, 'Europe/Paris'); $this->assertSame('2023-05-24 16:49 Europe/Paris', unserialize(serialize($date))->format('Y-m-d H:i e')); $date = Carbon::parse('2023-06-12 11:49')->toAppTz(false, 'Europe/Paris'); $this->assertSame('2023-06-12 13:49 Europe/Paris', unserialize(serialize($date))->format('Y-m-d H:i e')); } public function testSubClassMacro() { require_once __DIR__.'/../Fixtures/SubCarbonImmutable.php'; $subCarbon = new SubCarbonImmutable('2024-01-24 00:00'); SubCarbonImmutable::macro('diffInDecades', function (SubCarbonImmutable|string|null $dt = null, $abs = true) { return (int) ($this->diffInYears($dt, $abs) / 10); }); $this->assertSame(2, $subCarbon->diffInDecades(new SubCarbonImmutable('2049-01-24 00:00'))); $this->assertSame(2, $subCarbon->diffInDecades('2049-01-24 00:00')); SubCarbonImmutable::resetMacros(); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/IsTest.php
tests/CarbonImmutable/IsTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\CarbonInterval; use Carbon\Unit; use DateInterval; use DateTime; use InvalidArgumentException; use PHPUnit\Framework\Attributes\DataProvider; use stdClass; use Tests\AbstractTestCase; use TypeError; class IsTest extends AbstractTestCase { public function testIsWeekdayTrue() { $this->assertTrue(Carbon::createFromDate(2012, 1, 2)->isWeekday()); } public function testIsWeekdayFalse() { $this->assertFalse(Carbon::createFromDate(2012, 1, 1)->isWeekday()); } public function testIsWeekendTrue() { $this->assertTrue(Carbon::createFromDate(2012, 1, 1)->isWeekend()); } public function testIsWeekendFalse() { $this->assertFalse(Carbon::createFromDate(2012, 1, 2)->isWeekend()); } public function testIsYesterdayTrue() { $this->assertTrue(Carbon::now()->subDay()->isYesterday()); } public function testIsYesterdayFalseWithToday() { $this->assertFalse(Carbon::now()->endOfDay()->isYesterday()); } public function testIsYesterdayFalseWith2Days() { $this->assertFalse(Carbon::now()->subDays(2)->startOfDay()->isYesterday()); } public function testIsTodayTrue() { $this->assertTrue(Carbon::now()->isToday()); } public function testIsCurrentWeek() { $this->assertFalse(Carbon::now()->subWeek()->isCurrentWeek()); $this->assertFalse(Carbon::now()->addWeek()->isCurrentWeek()); $this->assertTrue(Carbon::now()->isCurrentWeek()); $this->assertTrue(Carbon::now()->startOfWeek()->isCurrentWeek()); $this->assertTrue(Carbon::now()->endOfWeek()->isCurrentWeek()); } public function testIsSameWeek() { $this->assertFalse(Carbon::now()->subWeek()->isSameWeek(Carbon::now())); $this->assertFalse(Carbon::now()->addWeek()->isSameWeek(Carbon::now())); $this->assertTrue(Carbon::now()->isSameWeek(Carbon::now())); $this->assertTrue(Carbon::now()->startOfWeek()->isSameWeek(Carbon::now())); $this->assertTrue(Carbon::now()->endOfWeek()->isSameWeek(Carbon::now())); $this->assertTrue(Carbon::parse('2019-01-01')->isSameWeek(Carbon::parse('2018-12-31'))); } public function testIsNextWeekTrue() { $this->assertTrue(Carbon::now()->addWeek()->isNextWeek()); } public function testIsLastWeekTrue() { $this->assertTrue(Carbon::now()->subWeek()->isLastWeek()); } public function testIsNextWeekFalse() { /** @var mixed $date */ $date = Carbon::now(); $this->assertFalse($date->addWeek(2)->isNextWeek()); } public function testIsLastWeekFalse() { /** @var mixed $date */ $date = Carbon::now(); $this->assertFalse($date->subWeek(2)->isLastWeek()); } public function testIsNextQuarterTrue() { $this->assertTrue(Carbon::now()->addQuarterNoOverflow()->isNextQuarter()); } public function testIsLastQuarterTrue() { $this->assertTrue(Carbon::now()->subQuarterNoOverflow()->isLastQuarter()); } public function testIsNextQuarterFalse() { $this->assertFalse(Carbon::now()->addQuartersNoOverflow(2)->isNextQuarter()); $this->assertFalse(Carbon::now()->addQuartersNoOverflow(5)->isNextQuarter()); } public function testIsLastQuarterFalse() { $this->assertFalse(Carbon::now()->subQuartersNoOverflow(2)->isLastQuarter()); $this->assertFalse(Carbon::now()->subQuartersNoOverflow(5)->isLastQuarter()); } public function testIsNextMonthTrue() { $this->assertTrue(Carbon::now()->addMonthNoOverflow()->isNextMonth()); } public function testIsLastMonthTrue() { $this->assertTrue(Carbon::now()->subMonthNoOverflow()->isLastMonth()); } public function testIsNextMonthFalse() { $this->assertFalse(Carbon::now()->addMonthsNoOverflow(2)->isNextMonth()); $this->assertFalse(Carbon::now()->addMonthsNoOverflow(13)->isNextMonth()); } public function testIsLastMonthFalse() { $this->assertFalse(Carbon::now()->subMonthsNoOverflow(2)->isLastMonth()); $this->assertFalse(Carbon::now()->subMonthsNoOverflow(13)->isLastMonth()); } public function testIsNextYearTrue() { $this->assertTrue(Carbon::now()->addYear()->isNextYear()); } public function testIsLastYearTrue() { $this->assertTrue(Carbon::now()->subYear()->isLastYear()); } public function testIsNextYearFalse() { /** @var mixed $date */ $date = Carbon::now(); $this->assertFalse($date->addYear(2)->isNextYear()); } public function testIsLastYearFalse() { /** @var mixed $date */ $date = Carbon::now(); $this->assertFalse($date->subYear(2)->isLastYear()); } public function testIsTodayFalseWithYesterday() { $this->assertFalse(Carbon::now()->subDay()->endOfDay()->isToday()); } public function testIsTodayFalseWithTomorrow() { $this->assertFalse(Carbon::now()->addDay()->startOfDay()->isToday()); } public function testIsTodayWithTimezone() { $this->assertTrue(Carbon::now('Asia/Tokyo')->isToday()); } public function testIsTomorrowTrue() { $this->assertTrue(Carbon::now()->addDay()->isTomorrow()); } public function testIsTomorrowFalseWithToday() { $this->assertFalse(Carbon::now()->endOfDay()->isTomorrow()); } public function testIsTomorrowFalseWith2Days() { $this->assertFalse(Carbon::now()->addDays(2)->startOfDay()->isTomorrow()); } public function testIsFutureTrue() { $this->assertTrue(Carbon::now()->addSecond()->isFuture()); } public function testIsFutureFalse() { $this->assertFalse(Carbon::now()->isFuture()); } public function testIsFutureFalseInThePast() { $this->assertFalse(Carbon::now()->subSecond()->isFuture()); } public function testIsPastTrue() { $this->assertTrue(Carbon::now()->subSecond()->isPast()); } public function testIsPastFalse() { $this->assertFalse(Carbon::now()->addSecond()->isPast()); } public function testNowIsPastFalse() { $this->assertFalse(Carbon::now()->isPast()); } public function testIsNowOrFutureTrue() { $this->assertTrue(Carbon::now()->addSecond()->isNowOrFuture()); } public function testIsNowOrFutureFalse() { $this->assertFalse(Carbon::now()->subSecond()->isNowOrFuture()); } public function testNowIsNowOrFutureTrue() { $this->assertTrue(Carbon::now()->isNowOrFuture()); } public function testIsNowOrPastTrue() { $this->assertTrue(Carbon::now()->subSecond()->isNowOrPast()); } public function testIsNowOrPastFalse() { $this->assertFalse(Carbon::now()->addSecond()->isNowOrPast()); } public function testNowIsNowOrPastTrue() { $this->assertTrue(Carbon::now()->isNowOrPast()); } public function testIsLeapYearTrue() { $this->assertTrue(Carbon::createFromDate(2016, 1, 1)->isLeapYear()); } public function testIsLeapYearFalse() { $this->assertFalse(Carbon::createFromDate(2014, 1, 1)->isLeapYear()); } public function testIsCurrentYearTrue() { $this->assertTrue(Carbon::now()->isCurrentYear()); } public function testIsCurrentYearFalse() { $this->assertFalse(Carbon::now()->subYear()->isCurrentYear()); } public function testIsSameYearTrue() { $this->assertTrue(Carbon::now()->isSameYear(Carbon::now())); } public function testIsSameYearFalse() { $this->assertFalse(Carbon::now()->isSameYear(Carbon::now()->subYear())); } public function testIsCurrentDecadeTrue() { $this->assertTrue(Carbon::now()->isCurrentDecade()); } public function testIsCurrentDecadeFalse() { $this->assertFalse(Carbon::now()->subDecade()->isCurrentDecade()); } public function testIsSameDecadeTrue() { $this->assertTrue(Carbon::now()->isSameDecade(Carbon::now())); $this->assertTrue(Carbon::now()->isSameUnit('millennium', Carbon::now())); } public function testIsSameDecadeFalse() { $this->assertFalse(Carbon::now()->isSameDecade(Carbon::now()->subDecade())); $this->assertFalse(Carbon::now()->isSameUnit('millennium', Carbon::now()->subMillennia(2))); } public function testIsSameFoobar() { $this->expectExceptionObject(new InvalidArgumentException( 'Bad comparison unit: \'foobar\'', )); Carbon::now()->isSameUnit('foobar', Carbon::now()->subMillennium()); } public function testIsCurrentQuarterTrue() { $this->assertTrue(Carbon::now()->isCurrentQuarter()); } public function testIsCurrentQuarterFalse() { Carbon::useMonthsOverflow(false); $this->assertFalse(Carbon::now()->subQuarter()->isCurrentQuarter()); Carbon::resetMonthsOverflow(); } public function testIsSameQuarterTrue() { $this->assertTrue(Carbon::now()->isSameQuarter(Carbon::now())); } public function testIsSameQuarterTrueWithDateTime() { $this->assertTrue(Carbon::now()->isSameQuarter(new DateTime())); } public function testIsSameQuarterFalse() { Carbon::useMonthsOverflow(false); $this->assertFalse(Carbon::now()->isSameQuarter(Carbon::now()->subQuarter())); Carbon::resetMonthsOverflow(); } public function testIsSameQuarterFalseWithDateTime() { $now = Carbon::now(); $dt = new DateTime(); $dt->modify((Carbon::MONTHS_PER_QUARTER * -1).' month'); if ($dt->format('d') !== $now->format('d')) { $dt->modify('last day of previous month'); } $this->assertFalse($now->isSameQuarter($dt)); } public function testIsSameQuarterAndYearTrue() { $this->assertTrue(Carbon::now()->isSameQuarter(Carbon::now(), true)); } public function testIsSameQuarterAndYearTrueWithDateTime() { $this->assertTrue(Carbon::now()->isSameQuarter(new DateTime(), true)); } public function testIsSameQuarterAndYearFalse() { $this->assertFalse(Carbon::now()->isSameQuarter(Carbon::now()->subYear(), true)); } public function testIsSameQuarterAndYearFalseWithDateTime() { $dt = new DateTime(); $dt->modify('-1 year'); $this->assertFalse(Carbon::now()->isSameQuarter($dt, true)); } public function testIsCurrentMonth() { $this->assertTrue(Carbon::now()->isCurrentMonth()); $dt = Carbon::now(); $dt = $dt->modify(Carbon::now()->year.$dt->format('-m-').'01'); $this->assertTrue($dt->isCurrentMonth()); $dt = $dt->modify((Carbon::now()->year + 1).$dt->format('-m-').'28'); $this->assertFalse($dt->isCurrentMonth()); } public function testIsCurrentMonthFalse() { $this->assertFalse(Carbon::now()->day(15)->subMonth()->isCurrentMonth()); $this->assertFalse(Carbon::now()->day(15)->addYear()->isCurrentMonth()); } public function testIsSameMonth() { $this->assertTrue(Carbon::now()->isSameMonth(Carbon::now())); $dt = Carbon::now(); for ($year = 1990; $year < Carbon::now()->year; $year++) { $dt->modify($year.$dt->format('-m-').'01'); $this->assertTrue(Carbon::now()->isSameMonth($dt, false)); $dt->modify($year.$dt->format('-m-').'28'); $this->assertTrue(Carbon::now()->isSameMonth($dt, false)); } } public function testIsSameMonthTrueWithDateTime() { $this->assertTrue(Carbon::now()->isSameMonth(new DateTime())); $dt = new DateTime(); for ($year = 1990; $year < 2200; $year++) { $dt->modify($year.$dt->format('-m-').'01'); $this->assertTrue(Carbon::now()->isSameMonth($dt, false)); $dt->modify($year.$dt->format('-m-').'28'); $this->assertTrue(Carbon::now()->isSameMonth($dt, false)); } } public function testIsSameMonthOfSameYear() { $this->assertFalse(Carbon::now()->isSameMonth(Carbon::now()->day(15)->subMonth())); $this->assertTrue(Carbon::now()->isSameMonth(Carbon::now())); $dt = Carbon::now(); for ($year = 1990; $year < Carbon::now()->year; $year++) { $dt = $dt->modify($year.$dt->format('-m-').'01'); $this->assertFalse(Carbon::now()->isSameMonth($dt, true)); $dt = $dt->modify($year.$dt->format('-m-').'28'); $this->assertFalse(Carbon::now()->isSameMonth($dt, true)); } $year = Carbon::now()->year; $dt = $dt->modify($year.$dt->format('-m-').'01'); $this->assertTrue(Carbon::now()->isSameMonth($dt, true)); $dt = $dt->modify($year.$dt->format('-m-').'28'); $this->assertTrue(Carbon::now()->isSameMonth($dt, true)); for ($year = Carbon::now()->year + 1; $year < 2200; $year++) { $dt = $dt->modify($year.$dt->format('-m-').'01'); $this->assertFalse(Carbon::now()->isSameMonth($dt, true)); $dt = $dt->modify($year.$dt->format('-m-').'28'); $this->assertFalse(Carbon::now()->isSameMonth($dt, true)); } } public function testIsSameMonthFalseWithDateTime() { $dt = new DateTime(); $dt = $dt->modify('-2 month'); $this->assertFalse(Carbon::now()->isSameMonth($dt)); } public function testIsSameMonthAndYearTrue() { $this->assertTrue(Carbon::now()->isSameMonth(Carbon::now(), true)); $dt = Carbon::now(); $dt = $dt->modify($dt->format('Y-m-').'01'); $this->assertTrue(Carbon::now()->isSameMonth($dt, true)); $dt = $dt->modify($dt->format('Y-m-').'28'); $this->assertTrue(Carbon::now()->isSameMonth($dt, true)); } public function testIsSameMonthAndYearTrueWithDateTime() { $this->assertTrue(Carbon::now()->isSameMonth(new DateTime(), true)); $dt = new DateTime(); $dt = $dt->modify($dt->format('Y-m-').'01'); $this->assertTrue(Carbon::now()->isSameMonth($dt, true)); $dt = $dt->modify($dt->format('Y-m-').'28'); $this->assertTrue(Carbon::now()->isSameMonth($dt, true)); } public function testIsSameMonthAndYearFalse() { $this->assertFalse(Carbon::now()->isSameMonth(Carbon::now()->subYear(), true)); } public function testIsSameMonthAndYearFalseWithDateTime() { $dt = new DateTime(); $dt = $dt->modify('-1 year'); $this->assertFalse(Carbon::now()->isSameMonth($dt, true)); } public function testIsSameDayTrue() { $current = Carbon::createFromDate(2012, 1, 2); $this->assertTrue($current->isSameDay(Carbon::createFromDate(2012, 1, 2))); $this->assertTrue($current->isSameDay(Carbon::create(2012, 1, 2, 23, 59, 59))); } public function testIsSameDayWithString() { $current = Carbon::createFromDate(2012, 1, 2); $this->assertTrue($current->isSameDay('2012-01-02 15:00:25')); $this->assertTrue($current->isSameDay('2012-01-02')); } public function testIsSameDayTrueWithDateTime() { $current = Carbon::createFromDate(2012, 1, 2); $this->assertTrue($current->isSameDay(new DateTime('2012-01-02'))); $this->assertTrue($current->isSameDay(new DateTime('2012-01-02 23:59:59'))); } public function testIsSameDayFalse() { $current = Carbon::createFromDate(2012, 1, 2); $this->assertFalse($current->isSameDay(Carbon::createFromDate(2012, 1, 3))); $this->assertFalse($current->isSameDay(Carbon::createFromDate(2012, 6, 2))); } public function testIsSameDayFalseWithDateTime() { $current = Carbon::createFromDate(2012, 1, 2); $this->assertFalse($current->isSameDay(new DateTime('2012-01-03'))); $this->assertFalse($current->isSameDay(new DateTime('2012-05-02'))); } public function testIsCurrentDayTrue() { $this->assertTrue(Carbon::now()->isCurrentDay()); $this->assertTrue(Carbon::now()->hour(0)->isCurrentDay()); $this->assertTrue(Carbon::now()->hour(23)->isCurrentDay()); } public function testIsCurrentDayFalse() { $this->assertFalse(Carbon::now()->subDay()->isCurrentDay()); $this->assertFalse(Carbon::now()->subMonth()->isCurrentDay()); } public function testIsSameHourTrue() { $current = Carbon::create(2018, 5, 6, 12); $this->assertTrue($current->isSameHour(Carbon::create(2018, 5, 6, 12))); $this->assertTrue($current->isSameHour(Carbon::create(2018, 5, 6, 12, 59, 59))); } public function testIsSameHourTrueWithDateTime() { $current = Carbon::create(2018, 5, 6, 12); $this->assertTrue($current->isSameHour(new DateTime('2018-05-06T12:00:00'))); $this->assertTrue($current->isSameHour(new DateTime('2018-05-06T12:59:59'))); } public function testIsSameHourFalse() { $current = Carbon::create(2018, 5, 6, 12); $this->assertFalse($current->isSameHour(Carbon::create(2018, 5, 6, 13))); $this->assertFalse($current->isSameHour(Carbon::create(2018, 5, 5, 12))); } public function testIsSameHourFalseWithDateTime() { $current = Carbon::create(2018, 5, 6, 12); $this->assertFalse($current->isSameHour(new DateTime('2018-05-06T13:00:00'))); $this->assertFalse($current->isSameHour(new DateTime('2018-06-06T12:00:00'))); } public function testIsCurrentHourTrue() { $this->assertTrue(Carbon::now()->isCurrentHour()); $this->assertTrue(Carbon::now()->second(1)->isCurrentHour()); $this->assertTrue(Carbon::now()->second(12)->isCurrentHour()); $this->assertTrue(Carbon::now()->minute(0)->isCurrentHour()); $this->assertTrue(Carbon::now()->minute(59)->second(59)->isCurrentHour()); } public function testIsCurrentHourFalse() { $this->assertFalse(Carbon::now()->subHour()->isCurrentHour()); $this->assertFalse(Carbon::now()->subDay()->isCurrentHour()); } public function testIsSameMinuteTrue() { $current = Carbon::create(2018, 5, 6, 12, 30); $this->assertTrue($current->isSameMinute(Carbon::create(2018, 5, 6, 12, 30))); $current = Carbon::create(2018, 5, 6, 12, 30, 15); $this->assertTrue($current->isSameMinute(Carbon::create(2018, 5, 6, 12, 30, 45))); } public function testIsSameMinuteTrueWithDateTime() { $current = Carbon::create(2018, 5, 6, 12, 30); $this->assertTrue($current->isSameMinute(new DateTime('2018-05-06T12:30:00'))); $current = Carbon::create(2018, 5, 6, 12, 30, 20); $this->assertTrue($current->isSameMinute(new DateTime('2018-05-06T12:30:40'))); } public function testIsSameMinuteFalse() { $current = Carbon::create(2018, 5, 6, 12, 30); $this->assertFalse($current->isSameMinute(Carbon::create(2018, 5, 6, 13, 31))); $this->assertFalse($current->isSameMinute(Carbon::create(2019, 5, 6, 13, 30))); } public function testIsSameMinuteFalseWithDateTime() { $current = Carbon::create(2018, 5, 6, 12, 30); $this->assertFalse($current->isSameMinute(new DateTime('2018-05-06T13:31:00'))); $this->assertFalse($current->isSameMinute(new DateTime('2018-05-06T17:30:00'))); } public function testIsCurrentMinuteTrue() { $this->assertTrue(Carbon::now()->isCurrentMinute()); $this->assertTrue(Carbon::now()->second(0)->isCurrentMinute()); $this->assertTrue(Carbon::now()->second(59)->isCurrentMinute()); } public function testIsCurrentMinuteFalse() { $this->assertFalse(Carbon::now()->subMinute()->isCurrentMinute()); $this->assertFalse(Carbon::now()->subHour()->isCurrentMinute()); } public function testIsSameSecondTrue() { $current = Carbon::create(2018, 5, 6, 12, 30, 13); $other = Carbon::create(2018, 5, 6, 12, 30, 13); $this->assertTrue($current->isSameSecond($other)); $this->assertTrue($current->modify($current->hour.':'.$current->minute.':'.$current->second.'.0')->isSameSecond($other)); $this->assertTrue($current->modify($current->hour.':'.$current->minute.':'.$current->second.'.999999')->isSameSecond($other)); } public function testIsSameSecondTrueWithDateTime() { $current = Carbon::create(2018, 5, 6, 12, 30, 13); $this->assertTrue($current->isSameSecond(new DateTime('2018-05-06T12:30:13'))); } public function testIsSameSecondFalse() { $current = Carbon::create(2018, 5, 6, 12, 30, 13); $this->assertFalse($current->isSameSecond(Carbon::create(2018, 5, 6, 12, 30, 55))); $this->assertFalse($current->isSameSecond(Carbon::create(2018, 5, 6, 14, 30, 13))); } public function testIsSameSecondFalseWithDateTime() { $current = Carbon::create(2018, 5, 6, 12, 30, 13); $this->assertFalse($current->isSameSecond(new DateTime('2018-05-06T13:30:54'))); $this->assertFalse($current->isSameSecond(new DateTime('2018-05-06T13:36:13'))); } public function testIsCurrentSecondTrue() { $this->assertTrue(Carbon::now()->isCurrentSecond()); $now = Carbon::now(); $this->assertTrue($now->modify($now->hour.':'.$now->minute.':'.$now->second.'.0')->isCurrentSecond()); $this->assertTrue($now->modify($now->hour.':'.$now->minute.':'.$now->second.'.999999')->isCurrentSecond()); } public function testIsCurrentSecondFalse() { $this->assertFalse(Carbon::now()->subSecond()->isCurrentSecond()); $this->assertFalse(Carbon::now()->subDay()->isCurrentSecond()); } public function testIsSameMicrosecond() { $current = new Carbon('2018-05-06T13:30:54.123456'); $this->assertTrue($current->isSameMicrosecond(new DateTime('2018-05-06T13:30:54.123456'))); $this->assertFalse($current->isSameMicrosecond(new DateTime('2018-05-06T13:30:54.123457'))); $this->assertFalse($current->isSameMicrosecond(new DateTime('2019-05-06T13:30:54.123456'))); $this->assertFalse($current->isSameMicrosecond(new DateTime('2018-05-06T13:30:55.123456'))); $this->assertTrue($current->isSameSecond($current->copy())); $this->assertTrue(Carbon::now()->isCurrentMicrosecond()); $this->assertFalse(Carbon::now()->subMicrosecond()->isCurrentMicrosecond()); $this->assertFalse(Carbon::now()->isLastMicrosecond()); $this->assertTrue(Carbon::now()->subMicrosecond()->isLastMicrosecond()); $this->assertFalse(Carbon::now()->isNextMicrosecond()); $this->assertTrue(Carbon::now()->addMicrosecond()->isNextMicrosecond()); $this->assertTrue(Carbon::now()->subMicroseconds(Carbon::MICROSECONDS_PER_SECOND)->isLastSecond()); $this->assertSame(4.0, Carbon::now()->subMicroseconds(4 * Carbon::MICROSECONDS_PER_SECOND)->diffInSeconds(Carbon::now())); } public function testIsDayOfWeek() { // True in the past past $this->assertTrue(Carbon::createFromDate(2015, 5, 31)->isDayOfWeek(0)); $this->assertTrue(Carbon::createFromDate(2015, 6, 21)->isDayOfWeek(0)); $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::SUNDAY)->isDayOfWeek(0)); $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::SUNDAY)->isDayOfWeek('sunday')); $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::SUNDAY)->isDayOfWeek('SUNDAY')); // True in the future $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::SUNDAY)->isDayOfWeek(0)); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::SUNDAY)->isDayOfWeek(0)); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::SUNDAY)->isDayOfWeek('sunday')); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::SUNDAY)->isDayOfWeek('SUNDAY')); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::MONDAY)->isDayOfWeek('monday')); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::MONDAY)->isDayOfWeek('MONDAY')); // False in the past $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::MONDAY)->isDayOfWeek(0)); $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::MONDAY)->isDayOfWeek(0)); $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::MONDAY)->isDayOfWeek('sunday')); $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::MONDAY)->isDayOfWeek('SUNDAY')); $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::SUNDAY)->isDayOfWeek('monday')); $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::SUNDAY)->isDayOfWeek('MONDAY')); // False in the future $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::MONDAY)->isDayOfWeek(0)); $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::MONDAY)->isDayOfWeek(0)); $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::MONDAY)->isDayOfWeek('sunday')); $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::MONDAY)->isDayOfWeek('SUNDAY')); $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::SUNDAY)->isDayOfWeek('monday')); $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::SUNDAY)->isDayOfWeek('MONDAY')); } public function testIsSameAs() { $current = Carbon::createFromDate(2012, 1, 2); $this->assertTrue($current->isSameAs('c', $current)); } public function testIsSameAsWithInvalidArgument() { $this->expectException(TypeError::class); $current = Carbon::createFromDate(2012, 1, 2); $current->isSameAs('Y-m-d', new stdClass()); } public function testIsSunday() { // True in the past past $this->assertTrue(Carbon::createFromDate(2015, 5, 31)->isSunday()); $this->assertTrue(Carbon::createFromDate(2015, 6, 21)->isSunday()); $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::SUNDAY)->isSunday()); // True in the future $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::SUNDAY)->isSunday()); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::SUNDAY)->isSunday()); // False in the past $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::MONDAY)->isSunday()); $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::MONDAY)->isSunday()); // False in the future $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::MONDAY)->isSunday()); $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::MONDAY)->isSunday()); } public function testIsMonday() { // True in the past past $this->assertTrue(Carbon::createFromDate(2015, 6, 1)->isMonday()); $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::MONDAY)->isMonday()); // True in the future $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::MONDAY)->isMonday()); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::MONDAY)->isMonday()); // False in the past $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::TUESDAY)->isMonday()); $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::TUESDAY)->isMonday()); // False in the future $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::TUESDAY)->isMonday()); $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::TUESDAY)->isMonday()); } public function testIsTuesday() { // True in the past past $this->assertTrue(Carbon::createFromDate(2015, 6, 2)->isTuesday()); $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::TUESDAY)->isTuesday()); // True in the future $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::TUESDAY)->isTuesday()); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::TUESDAY)->isTuesday()); // False in the past $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::WEDNESDAY)->isTuesday()); $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::WEDNESDAY)->isTuesday()); // False in the future $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::WEDNESDAY)->isTuesday()); $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::WEDNESDAY)->isTuesday()); } public function testIsWednesday() { // True in the past past $this->assertTrue(Carbon::createFromDate(2015, 6, 3)->isWednesday()); $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::WEDNESDAY)->isWednesday()); // True in the future $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::WEDNESDAY)->isWednesday()); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::WEDNESDAY)->isWednesday()); // False in the past $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::THURSDAY)->isWednesday()); $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::THURSDAY)->isWednesday()); // False in the future $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::THURSDAY)->isWednesday()); $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::THURSDAY)->isWednesday()); } public function testIsThursday() { // True in the past past $this->assertTrue(Carbon::createFromDate(2015, 6, 4)->isThursday()); $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::THURSDAY)->isThursday()); // True in the future $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::THURSDAY)->isThursday()); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::THURSDAY)->isThursday()); // False in the past $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::FRIDAY)->isThursday()); $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::FRIDAY)->isThursday()); // False in the future $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::FRIDAY)->isThursday()); $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::FRIDAY)->isThursday()); } public function testIsFriday() { // True in the past past $this->assertTrue(Carbon::createFromDate(2015, 6, 5)->isFriday()); $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::FRIDAY)->isFriday()); // True in the future $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::FRIDAY)->isFriday()); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::FRIDAY)->isFriday()); // False in the past $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::SATURDAY)->isFriday()); $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::SATURDAY)->isFriday()); // False in the future $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::SATURDAY)->isFriday()); $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::SATURDAY)->isFriday()); } public function testIsSaturday() { // True in the past past $this->assertTrue(Carbon::createFromDate(2015, 6, 6)->isSaturday()); $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::SATURDAY)->isSaturday()); // True in the future $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::SATURDAY)->isSaturday()); $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::SATURDAY)->isSaturday()); // False in the past $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::SUNDAY)->isSaturday());
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
true
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/StartEndOfTest.php
tests/CarbonImmutable/StartEndOfTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use PHPUnit\Framework\Attributes\TestWith; use Tests\AbstractTestCase; class StartEndOfTest extends AbstractTestCase { public function testStartOfDay() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt2 = $dt->startOfDay()); $this->assertCarbon($dt2, $dt->year, $dt->month, $dt->day, 0, 0, 0, 0); } public function testEndOfDay() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt2 = $dt->endOfDay()); $this->assertCarbon($dt2, $dt->year, $dt->month, $dt->day, 23, 59, 59, 999999); } public function testStartOfMonthIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->startOfMonth()); } public function testStartOfMonthFromNow() { $dt = Carbon::now()->startOfMonth(); $this->assertCarbon($dt, $dt->year, $dt->month, 1, 0, 0, 0); } public function testStartOfMonthFromLastDay() { $dt = Carbon::create(2000, 1, 31, 2, 3, 4)->startOfMonth(); $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); } public function testStartOfYearIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->startOfYear()); } public function testStartOfYearFromNow() { $dt = Carbon::now()->startOfYear(); $this->assertCarbon($dt, $dt->year, 1, 1, 0, 0, 0); } public function testStartOfYearFromFirstDay() { $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->startOfYear(); $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); } public function testStartOfYearFromLastDay() { $dt = Carbon::create(2000, 12, 31, 23, 59, 59)->startOfYear(); $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); } public function testEndOfMonthIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->endOfMonth()); } public function testEndOfMonth() { $dt = Carbon::create(2000, 1, 1, 2, 3, 4)->endOfMonth(); $this->assertCarbon($dt, 2000, 1, 31, 23, 59, 59); } public function testEndOfMonthFromLastDay() { $dt = Carbon::create(2000, 1, 31, 2, 3, 4)->endOfMonth(); $this->assertCarbon($dt, 2000, 1, 31, 23, 59, 59); } public function testEndOfYearIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->endOfYear()); } public function testEndOfYearFromNow() { $dt = Carbon::now()->endOfYear(); $this->assertCarbon($dt, $dt->year, 12, 31, 23, 59, 59); } public function testEndOfYearFromFirstDay() { $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->endOfYear(); $this->assertCarbon($dt, 2000, 12, 31, 23, 59, 59); } public function testEndOfYearFromLastDay() { $dt = Carbon::create(2000, 12, 31, 23, 59, 59)->endOfYear(); $this->assertCarbon($dt, 2000, 12, 31, 23, 59, 59); } public function testStartOfDecadeIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->startOfDecade()); } public function testStartOfDecadeFromNow() { $dt = Carbon::now()->startOfDecade(); $this->assertCarbon($dt, $dt->year - $dt->year % 10, 1, 1, 0, 0, 0); } public function testStartOfDecadeFromFirstDay() { $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->startOfDecade(); $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); } public function testStartOfDecadeFromLastDay() { $dt = Carbon::create(2009, 12, 31, 23, 59, 59)->startOfDecade(); $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); } public function testEndOfDecadeIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->endOfDecade()); } public function testEndOfDecadeFromNow() { $dt = Carbon::now()->endOfDecade(); $this->assertCarbon($dt, $dt->year - $dt->year % 10 + 9, 12, 31, 23, 59, 59); } public function testEndOfDecadeFromFirstDay() { $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->endOfDecade(); $this->assertCarbon($dt, 2009, 12, 31, 23, 59, 59); } public function testEndOfDecadeFromLastDay() { $dt = Carbon::create(2009, 12, 31, 23, 59, 59)->endOfDecade(); $this->assertCarbon($dt, 2009, 12, 31, 23, 59, 59); } public function testStartOfCenturyIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->startOfCentury()); } public function testStartOfCenturyFromNow() { $now = Carbon::now(); $dt = Carbon::now()->startOfCentury(); $this->assertCarbon($dt, $now->year - $now->year % 100 + 1, 1, 1, 0, 0, 0); } public function testStartOfCenturyFromFirstDay() { $dt = Carbon::create(2001, 1, 1, 1, 1, 1)->startOfCentury(); $this->assertCarbon($dt, 2001, 1, 1, 0, 0, 0); } public function testStartOfCenturyFromLastDay() { $dt = Carbon::create(2100, 12, 31, 23, 59, 59)->startOfCentury(); $this->assertCarbon($dt, 2001, 1, 1, 0, 0, 0); } public function testStartOfMillenniumIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->startOfMillennium()); } public function testStartOfMillenniumFromNow() { $now = Carbon::now(); $dt = Carbon::now()->startOfMillennium(); $this->assertCarbon($dt, $now->year - $now->year % 1000 + 1, 1, 1, 0, 0, 0); } public function testStartOfMillenniumFromFirstDay() { $dt = Carbon::create(2001, 1, 1, 1, 1, 1)->startOfMillennium(); $this->assertCarbon($dt, 2001, 1, 1, 0, 0, 0); } public function testStartOfMillenniumFromLastDay() { $dt = Carbon::create(3000, 12, 31, 23, 59, 59)->startOfMillennium(); $this->assertCarbon($dt, 2001, 1, 1, 0, 0, 0); } public function testStartOfHourIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->startOfHour()); } public function testStartOfHourFromNow() { $now = Carbon::now(); $dt = Carbon::now()->startOfHour(); $this->assertCarbon($dt, $now->year, $now->month, $now->day, $now->hour, 0, 0); } public function testStartOfHourFromFirstMinute() { $dt = Carbon::create(2001, 1, 1, 1, 1, 1)->startOfHour(); $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, $dt->hour, 0, 0); } public function testStartOfHourFromLastMinute() { $dt = Carbon::create(2100, 12, 31, 23, 59, 59)->startOfHour(); $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, $dt->hour, 0, 0); } public function testEndOfHourIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->endOfHour()); } public function testEndOfHourFromNow() { $now = Carbon::now(); $dt = Carbon::now()->endOfHour(); $this->assertCarbon($dt, $now->year, $now->month, $now->day, $now->hour, 59, 59); } public function testEndOfHourFromFirstMinute() { $dt = Carbon::create(2001, 1, 1, 1, 1, rand(0, 59))->endOfHour(); $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, $dt->hour, 59, 59); } public function testEndOfHourFromLastMinute() { $dt = Carbon::create(2100, 12, 31, 23, 59, rand(0, 59))->endOfHour(); $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, $dt->hour, 59, 59); } public function testStartOfMinuteIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->startOfMinute()); } public function testStartOfMinuteFromNow() { $now = Carbon::now(); $dt = Carbon::now()->startOfMinute(); $this->assertCarbon($dt, $now->year, $now->month, $now->day, $now->hour, $now->minute, 0); } public function testStartOfMinuteFromFirstSecond() { $dt = Carbon::create(2001, 1, 1, 1, 1, 1)->startOfMinute(); $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, $dt->hour, $dt->minute, 0); } public function testStartOfMinuteFromLastSecond() { $dt = Carbon::create(2100, 12, 31, 23, 59, 59)->startOfMinute(); $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, $dt->hour, $dt->minute, 0); } public function testEndOfMinuteIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->endOfMinute()); } public function testEndOfMinuteFromNow() { $now = Carbon::now(); $dt = Carbon::now()->endOfMinute(); $this->assertCarbon($dt, $now->year, $now->month, $now->day, $now->hour, $now->minute, 59); } public function testEndOfMinuteFromFirstSecond() { $dt = Carbon::create(2001, 1, 1, 1, 1, 1)->endOfMinute(); $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, $dt->hour, $dt->minute, 59); } public function testEndOfMinuteFromLastSecond() { $dt = Carbon::create(2100, 12, 31, 23, 59, 59)->endOfHour(); $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, $dt->hour, $dt->minute, 59); } public function testMidDayIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->midDay()); } public function testMidDayFromNow() { $now = Carbon::now(); $dt = Carbon::now()->midDay(); $this->assertCarbon($dt, $now->year, $now->month, $now->day, 12, 0, 0); } public function testEndOfCenturyIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->endOfCentury()); } public function testEndOfCenturyFromNow() { $now = Carbon::now(); $dt = Carbon::now()->endOfCentury(); $this->assertCarbon($dt, $now->year - $now->year % 100 + 100, 12, 31, 23, 59, 59); } public function testEndOfCenturyFromFirstDay() { $dt = Carbon::create(2001, 1, 1, 1, 1, 1)->endOfCentury(); $this->assertCarbon($dt, 2100, 12, 31, 23, 59, 59); } public function testEndOfCenturyFromLastDay() { $dt = Carbon::create(2100, 12, 31, 23, 59, 59)->endOfCentury(); $this->assertCarbon($dt, 2100, 12, 31, 23, 59, 59); } public function testStartOfQuarterIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->startOfQuarter()); } #[TestWith([1, 1])] #[TestWith([2, 1])] #[TestWith([3, 1])] #[TestWith([4, 4])] #[TestWith([5, 4])] #[TestWith([6, 4])] #[TestWith([7, 7])] #[TestWith([8, 7])] #[TestWith([9, 7])] #[TestWith([10, 10])] #[TestWith([11, 10])] #[TestWith([12, 10])] public function testStartOfQuarter(int $month, int $startOfQuarterMonth) { $dt = Carbon::create(2015, $month, 15, 1, 2, 3); $this->assertCarbon($dt->startOfQuarter(), 2015, $startOfQuarterMonth, 1, 0, 0, 0); } public function testEndOfQuarterIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->endOfQuarter()); } #[TestWith([1, 3, 31])] #[TestWith([2, 3, 31])] #[TestWith([3, 3, 31])] #[TestWith([4, 6, 30])] #[TestWith([5, 6, 30])] #[TestWith([6, 6, 30])] #[TestWith([7, 9, 30])] #[TestWith([8, 9, 30])] #[TestWith([9, 9, 30])] #[TestWith([10, 12, 31])] #[TestWith([11, 12, 31])] #[TestWith([12, 12, 31])] public function testEndOfQuarter(int $month, int $endOfQuarterMonth, int $endOfQuarterDay) { $dt = Carbon::create(2015, $month, 15, 1, 2, 3); $this->assertCarbon($dt->endOfQuarter(), 2015, $endOfQuarterMonth, $endOfQuarterDay, 23, 59, 59); } public function testAverageIsFluid() { $dt = Carbon::now()->average(); $this->assertInstanceOfCarbon($dt); } public function testAverageFromSame() { $dt1 = Carbon::create(2000, 1, 31, 2, 3, 4); $dt2 = Carbon::create(2000, 1, 31, 2, 3, 4)->average($dt1); $this->assertCarbon($dt2, 2000, 1, 31, 2, 3, 4); } public function testAverageFromGreater() { $dt1 = Carbon::create(2000, 1, 1, 1, 1, 1); $dt2 = Carbon::create(2009, 12, 31, 23, 59, 59)->average($dt1); $this->assertCarbon($dt2, 2004, 12, 31, 12, 30, 30); } public function testAverageFromLower() { $dt1 = Carbon::create(2009, 12, 31, 23, 59, 59); $dt2 = Carbon::create(2000, 1, 1, 1, 1, 1)->average($dt1); $this->assertCarbon($dt2, 2004, 12, 31, 12, 30, 30); } public function testAverageWithCloseDates() { $dt1 = Carbon::parse('2004-01-24 09:46:56.500000'); $dt2 = Carbon::parse('2004-01-24 09:46:56.600000'); $this->assertSame('2004-01-24 09:46:56.550000', $dt1->average($dt2)->format('Y-m-d H:i:s.u')); } public function testAverageWithFarDates() { $dt1 = Carbon::parse('-2018-05-07 12:34:46.500000', 'UTC'); $dt2 = Carbon::parse('6025-10-11 20:59:06.600000', 'UTC'); $this->assertSame('2004-01-24 04:46:56.550000', $dt1->average($dt2)->format('Y-m-d H:i:s.u')); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/IssetTest.php
tests/CarbonImmutable/IssetTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Generator; use PHPUnit\Framework\Attributes\DataProvider; use Tests\AbstractTestCase; class IssetTest extends AbstractTestCase { public function testIssetReturnFalseForUnknownProperty(): void { $this->assertFalse(isset($this->immutableNow->sdfsdfss)); } public static function dataForTestIssetReturnTrueForProperties(): Generator { yield ['age']; yield ['century']; yield ['day']; yield ['dayName']; yield ['dayOfWeek']; yield ['dayOfWeekIso']; yield ['dayOfYear']; yield ['daysInMonth']; yield ['daysInYear']; yield ['decade']; yield ['dst']; yield ['englishDayOfWeek']; yield ['englishMonth']; yield ['firstWeekDay']; yield ['hour']; yield ['isoWeek']; yield ['isoWeekYear']; yield ['isoWeeksInYear']; yield ['lastWeekDay']; yield ['latinMeridiem']; yield ['latinUpperMeridiem']; yield ['local']; yield ['locale']; yield ['localeDayOfWeek']; yield ['localeMonth']; yield ['meridiem']; yield ['micro']; yield ['microsecond']; yield ['millennium']; yield ['milli']; yield ['millisecond']; yield ['milliseconds']; yield ['minDayName']; yield ['minute']; yield ['month']; yield ['monthName']; yield ['noZeroHour']; yield ['offset']; yield ['offsetHours']; yield ['offsetMinutes']; yield ['quarter']; yield ['second']; yield ['shortDayName']; yield ['shortEnglishDayOfWeek']; yield ['shortEnglishMonth']; yield ['shortLocaleDayOfWeek']; yield ['shortLocaleMonth']; yield ['shortMonthName']; yield ['timestamp']; yield ['timezone']; yield ['timezoneAbbreviatedName']; yield ['timezoneName']; yield ['tz']; yield ['tzAbbrName']; yield ['tzName']; yield ['upperMeridiem']; yield ['utc']; yield ['week']; yield ['weekNumberInMonth']; yield ['weekOfMonth']; yield ['weekOfYear']; yield ['weekYear']; yield ['weeksInYear']; yield ['year']; yield ['yearIso']; } #[DataProvider('dataForTestIssetReturnTrueForProperties')] public function testIssetReturnTrueForProperties(string $property): void { Carbon::useStrictMode(false); $this->assertTrue(isset($this->immutableNow->{$property})); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/RelativeTest.php
tests/CarbonImmutable/RelativeTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Tests\AbstractTestCase; class RelativeTest extends AbstractTestCase { public function testSecondsSinceMidnight() { $d = Carbon::today()->addSeconds(30); $this->assertSame(30.0, $d->secondsSinceMidnight()); $d = Carbon::today()->addDays(1); $this->assertSame(0.0, $d->secondsSinceMidnight()); $d = Carbon::today()->addDays(1)->addSeconds(120); $this->assertSame(120.0, $d->secondsSinceMidnight()); $d = Carbon::today()->addMonths(3)->addSeconds(42); $this->assertSame(42.0, $d->secondsSinceMidnight()); } public function testSecondsUntilEndOfDay() { $d = Carbon::today()->endOfDay(); $this->assertSame(0.0, $d->secondsUntilEndOfDay()); $d = Carbon::today()->endOfDay()->subSeconds(60); $this->assertSame(60.0, $d->secondsUntilEndOfDay()); $d = Carbon::create(2014, 10, 24, 12, 34, 56); $this->assertVeryClose(41103.999999, $d->secondsUntilEndOfDay()); $d = Carbon::create(2014, 10, 24, 0, 0, 0); $this->assertVeryClose(86399.99999899999, $d->secondsUntilEndOfDay()); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/RoundTest.php
tests/CarbonImmutable/RoundTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use InvalidArgumentException; use Tests\AbstractTestCase; class RoundTest extends AbstractTestCase { public function testRoundWithDefaultUnit() { $dt = Carbon::create(2315, 7, 18, 22, 42, 17.643971); $copy = $dt->copy(); $ref = $copy->round(); $this->assertNotEquals($ref, $copy); $this->assertNotSame($ref, $copy); $this->assertCarbon($ref, 2315, 7, 18, 22, 42, 18, 0); $this->assertCarbon($dt->copy()->round(5), 2315, 7, 18, 22, 42, 20, 0); $this->assertCarbon($dt->copy()->floor()->round(5), 2315, 7, 18, 22, 42, 15, 0); $this->assertCarbon($dt->copy()->round(3), 2315, 7, 18, 22, 42, 18, 0); $this->assertCarbon($dt->copy()->round(4), 2315, 7, 18, 22, 42, 16, 0); $this->assertCarbon($dt->copy()->round(10), 2315, 7, 18, 22, 42, 20, 0); $this->assertCarbon($dt->copy()->round(0.5), 2315, 7, 18, 22, 42, 17, 500000); $this->assertCarbon($dt->copy()->round(0.25), 2315, 7, 18, 22, 42, 17, 750000); $this->assertCarbon($dt->copy()->round(3.8), 2315, 7, 18, 22, 42, 19, 800000); $this->assertCarbon($dt->copy()->floor(5), 2315, 7, 18, 22, 42, 15, 0); $this->assertCarbon($dt->copy()->floor()->floor(5), 2315, 7, 18, 22, 42, 15, 0); $this->assertCarbon($dt->copy()->floor(3), 2315, 7, 18, 22, 42, 15, 0); $this->assertCarbon($dt->copy()->floor(4), 2315, 7, 18, 22, 42, 16, 0); $this->assertCarbon($dt->copy()->floor(10), 2315, 7, 18, 22, 42, 10, 0); $this->assertCarbon($dt->copy()->floor(0.5), 2315, 7, 18, 22, 42, 17, 500000); $this->assertCarbon($dt->copy()->floor(0.25), 2315, 7, 18, 22, 42, 17, 500000); $this->assertCarbon($dt->copy()->floor(3.8), 2315, 7, 18, 22, 42, 15, 0); $this->assertCarbon($dt->copy()->ceil(5), 2315, 7, 18, 22, 42, 20, 0); $this->assertCarbon($dt->copy()->floor()->ceil(5), 2315, 7, 18, 22, 42, 20, 0); $this->assertCarbon($dt->copy()->ceil(3), 2315, 7, 18, 22, 42, 18, 0); $this->assertCarbon($dt->copy()->ceil(4), 2315, 7, 18, 22, 42, 20, 0); $this->assertCarbon($dt->copy()->ceil(10), 2315, 7, 18, 22, 42, 20, 0); $this->assertCarbon($dt->copy()->ceil(0.5), 2315, 7, 18, 22, 42, 18, 0); $this->assertCarbon($dt->copy()->ceil(0.25), 2315, 7, 18, 22, 42, 17, 750000); $this->assertCarbon($dt->copy()->ceil(3.8), 2315, 7, 18, 22, 42, 19, 800000); } public function testRoundWithBaseUnit() { $dt = Carbon::create(2315, 7, 18, 22, 42, 17.643971); $copy = $dt->copy(); $ref = $copy->roundSecond(); $this->assertNotEquals($ref, $copy); $this->assertNotSame($ref, $copy); $this->assertCarbon($ref, 2315, 7, 18, 22, 42, 18, 0); $this->assertCarbon($dt->copy()->roundDay(), 2315, 7, 19, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->roundDay(5), 2315, 7, 21, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->ceilDay(), 2315, 7, 19, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->floorDay(), 2315, 7, 18, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->roundYear(), 2316, 1, 1, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->subMonths(2)->roundYear(), 2315, 1, 1, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->roundYear(2), 2315, 1, 1, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->floorYear(2), 2315, 1, 1, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->ceilYear(2), 2317, 1, 1, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->roundMonth(), 2315, 8, 1, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->floorMonth(), 2315, 7, 1, 0, 0, 0, 0); } public function testRoundWithMetaUnit() { $dt = Carbon::create(2315, 7, 18, 22, 42, 17.643971); $copy = $dt->copy(); $ref = $copy->roundSecond(); $this->assertNotEquals($ref, $copy); $this->assertNotSame($ref, $copy); $this->assertCarbon($ref, 2315, 7, 18, 22, 42, 18, 0); $this->assertCarbon($dt->copy()->roundMillisecond(), 2315, 7, 18, 22, 42, 17, 644000); $this->assertCarbon($dt->copy()->roundMillennium(), 2001, 1, 1, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->roundQuarter(), 2315, 7, 1, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->roundQuarters(2), 2315, 7, 1, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->subMonth()->floorQuarter(), 2315, 4, 1, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->subMonth()->floorQuarters(2), 2315, 1, 1, 0, 0, 0, 0); } public function testRoundWeek() { $dt = Carbon::create(2315, 7, 18, 22, 42, 17.643971); $copy = $dt->copy(); $ref = $copy->roundSecond(); $this->assertNotEquals($ref, $copy); $this->assertNotSame($ref, $copy); $this->assertCarbon($ref, 2315, 7, 18, 22, 42, 18, 0); $this->assertCarbon($dt->copy()->floorWeek(), 2315, 7, 12, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->ceilWeek(), 2315, 7, 19, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->roundWeek(), 2315, 7, 19, 0, 0, 0, 0); $dt = Carbon::create(2315, 7, 19, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->floorWeek(), 2315, 7, 19, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->ceilWeek(), 2315, 7, 19, 0, 0, 0, 0); $this->assertCarbon($dt->copy()->roundWeek(), 2315, 7, 19, 0, 0, 0, 0); } public function testCeilMonth() { $this->assertCarbon(Carbon::parse('2021-01-29')->ceilMonth(), 2021, 2, 1, 0, 0, 0); $this->assertCarbon(Carbon::parse('2021-01-31')->ceilMonth(), 2021, 2, 1, 0, 0, 0); $this->assertCarbon(Carbon::parse('2021-12-17')->ceilMonth(), 2022, 1, 1, 0, 0, 0); } public function testFloorMonth() { $this->assertCarbon(Carbon::parse('2021-05-31')->floorMonth(3), 2021, 4, 1, 0, 0, 0); } public function testRoundInvalidArgument() { $this->expectExceptionObject(new InvalidArgumentException( 'Unknown unit \'foobar\'.', )); Carbon::now()->roundUnit('foobar'); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/AddMonthsTest.php
tests/CarbonImmutable/AddMonthsTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use PHPUnit\Framework\Attributes\DataProvider; use Tests\AbstractTestCase; class AddMonthsTest extends AbstractTestCase { private ?Carbon $carbon = null; protected function setUp(): void { parent::setUp(); /** @var Carbon $date */ $date = Carbon::create(2016, 1, 31); $this->carbon = $date; } public static function dataForTestAddMonthNoOverflow() { return [ [-2, 2015, 11, 30], [-1, 2015, 12, 31], [0, 2016, 1, 31], [1, 2016, 2, 29], [2, 2016, 3, 31], ]; } #[DataProvider('dataForTestAddMonthNoOverflow')] public function testAddMonthNoOverflow(int $months, int $y, int $m, int $d) { $this->assertCarbon($this->carbon->addMonthNoOverflow($months), $y, $m, $d); } #[DataProvider('dataForTestAddMonthNoOverflow')] public function testAddMonthsNoOverflow(int $months, int $y, int $m, int $d) { $this->assertCarbon($this->carbon->addMonthsNoOverflow($months), $y, $m, $d); } public static function dataForTestSubMonthNoOverflow(): array { return [ [-2, 2016, 3, 31], [-1, 2016, 2, 29], [0, 2016, 1, 31], [1, 2015, 12, 31], [2, 2015, 11, 30], ]; } #[DataProvider('dataForTestSubMonthNoOverflow')] public function testSubMonthNoOverflow(int $months, int $y, int $m, int $d) { $this->assertCarbon($this->carbon->subMonthNoOverflow($months), $y, $m, $d); } #[DataProvider('dataForTestSubMonthNoOverflow')] public function testSubMonthsNoOverflow(int $months, int $y, int $m, int $d) { $this->assertCarbon($this->carbon->subMonthsNoOverflow($months), $y, $m, $d); } public static function dataForTestAddMonthWithOverflow(): array { return [ [-2, 2015, 12, 1], [-1, 2015, 12, 31], [0, 2016, 1, 31], [1, 2016, 3, 2], [2, 2016, 3, 31], ]; } #[DataProvider('dataForTestAddMonthWithOverflow')] public function testAddMonthWithOverflow(int $months, int $y, int $m, int $d) { $this->assertCarbon($this->carbon->addMonthWithOverflow($months), $y, $m, $d); } #[DataProvider('dataForTestAddMonthWithOverflow')] public function testAddMonthsWithOverflow(int $months, int $y, int $m, int $d) { $this->assertCarbon($this->carbon->addMonthsWithOverflow($months), $y, $m, $d); } public static function dataForTestSubMonthWithOverflow(): array { return [ [-2, 2016, 3, 31], [-1, 2016, 3, 2], [0, 2016, 1, 31], [1, 2015, 12, 31], [2, 2015, 12, 1], ]; } #[DataProvider('dataForTestSubMonthWithOverflow')] public function testSubMonthWithOverflow(int $months, int $y, int $m, int $d) { $this->assertCarbon($this->carbon->subMonthWithOverflow($months), $y, $m, $d); } #[DataProvider('dataForTestSubMonthWithOverflow')] public function testSubMonthsWithOverflow(int $months, int $y, int $m, int $d) { $this->assertCarbon($this->carbon->subMonthsWithOverflow($months), $y, $m, $d); } public function testSetOverflowIsTrue() { Carbon::useMonthsOverflow(true); $this->assertTrue(Carbon::shouldOverflowMonths()); } public function testSetOverflowIsFalse() { Carbon::useMonthsOverflow(false); $this->assertFalse(Carbon::shouldOverflowMonths()); } public function testSetOverflowIsResetInTests() { $this->assertTrue(Carbon::shouldOverflowMonths()); } public function testSetOverflowIsReset() { Carbon::useMonthsOverflow(false); $this->assertFalse(Carbon::shouldOverflowMonths()); Carbon::resetMonthsOverflow(); $this->assertTrue(Carbon::shouldOverflowMonths()); } #[DataProvider('dataForTestAddMonthWithOverflow')] public function testUseOverflowAddMonth(int $months, int $y, int $m, int $d) { Carbon::useMonthsOverflow(true); $this->assertCarbon($this->carbon->addMonth($months), $y, $m, $d); } #[DataProvider('dataForTestAddMonthWithOverflow')] public function testUseOverflowAddMonths(int $months, int $y, int $m, int $d) { Carbon::useMonthsOverflow(true); $this->assertCarbon($this->carbon->addMonths($months), $y, $m, $d); } #[DataProvider('dataForTestSubMonthWithOverflow')] public function testUseOverflowSubMonth(int $months, int $y, int $m, int $d) { Carbon::useMonthsOverflow(true); $this->assertCarbon($this->carbon->subMonth($months), $y, $m, $d); } #[DataProvider('dataForTestSubMonthWithOverflow')] public function testUseOverflowSubMonths(int $months, int $y, int $m, int $d) { Carbon::useMonthsOverflow(true); $this->assertCarbon($this->carbon->subMonths($months), $y, $m, $d); } #[DataProvider('dataForTestAddMonthNoOverflow')] public function testSkipOverflowAddMonth(int $months, int $y, int $m, int $d) { Carbon::useMonthsOverflow(false); $this->assertCarbon($this->carbon->addMonth($months), $y, $m, $d); } #[DataProvider('dataForTestAddMonthNoOverflow')] public function testSkipOverflowAddMonths(int $months, int $y, int $m, int $d) { Carbon::useMonthsOverflow(false); $this->assertCarbon($this->carbon->addMonths($months), $y, $m, $d); } #[DataProvider('dataForTestSubMonthNoOverflow')] public function testSkipOverflowSubMonth(int $months, int $y, int $m, int $d) { Carbon::useMonthsOverflow(false); $this->assertCarbon($this->carbon->subMonth($months), $y, $m, $d); } #[DataProvider('dataForTestSubMonthNoOverflow')] public function testSkipOverflowSubMonths(int $months, int $y, int $m, int $d) { Carbon::useMonthsOverflow(false); $this->assertCarbon($this->carbon->subMonths($months), $y, $m, $d); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/ModifyNearDSTChangeTest.php
tests/CarbonImmutable/ModifyNearDSTChangeTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Generator; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Tests\AbstractTestCase; class ModifyNearDSTChangeTest extends AbstractTestCase { /** * Tests transition through DST change hour in non default timezone. */ #[Group('dst')] #[DataProvider('dataForTransitionTests')] public function testTransitionInNonDefaultTimezone(string $dateString, int $addHours, string $expected): void { date_default_timezone_set('Europe/london'); $date = Carbon::parse($dateString, 'America/New_York'); $date = $date->addHours($addHours); $this->assertSame($expected, $date->format('c')); } /** * Tests transition through DST change hour in default timezone. */ #[Group('dst')] #[DataProvider('dataForTransitionTests')] public function testTransitionInDefaultTimezone(string $dateString, int $addHours, string $expected): void { date_default_timezone_set('America/New_York'); $date = Carbon::parse($dateString, 'America/New_York'); $date = $date->addHours($addHours); $this->assertSame($expected, $date->format('c')); } public static function dataForTransitionTests(): Generator { // arguments: // - Date string to Carbon::parse in America/New_York. // - Hours to add // - Resulting string in 'c' format // testForwardTransition // When standard time was about to reach 2010-03-14T02:00:00-05:00 clocks were turned forward 1 hour to // 2010-03-14T03:00:00-04:00 local daylight time instead yield [ '2010-03-14T00:00:00', 24, '2010-03-15T01:00:00-04:00', ]; // testBackwardTransition // When local daylight time was about to reach 2010-11-07T02:00:00-04:00 clocks were turned backward 1 hour // to 2010-11-07T01:00:00-05:00 local standard time instead yield ['2010-11-07T00:00:00', 24, '2010-11-07T23:00:00-05:00']; } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/ModifyTest.php
tests/CarbonImmutable/ModifyTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Tests\AbstractTestCase; class ModifyTest extends AbstractTestCase { public function testSimpleModify() { $a = new Carbon('2014-03-30 00:00:00'); $b = $a->addHours(24); $this->assertSame(24.0, $a->diffInHours($b)); } public function testSimpleModifyWithNamedParameter() { $a = new Carbon('2014-03-30 00:00:00'); $b = $a->addHours(value: 24); $this->assertSame(24.0, $a->diffInHours($b)); } public function testTimezoneModify() { $php81Fix = 1.0; // For daylight saving time reason 2014-03-30 0h59 is immediately followed by 2h00 $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addHours(24); $this->assertSame(23.0 + $php81Fix, $a->diffInHours($b)); $this->assertSame(23.0 + $php81Fix, $b->diffInHours($a, true)); $this->assertSame(-23.0 - $php81Fix, $b->diffInHours($a)); $this->assertSame(-(23.0 + $php81Fix) * 60, $b->diffInMinutes($a)); $this->assertSame(-(23.0 + $php81Fix) * 60 * 60, $b->diffInSeconds($a)); $this->assertSame(-(23.0 + $php81Fix) * 60 * 60 * 1000, $b->diffInMilliseconds($a)); $this->assertSame(-(23.0 + $php81Fix) * 60 * 60 * 1000000, $b->diffInMicroseconds($a)); $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addRealHours(24); $this->assertSame(-24.0, $b->diffInHours($a, false)); $this->assertSame(-24.0 * 60, $b->diffInMinutes($a, false)); $this->assertSame(-24.0 * 60 * 60, $b->diffInSeconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000, $b->diffInMilliseconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000000, $b->diffInMicroseconds($a, false)); $b = $b->subRealHours(24); $this->assertSame(0.0, $b->diffInHours($a, false)); $this->assertSame(0.0, $b->diffInHours($a, false)); $a = new Carbon('2014-03-30 00:59:00', 'Europe/London'); $a = $a->addRealHour(); $this->assertSame('02:59', $a->format('H:i')); $a = $a->subRealHour(); $this->assertSame('00:59', $a->format('H:i')); $a = new Carbon('2014-03-30 00:59:00', 'Europe/London'); $a = $a->addRealMinutes(2); $this->assertSame('02:01', $a->format('H:i')); $a = $a->subRealMinutes(2); $this->assertSame('00:59', $a->format('H:i')); $a = new Carbon('2014-03-30 00:59:30', 'Europe/London'); $a = $a->addRealMinute(); $this->assertSame('02:00:30', $a->format('H:i:s')); $a = $a->subRealMinute(); $this->assertSame('00:59:30', $a->format('H:i:s')); $a = new Carbon('2014-03-30 00:59:30', 'Europe/London'); $a = $a->addRealSeconds(40); $this->assertSame('02:00:10', $a->format('H:i:s')); $a = $a->subRealSeconds(40); $this->assertSame('00:59:30', $a->format('H:i:s')); $a = new Carbon('2014-03-30 00:59:59', 'Europe/London'); $a = $a->addRealSecond(); $this->assertSame('02:00:00', $a->format('H:i:s')); $a = $a->subRealSecond(); $this->assertSame('00:59:59', $a->format('H:i:s')); $a = new Carbon('2014-03-30 00:59:59.990000', 'Europe/London'); $a = $a->addRealMilliseconds(20); $this->assertSame('02:00:00.010000', $a->format('H:i:s.u')); $a = $a->subRealMilliseconds(20); $this->assertSame('00:59:59.990000', $a->format('H:i:s.u')); $a = new Carbon('2014-03-30 00:59:59.999990', 'Europe/London'); $a = $a->addRealMicroseconds(20); $this->assertSame('02:00:00.000010', $a->format('H:i:s.u')); $a = $a->subRealMicroseconds(20); $this->assertSame('00:59:59.999990', $a->format('H:i:s.u')); $a = new Carbon('2014-03-30 00:59:59.999999', 'Europe/London'); $a = $a->addRealMicrosecond(); $this->assertSame('02:00:00.000000', $a->format('H:i:s.u')); $a = $a->subRealMicrosecond(); $this->assertSame('00:59:59.999999', $a->format('H:i:s.u')); $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addRealDay(); $this->assertSame(-24.0, $b->diffInHours($a, false)); $this->assertSame(-24.0 * 60, $b->diffInMinutes($a, false)); $this->assertSame(-24.0 * 60 * 60, $b->diffInSeconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000, $b->diffInMilliseconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000000, $b->diffInMicroseconds($a, false)); $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addRealWeeks(1 / 7); $this->assertSame(-24.0, $b->diffInHours($a, false)); $this->assertSame(-24.0 * 60, $b->diffInMinutes($a, false)); $this->assertSame(-24.0 * 60 * 60, $b->diffInSeconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000, $b->diffInMilliseconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000000, $b->diffInMicroseconds($a, false)); $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addRealMonths(1 / 30); $this->assertSame(-24.0, $b->diffInHours($a, false)); $this->assertSame(-24.0 * 60, $b->diffInMinutes($a, false)); $this->assertSame(-24.0 * 60 * 60, $b->diffInSeconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000, $b->diffInMilliseconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000000, $b->diffInMicroseconds($a, false)); $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addRealQuarters(1 / 90); $this->assertSame(-24.0, $b->diffInHours($a, false)); $this->assertSame(-24.0 * 60, $b->diffInMinutes($a, false)); $this->assertSame(-24.0 * 60 * 60, $b->diffInSeconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000, $b->diffInMilliseconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000000, $b->diffInMicroseconds($a, false)); $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addRealYears(1 / 365); $this->assertSame(-24.0, $b->diffInHours($a, false)); $this->assertSame(-24.0 * 60, $b->diffInMinutes($a, false)); $this->assertSame(-24.0 * 60 * 60, $b->diffInSeconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000, $b->diffInMilliseconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000000, $b->diffInMicroseconds($a, false)); $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addRealDecades(1 / 3650); $this->assertSame(-24.0, $b->diffInHours($a, false)); $this->assertSame(-24.0 * 60, $b->diffInMinutes($a, false)); $this->assertSame(-24.0 * 60 * 60, $b->diffInSeconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000, $b->diffInMilliseconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000000, $b->diffInMicroseconds($a, false)); $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addRealCenturies(1 / 36500); $this->assertSame(-24.0, $b->diffInHours($a, false)); $this->assertSame(-24.0 * 60, $b->diffInMinutes($a, false)); $this->assertSame(-24.0 * 60 * 60, $b->diffInSeconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000, $b->diffInMilliseconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000000, $b->diffInMicroseconds($a, false)); $a = new Carbon('2014-03-30 00:00:00', 'Europe/London'); $b = $a->addRealMillennia(1 / 365000); $this->assertSame(-24.0, $b->diffInHours($a, false)); $this->assertSame(-24.0 * 60, $b->diffInMinutes($a, false)); $this->assertSame(-24.0 * 60 * 60, $b->diffInSeconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000, $b->diffInMilliseconds($a, false)); $this->assertSame(-24.0 * 60 * 60 * 1000000, $b->diffInMicroseconds($a, false)); } public function testNextAndPrevious() { Carbon::setTestNow('2019-06-02 13:27:09.816752'); $this->assertSame('2019-06-02 14:00:00', Carbon::now()->next('2pm')->format('Y-m-d H:i:s')); $this->assertSame('2019-06-01 14:00:00', Carbon::now()->previous('2pm')->format('Y-m-d H:i:s')); $this->assertSame('2019-06-02 14:00:00', Carbon::now()->next('14h')->format('Y-m-d H:i:s')); $this->assertSame('2019-06-01 14:00:00', Carbon::now()->previous('14h')->format('Y-m-d H:i:s')); $this->assertSame('2019-06-03 09:00:00', Carbon::now()->next('9am')->format('Y-m-d H:i:s')); $this->assertSame('2019-06-02 09:00:00', Carbon::now()->previous('9am')->format('Y-m-d H:i:s')); $this->assertSame('2019-06-02 14:00:00', Carbon::parse('next 2pm')->format('Y-m-d H:i:s')); $this->assertSame('2019-06-01 14:00:00', Carbon::parse('previous 2pm')->format('Y-m-d H:i:s')); $this->assertSame('2019-06-02 14:00:00', Carbon::parse('next 14h')->format('Y-m-d H:i:s')); $this->assertSame('2019-06-01 14:00:00', Carbon::parse('previous 14h')->format('Y-m-d H:i:s')); $this->assertSame('2019-06-03 09:00:00', Carbon::parse('next 9am')->format('Y-m-d H:i:s')); $this->assertSame('2019-06-02 09:00:00', Carbon::parse('previous 9am')->format('Y-m-d H:i:s')); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/CreateFromFormatTest.php
tests/CarbonImmutable/CreateFromFormatTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use DateTime; use DateTimeZone; use PHPUnit\Framework\Attributes\RequiresPhp; use Tests\AbstractTestCase; use Tests\Carbon\Fixtures\MyCarbon; class CreateFromFormatTest extends AbstractTestCase { /** * @var array */ protected $lastErrors; /** * @var array */ protected $noErrors; protected function setUp(): void { parent::setUp(); $this->lastErrors = [ 'warning_count' => 1, 'warnings' => ['10' => 'The parsed date was invalid'], 'error_count' => 0, 'errors' => [], ]; } public function testCreateFromFormatReturnsCarbon() { $d = Carbon::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11'); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 11); $this->assertInstanceOfCarbon($d); } public function testCreateFromFormatWithTimezoneString() { $d = Carbon::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11', 'Europe/London'); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 11); $this->assertSame('Europe/London', $d->tzName); } public function testCreateFromFormatWithTimezone() { $d = Carbon::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11', new DateTimeZone('Europe/London')); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 11); $this->assertSame('Europe/London', $d->tzName); } public function testCreateFromFormatWithMillis() { $d = Carbon::createFromFormat('Y-m-d H:i:s.u', '1975-05-21 22:32:11.254687'); $this->assertSame(254687, $d->micro); } public function testCreateFromFormatWithTestNow() { Carbon::setTestNow(); $nativeDate = Carbon::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11'); Carbon::setTestNow(Carbon::now()); $mockedDate = Carbon::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11'); $this->assertSame($mockedDate->micro === 0, $nativeDate->micro === 0); } #[RequiresPhp('>=8.2')] public function testCreateLastErrorsCanBeAccessedByExtendingClass() { $this->assertFalse(MyCarbon::getLastErrors()); } public function testCreateFromFormatHandlesLastErrors() { $carbon = Carbon::createFromFormat('d/m/Y', '41/02/1900'); $datetime = DateTime::createFromFormat('d/m/Y', '41/02/1900'); $this->assertSame($this->lastErrors, $carbon->getLastErrors()); $this->assertSame($carbon->getLastErrors(), $datetime->getLastErrors()); } #[RequiresPhp('>=8.2')] public function testCreateFromFormatResetLastErrors() { $carbon = Carbon::createFromFormat('d/m/Y', '41/02/1900'); $this->assertSame($this->lastErrors, $carbon->getLastErrors()); $carbon = Carbon::createFromFormat('d/m/Y', '11/03/2016'); $this->assertFalse($carbon->getLastErrors()); } public function testCreateFromFormatWithDollar() { $d = Carbon::createFromFormat('$c', '$1975-05-21T22:32:11+01:00'); $this->assertCarbon($d, 1975, 5, 21, 22, 32, 11); $this->assertInstanceOfCarbon($d); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/SetDateAndTimeFromTest.php
tests/CarbonImmutable/SetDateAndTimeFromTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Tests\AbstractTestCase; class SetDateAndTimeFromTest extends AbstractTestCase { public function testSetDateFrom() { $this->assertCarbon( Carbon::create(2001, 1, 1, 1, 1, 1) ->setDateFrom(Carbon::create(2002, 2, 2, 2, 2, 2)), 2002, 2, 2, 1, 1, 1, ); } public function testSetTimeFrom() { $this->assertCarbon( Carbon::create(2001, 1, 1, 1, 1, 1) ->setTimeFrom(Carbon::create(2002, 2, 2, 2, 2, 2)), 2001, 1, 1, 2, 2, 2, ); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/SettersTest.php
tests/CarbonImmutable/SettersTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\Exceptions\UnitException; use Carbon\Month; use DateTimeZone; use InvalidArgumentException; use PHPUnit\Framework\Attributes\TestWith; use RuntimeException; use Tests\AbstractTestCase; class SettersTest extends AbstractTestCase { public function testYearSetter() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::now(); $d->year = 1995; } public function testMonthSetter() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::now(); $d->month = 3; } public function testMonthEnumOnWrongUnit() { $this->expectExceptionObject(new UnitException( 'Month enum cannot be used to set hour', )); $d = Carbon::now(); $d->setHours(Month::February); } public function testMonthEnum() { $d = Carbon::parse('2023-10-25 21:14:51'); $result = $d->setMonth(Month::February); $this->assertSame('2023-02-25 21:14:51', $result->format('Y-m-d H:i:s')); $result = $d->setMonth(Month::July); $this->assertSame('2023-07-25 21:14:51', $result->format('Y-m-d H:i:s')); } public function testMonthFloatFailWithDecimalPart() { $this->expectExceptionObject(new InvalidArgumentException( 'month cannot be changed to float value 2.5, integer expected', )); $d = Carbon::parse('2023-10-25 21:14:51'); $d->setMonth(2.5); } public function testMonthFloatPassWithZeroDecimalPart() { $d = Carbon::parse('2023-10-25 21:14:51'); $result = $d->setMonth(2.0); $this->assertSame('2023-02-25 21:14:51', $result->format('Y-m-d H:i:s')); } public function testMonthSetterWithWrap() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::now(); $d->month = 13; } public function testDaySetter() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::now(); $d->day = 2; } public function testDaySetterWithWrap() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::createFromDate(2012, 8, 5); $d->day = 32; } public function testHourSetter() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::now(); $d->hour = 2; } public function testHourSetterWithWrap() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::now(); $d->hour = 25; } public function testMinuteSetter() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::now(); $d->minute = 2; } public function testMinuteSetterWithWrap() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::now(); $d->minute = 65; } public function testSecondSetter() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::now(); $d->second = 2; } public function testTimeSetter() { $d = Carbon::now(); $d = $d->setTime(1, 1, 1); $this->assertSame(1, $d->second); $d = $d->setTime(1, 1); $this->assertSame(0, $d->second); } public function testTimeSetterWithChaining() { $d = Carbon::now(); $d = $d->setTime(2, 2, 2)->setTime(1, 1, 1); $this->assertInstanceOfCarbon($d); $this->assertSame(1, $d->second); $d = $d->setTime(2, 2, 2)->setTime(1, 1); $this->assertInstanceOfCarbon($d); $this->assertSame(0, $d->second); } public function testTimeSetterWithZero() { $d = Carbon::now(); $d = $d->setTime(1, 1); $this->assertSame(0, $d->second); } public function testDateTimeSetter() { $d = Carbon::now(); $d = $d->setDateTime($d->year, $d->month, $d->day, 1, 1, 1); $this->assertSame(1, $d->second); } public function testDateTimeSetterWithZero() { $d = Carbon::now(); $d = $d->setDateTime($d->year, $d->month, $d->day, 1, 1); $this->assertSame(0, $d->second); } public function testDateTimeSetterWithChaining() { $d = Carbon::now(); $d = $d->setDateTime(2013, 9, 24, 17, 4, 29); $this->assertInstanceOfCarbon($d); $d = $d->setDateTime(2014, 10, 25, 18, 5, 30); $this->assertInstanceOfCarbon($d); $this->assertCarbon($d, 2014, 10, 25, 18, 5, 30); } /** * @link https://github.com/briannesbitt/Carbon/issues/539 */ public function testSetDateAfterStringCreation() { $d = new Carbon('first day of this month'); $this->assertSame(1, $d->day); $d = $d->setDate($d->year, $d->month, 12); $this->assertSame(12, $d->day); } public function testSecondSetterWithWrap() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::now(); $d->second = 65; } public function testTimestampSetter() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); $d = Carbon::now(); $d->timestamp = 10; } public function testSetTimezoneWithInvalidTimezone() { $this->expectExceptionObject(new InvalidArgumentException( 'Unknown or bad timezone (sdf)', )); $d = Carbon::now(); $d->setTimezone('sdf'); } public function testTimezoneWithInvalidTimezone() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); /** @var mixed $d */ $d = Carbon::now(); $d->timezone = 'sdf'; } public function testTimezoneWithInvalidTimezoneSetter() { $this->expectExceptionObject(new InvalidArgumentException( 'Unknown or bad timezone (sdf)', )); $d = Carbon::now(); $d->timezone('sdf'); } public function testTzWithInvalidTimezone() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); /** @var mixed $d */ $d = Carbon::now(); $d->tz = 'sdf'; } public function testTzWithInvalidTimezoneSetter() { $this->expectExceptionObject(new InvalidArgumentException( 'Unknown or bad timezone (sdf)', )); $d = Carbon::now(); $d->tz('sdf'); } public function testSetTimezoneUsingString() { $d = Carbon::now(); $d = $d->setTimezone('America/Toronto'); $this->assertSame('America/Toronto', $d->tzName); } public function testShiftTimezone() { $d = Carbon::parse('2018-08-13 10:53:12', 'Europe/Paris'); $d2 = $d->copy()->setTimezone('America/Toronto'); $this->assertSame(0, $d2->getTimestamp() - $d->getTimestamp()); $this->assertSame('04:53:12', $d2->format('H:i:s')); $d = Carbon::parse('2018-08-13 10:53:12', 'Europe/Paris'); $d2 = $d->copy()->shiftTimezone('America/Toronto'); $this->assertSame(21600, $d2->getTimestamp() - $d->getTimestamp()); $this->assertSame('America/Toronto', $d2->tzName); $this->assertSame('10:53:12', $d2->format('H:i:s')); $d = Carbon::parse('2018-03-25 00:53:12.321654 America/Toronto')->shiftTimezone('Europe/Oslo'); $this->assertSame('2018-03-25 00:53:12.321654 Europe/Oslo', $d->format('Y-m-d H:i:s.u e')); } public function testTimezoneUsingString() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); /** @var mixed $d */ $d = Carbon::now(); $d->timezone = 'America/Toronto'; } public function testTzUsingString() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); /** @var mixed $d */ $d = Carbon::now(); $d->tz = 'America/Toronto'; } public function testSetTimezoneUsingDateTimeZone() { $d = Carbon::now(); $d = $d->setTimezone(new DateTimeZone('America/Toronto')); $this->assertSame('America/Toronto', $d->tzName); } public function testTimezoneUsingDateTimeZone() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); /** @var mixed $d */ $d = Carbon::now(); $d->timezone = new DateTimeZone('America/Toronto'); } public function testTzUsingDateTimeZone() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); /** @var mixed $d */ $d = Carbon::now(); $d->tz = new DateTimeZone('America/Toronto'); } public function testInvalidSetter() { $this->expectExceptionObject(new RuntimeException( 'Carbon\CarbonImmutable class is immutable.', )); /** @var mixed $d */ $d = Carbon::now(); $d->doesNotExit = 'bb'; } #[TestWith([9, 15, 30, '09:15:30'])] #[TestWith([9, 15, 0, '09:15'])] #[TestWith([9, 0, 0, '09'])] #[TestWith([9, 5, 3, '9:5:3'])] #[TestWith([9, 5, 0, '9:5'])] #[TestWith([9, 0, 0, '9'])] public function testSetTimeFromTimeString(int $hour, int $minute, int $second, string $time) { Carbon::setTestNow(Carbon::create(2016, 2, 12, 1, 2, 3)); $d = Carbon::now()->setTimeFromTimeString($time); $this->assertCarbon($d, 2016, 2, 12, $hour, $minute, $second); } public function testWeekendDaysSetter() { $weekendDays = [Carbon::FRIDAY, Carbon::SATURDAY]; $d = Carbon::now(); $d->setWeekendDays($weekendDays); $this->assertSame($weekendDays, $d->getWeekendDays()); Carbon::setWeekendDays([Carbon::SATURDAY, Carbon::SUNDAY]); } public function testMidDayAtSetter() { $d = Carbon::now(); $d->setMidDayAt(11); $this->assertSame(11, $d->getMidDayAt()); $d->setMidDayAt(12); $this->assertSame(12, $d->getMidDayAt()); } public function testSetter() { $d = Carbon::now(); $d->setMidDayAt(11); $this->assertSame(11, $d->getMidDayAt()); $d->setMidDayAt(12); $this->assertSame(12, $d->getMidDayAt()); } public function testSetUnitNoOverflowFebruary() { $d = Carbon::parse('2024-02-29')->setUnitNoOverFlow('day', 31, 'month'); $this->assertInstanceOf(Carbon::class, $d); $this->assertSame('2024-02-29 23:59:59.999999', $d->format('Y-m-d H:i:s.u')); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/ComparisonTest.php
tests/CarbonImmutable/ComparisonTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use DateTime; use SubCarbon; use Tests\AbstractTestCase; class ComparisonTest extends AbstractTestCase { public function testEqualToTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->equalTo(Carbon::createFromDate(2000, 1, 1))); } public function testEqualToFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->equalTo(Carbon::createFromDate(2000, 1, 2))); } public function testEqualWithTimezoneTrue() { $this->assertTrue(Carbon::create(2000, 1, 1, 12, 0, 0, 'America/Toronto')->equalTo(Carbon::create(2000, 1, 1, 9, 0, 0, 'America/Vancouver'))); } public function testNotEqualToTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->notEqualTo(Carbon::createFromDate(2000, 1, 2))); } public function testNotEqualToFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->notEqualTo(Carbon::createFromDate(2000, 1, 1))); } public function testGreaterThanTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->greaterThan(Carbon::createFromDate(1999, 12, 31))); } public function testGreaterThanFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->greaterThan(Carbon::createFromDate(2000, 1, 2))); } public function testGreaterThanWithTimezoneTrue() { $dt1 = Carbon::create(2000, 1, 1, 12, 0, 0, 'America/Toronto'); $dt2 = Carbon::create(2000, 1, 1, 8, 59, 59, 'America/Vancouver'); $this->assertTrue($dt1->greaterThan($dt2)); } public function testGreaterThanWithTimezoneFalse() { $dt1 = Carbon::create(2000, 1, 1, 12, 0, 0, 'America/Toronto'); $dt2 = Carbon::create(2000, 1, 1, 9, 0, 1, 'America/Vancouver'); $this->assertFalse($dt1->greaterThan($dt2)); } public function testGreaterThanOrEqualTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->greaterThanOrEqualTo(Carbon::createFromDate(1999, 12, 31))); } public function testGreaterThanOrEqualTrueEqual() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->greaterThanOrEqualTo(Carbon::createFromDate(2000, 1, 1))); } public function testGreaterThanOrEqualFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->greaterThanOrEqualTo(Carbon::createFromDate(2000, 1, 2))); } public function testLessThanTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lessThan(Carbon::createFromDate(2000, 1, 2))); } public function testLessThanFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->lessThan(Carbon::createFromDate(1999, 12, 31))); } public function testLessThanOrEqualTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lessThanOrEqualTo(Carbon::createFromDate(2000, 1, 2))); } public function testLessThanOrEqualTrueEqual() { $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lessThanOrEqualTo(Carbon::createFromDate(2000, 1, 1))); } public function testLessThanOrEqualFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->lessThanOrEqualTo(Carbon::createFromDate(1999, 12, 31))); } public function testBetweenEqualTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), true)); $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->isBetween(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), true)); $this->assertTrue(\Carbon\Carbon::createFromDate(2000, 1, 15)->between(new DateTime('2000-01-01'), new DateTime('2000-01-31'), true)); $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->isBetween(new DateTime('2000-01-01'), new DateTime('2000-01-31'), true)); $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between('2000-01-01', '2000-01-31', true)); $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->isBetween('2000-01-01', '2000-01-31', true)); } public function testBetweenNotEqualTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), false)); $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->isBetween(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), false)); $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(new DateTime('2000-01-01'), new DateTime('2000-01-31'), false)); $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->isBetween(new DateTime('2000-01-01'), new DateTime('2000-01-31'), false)); $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between('2000-01-01', '2000-01-31', false)); $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->isBetween('2000-01-01', '2000-01-31', false)); } public function testBetweenExcludedTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->betweenExcluded(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31))); $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->betweenExcluded(new DateTime('2000-01-01'), new DateTime('2000-01-31'))); $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->betweenExcluded('2000-01-01', '2000-01-31')); } public function testBetweenEqualFalse() { $this->assertFalse(Carbon::createFromDate(1999, 12, 31)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), true)); } public function testBetweenNotEqualFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), false)); } public function testBetweenEqualSwitchTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), true)); } public function testBetweenNotEqualSwitchTrue() { $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), false)); } public function testBetweenEqualSwitchFalse() { $this->assertFalse(Carbon::createFromDate(1999, 12, 31)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), true)); } public function testBetweenNotEqualSwitchFalse() { $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), false)); } public function testMinIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->min()); } public function testMinWithNow() { $dt = Carbon::create(2012, 1, 1, 0, 0, 0)->min(); $this->assertCarbon($dt, 2012, 1, 1, 0, 0, 0); } public function testMinWithInstance() { $dt1 = Carbon::create(2013, 12, 31, 23, 59, 59); $dt2 = Carbon::create(2012, 1, 1, 0, 0, 0)->min($dt1); $this->assertCarbon($dt2, 2012, 1, 1, 0, 0, 0); } public function testMaxIsFluid() { $dt = Carbon::now(); $this->assertInstanceOfCarbon($dt->max()); } public function testMaxWithNow() { $dt = Carbon::create(2099, 12, 31, 23, 59, 59)->max(); $this->assertCarbon($dt, 2099, 12, 31, 23, 59, 59); } public function testMaxWithInstance() { $dt1 = Carbon::create(2012, 1, 1, 0, 0, 0); $dt2 = Carbon::create(2099, 12, 31, 23, 59, 59)->max($dt1); $this->assertCarbon($dt2, 2099, 12, 31, 23, 59, 59); } public function testIsBirthday() { $dt = Carbon::now(); // Birthday test can't work on February 29th if ($dt->format('m-d') === '02-29') { Carbon::setTestNow($dt->subDay()); $dt = Carbon::now(); } $aBirthday = $dt->subYear(); $this->assertTrue($aBirthday->isBirthday()); $notABirthday = $dt->subDay(); $this->assertFalse($notABirthday->isBirthday()); $alsoNotABirthday = $dt->addDays(2); $this->assertFalse($alsoNotABirthday->isBirthday()); $dt1 = Carbon::createFromDate(1987, 4, 23); $dt2 = Carbon::createFromDate(2014, 9, 26); $dt3 = Carbon::createFromDate(2014, 4, 23); $this->assertFalse($dt2->isBirthday($dt1)); $this->assertTrue($dt3->isBirthday($dt1)); } public function testClosest() { $instance = Carbon::create(2015, 5, 28, 12, 0, 0); $dt1 = Carbon::create(2015, 5, 28, 11, 0, 0); $dt2 = Carbon::create(2015, 5, 28, 14, 0, 0); $closest = $instance->closest($dt1, $dt2); $this->assertSame($dt1, $closest); } public function testClosestWithEquals() { $instance = Carbon::create(2015, 5, 28, 12, 0, 0); $dt1 = Carbon::create(2015, 5, 28, 12, 0, 0); $dt2 = Carbon::create(2015, 5, 28, 14, 0, 0); $closest = $instance->closest($dt1, $dt2); $this->assertSame($dt1, $closest); } public function testClosestWithMicroseconds() { $baseDate = Carbon::parse('2018-10-11 20:59:06.500000'); $closestDate = Carbon::parse('2018-10-11 20:59:06.600000'); $farthestDate = Carbon::parse('2018-10-11 20:59:06.300000'); $this->assertSame('06.600000', $baseDate->closest($closestDate, $farthestDate)->format('s.u')); } public function testClosestWithFarDates() { $baseDate = Carbon::parse('2018-10-11 20:59:06.500000'); $closestDate = Carbon::parse('-4025-10-11 20:59:06.600000'); $farthestDate = Carbon::parse('9995-10-11 20:59:06.300000'); $this->assertSame('06.600000', $baseDate->closest($closestDate, $farthestDate)->format('s.u')); } public function testFarthest() { $instance = Carbon::create(2015, 5, 28, 12, 0, 0); $dt1 = Carbon::create(2015, 5, 28, 11, 0, 0); $dt2 = Carbon::create(2015, 5, 28, 14, 0, 0); $farthest = $instance->farthest($dt1, $dt2); $this->assertSame($dt2, $farthest); } public function testFarthestWithEquals() { $instance = Carbon::create(2015, 5, 28, 12, 0, 0); $dt1 = Carbon::create(2015, 5, 28, 12, 0, 0); $dt2 = Carbon::create(2015, 5, 28, 14, 0, 0); $farthest = $instance->farthest($dt1, $dt2); $this->assertSame($dt2, $farthest); } public function testFarthestWithMicroseconds() { $baseDate = Carbon::parse('2018-10-11 20:59:06.500000'); $closestDate = Carbon::parse('2018-10-11 20:59:06.600000'); $farthestDate = Carbon::parse('2018-10-11 20:59:06.300000'); $this->assertSame('06.300000', $baseDate->farthest($closestDate, $farthestDate)->format('s.u')); } public function testFarthestWithFarDates() { $baseDate = Carbon::parse('2018-10-11 20:59:06.500000'); $closestDate = Carbon::parse('-4025-10-11 20:59:06.600000'); $farthestDate = Carbon::parse('9995-10-11 20:59:06.300000'); $this->assertSame('06.300000', $baseDate->farthest($closestDate, $farthestDate)->format('s.u')); } public function testDifferentType() { require_once __DIR__.'/../Fixtures/SubCarbon.php'; $subCarbon = new SubCarbon('2024-01-24 00:00'); $carbon = new Carbon('2024-01-24 00:00'); $this->assertTrue($subCarbon->equalTo($carbon)); $this->assertTrue($carbon->equalTo($subCarbon)); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/CreateFromDateTest.php
tests/CarbonImmutable/CreateFromDateTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use DateTimeZone; use Tests\AbstractTestCase; class CreateFromDateTest extends AbstractTestCase { public function testCreateFromDateWithDefaults() { $d = Carbon::createFromDate(); $this->assertSame($d->timestamp, Carbon::create(null, null, null, null, null, null)->timestamp); } public function testCreateFromDate() { $d = Carbon::createFromDate(1975, 5, 21); $this->assertCarbon($d, 1975, 5, 21); } public function testCreateFromDateWithYear() { $d = Carbon::createFromDate(1975); $this->assertSame(1975, $d->year); } public function testCreateFromDateWithMonth() { $d = Carbon::createFromDate(null, 5); $this->assertSame(5, $d->month); } public function testCreateFromDateWithDay() { $d = Carbon::createFromDate(null, null, 21); $this->assertSame(21, $d->day); } public function testCreateFromDateWithTimezone() { $d = Carbon::createFromDate(1975, 5, 21, 'Europe/London'); $this->assertCarbon($d, 1975, 5, 21); $this->assertSame('Europe/London', $d->tzName); } public function testCreateFromDateWithDateTimeZone() { $d = Carbon::createFromDate(1975, 5, 21, new DateTimeZone('Europe/London')); $this->assertCarbon($d, 1975, 5, 21); $this->assertSame('Europe/London', $d->tzName); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/CreateFromTimeTest.php
tests/CarbonImmutable/CreateFromTimeTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\Exceptions\InvalidFormatException; use DateTimeZone; use Tests\AbstractTestCase; class CreateFromTimeTest extends AbstractTestCase { public function testCreateWithTestNow() { Carbon::setTestNow($testNow = Carbon::create(2011, 1, 1, 12, 13, 14)); $dt = Carbon::create(null, null, null, null, null, null); $this->assertCarbon($dt, 2011, 1, 1, 12, 13, 14); $this->assertTrue($testNow->eq($dt)); } public function testCreateFromDateWithDefaults() { $d = Carbon::createFromTime(); $this->assertSame($d->timestamp, Carbon::create(null, null, null, 0, 0, 0)->timestamp); } public function testCreateFromDateWithNull() { $d = Carbon::createFromTime(null, null, null); $this->assertSame($d->timestamp, Carbon::create(null, null, null, null, null, null)->timestamp); } public function testCreateFromDate() { $d = Carbon::createFromTime(23, 5, 21); $this->assertCarbon($d, Carbon::now()->year, Carbon::now()->month, Carbon::now()->day, 23, 5, 21); } public function testCreateFromTimeWithHour() { $d = Carbon::createFromTime(22); $this->assertSame(22, $d->hour); $this->assertSame(0, $d->minute); $this->assertSame(0, $d->second); } public function testCreateFromTimeWithMinute() { $d = Carbon::createFromTime(null, 5); $this->assertSame(5, $d->minute); } public function testCreateFromTimeWithSecond() { $d = Carbon::createFromTime(null, null, 21); $this->assertSame(21, $d->second); } public function testCreateFromTimeWithDateTimeZone() { $d = Carbon::createFromTime(12, 0, 0, new DateTimeZone('Europe/London')); $this->assertCarbon($d, Carbon::now('Europe/London')->year, Carbon::now('Europe/London')->month, Carbon::now('Europe/London')->day, 12, 0, 0); $this->assertSame('Europe/London', $d->tzName); } public function testCreateFromTimeWithTimeZoneString() { $d = Carbon::createFromTime(12, 0, 0, 'Europe/London'); $this->assertCarbon($d, Carbon::now('Europe/London')->year, Carbon::now('Europe/London')->month, Carbon::now('Europe/London')->day, 12, 0, 0); $this->assertSame('Europe/London', $d->tzName); } public function testCreateFromTime() { // disable test for now // because we need Carbon::now() in Carbon::create() to work with given TZ $test = Carbon::getTestNow(); Carbon::setTestNow(); $tz = 'Etc/GMT+12'; try { $now = Carbon::now($tz); } catch (InvalidFormatException $exception) { if ($exception->getMessage() !== 'Unknown or bad timezone (Etc/GMT+12)') { throw $exception; } $tz = 'GMT+12'; $now = Carbon::now($tz); } $dt = Carbon::createFromTime($now->hour, $now->minute, $now->second, $tz); // re-enable test Carbon::setTestNow($test); // tested without microseconds // because they appear within calls to Carbon $this->assertSame($now->format('c'), $dt->format('c')); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/TestingAidsTest.php
tests/CarbonImmutable/TestingAidsTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\CarbonInterface; use Closure; use DateTime; use DateTimeZone; use Exception; use stdClass; use Tests\AbstractTestCase; class TestingAidsTest extends AbstractTestCase { public function wrapWithTestNow(Closure $func, ?CarbonInterface $dt = null): void { Carbon::setTestNow($dt ?: Carbon::now()); $func(); Carbon::setTestNow(); } public function testTestingAidsWithTestNowNotSet() { Carbon::setTestNow(); $this->assertFalse(Carbon::hasTestNow()); $this->assertNull(Carbon::getTestNow()); } public function testTestingAidsWithTestNowSet() { Carbon::setTestNow($yesterday = Carbon::yesterday()); $this->assertTrue(Carbon::hasTestNow()); $this->assertSame($yesterday->format('Y-m-d H:i:s.u e'), Carbon::getTestNow()->format('Y-m-d H:i:s.u e')); } public function testTestingAidsWithTestNowSetToString() { Carbon::setTestNow('2016-11-23'); $this->assertTrue(Carbon::hasTestNow()); $this->assertEquals(Carbon::getTestNow(), Carbon::parse('2016-11-23')); } public function testConstructorWithTestValueSet() { Carbon::setTestNow($yesterday = Carbon::yesterday()); $this->assertEquals($yesterday, new Carbon()); $this->assertEquals($yesterday, new Carbon(null)); $this->assertEquals($yesterday, new Carbon('')); $this->assertEquals($yesterday, new Carbon('now')); } public function testNowWithTestValueSet() { Carbon::setTestNow($yesterday = Carbon::yesterday()); $this->assertEquals($yesterday, Carbon::now()); } public function testNowWithDateTime() { Carbon::setTestNow(new DateTime('2021-05-26 08:41:59')); $this->assertSame('2021-05-26 08:41:59', Carbon::now()->format('Y-m-d H:i:s')); } public function testNowWithClosureValue() { $mockedNow = Carbon::parse('2019-09-21 12:34:56.123456'); $delta = 0; Carbon::setTestNow(function (Carbon $now) use (&$mockedNow, &$delta) { $this->assertInstanceOfCarbon($now); return $mockedNow->copy()->tz($now->tz)->addMicroseconds($delta); }); $this->assertSame('2019-09-21 12:34:56.123456', Carbon::now()->format('Y-m-d H:i:s.u')); $this->assertSame('2019-09-21 00:00:00.000000', Carbon::today()->format('Y-m-d H:i:s.u')); $this->assertSame('2019-09-22 00:00:00.000000', Carbon::create('tomorrow')->format('Y-m-d H:i:s.u')); $this->assertSame('2018-06-15 12:34:00.000000', Carbon::create(2018, 6, 15, null, null)->format('Y-m-d H:i:s.u')); $delta = 11111111; $date = Carbon::now(); $this->assertSame('America/Toronto', $date->tzName); $this->assertSame('2019-09-21 12:35:07.234567', $date->format('Y-m-d H:i:s.u')); $date = Carbon::today(); $this->assertSame('America/Toronto', $date->tzName); $this->assertSame('2019-09-21 00:00:00.000000', $date->format('Y-m-d H:i:s.u')); $date = Carbon::create('tomorrow'); $this->assertSame('America/Toronto', $date->tzName); $this->assertSame('2019-09-22 00:00:00.000000', $date->format('Y-m-d H:i:s.u')); $date = Carbon::create(2018, 6, 15, null, null); $this->assertSame('America/Toronto', $date->tzName); $this->assertSame('2018-06-15 12:35:00.000000', $date->format('Y-m-d H:i:s.u')); date_default_timezone_set('UTC'); $date = Carbon::now(); $this->assertSame('UTC', $date->tzName); $this->assertSame('2019-09-21 16:35:07.234567', $date->format('Y-m-d H:i:s.u')); $date = Carbon::today(); $this->assertSame('UTC', $date->tzName); $this->assertSame('2019-09-21 00:00:00.000000', $date->format('Y-m-d H:i:s.u')); $date = Carbon::create('tomorrow'); $this->assertSame('UTC', $date->tzName); $this->assertSame('2019-09-22 00:00:00.000000', $date->format('Y-m-d H:i:s.u')); $date = Carbon::create(2018, 6, 15, null, null); $this->assertSame('UTC', $date->tzName); $this->assertSame('2018-06-15 16:35:00.000000', $date->format('Y-m-d H:i:s.u')); date_default_timezone_set('America/Toronto'); } public function testParseWithTestValueSet() { $testNow = Carbon::yesterday(); $this->wrapWithTestNow(function () use ($testNow) { $this->assertEquals($testNow, Carbon::parse(null)); $this->assertEquals($testNow, Carbon::parse('')); $this->assertEquals($testNow, Carbon::parse('now')); }, $testNow); } public function testParseRelativeWithTestValueSet() { $testNow = Carbon::parse('2013-09-01 05:15:05'); $this->wrapWithTestNow(function () { $this->assertSame('2013-09-01 05:10:05', Carbon::parse('5 minutes ago')->toDateTimeString()); $this->assertSame('2013-08-25 05:15:05', Carbon::parse('1 week ago')->toDateTimeString()); $this->assertSame('2013-09-02 00:00:00', Carbon::parse('tomorrow')->toDateTimeString()); $this->assertSame('2013-09-01 00:00:00', Carbon::parse('today')->toDateTimeString()); $this->assertSame('2013-08-31 00:00:00', Carbon::parse('yesterday')->toDateTimeString()); $this->assertSame('2013-09-02 05:15:05', Carbon::parse('+1 day')->toDateTimeString()); $this->assertSame('2013-08-31 05:15:05', Carbon::parse('-1 day')->toDateTimeString()); $this->assertSame('2013-09-02 00:00:00', Carbon::parse('next monday')->toDateTimeString()); $this->assertSame('2013-09-03 00:00:00', Carbon::parse('next tuesday')->toDateTimeString()); $this->assertSame('2013-09-04 00:00:00', Carbon::parse('next wednesday')->toDateTimeString()); $this->assertSame('2013-09-05 00:00:00', Carbon::parse('next thursday')->toDateTimeString()); $this->assertSame('2013-09-06 00:00:00', Carbon::parse('next friday')->toDateTimeString()); $this->assertSame('2013-09-07 00:00:00', Carbon::parse('next saturday')->toDateTimeString()); $this->assertSame('2013-09-08 00:00:00', Carbon::parse('next sunday')->toDateTimeString()); $this->assertSame('2013-08-26 00:00:00', Carbon::parse('last monday')->toDateTimeString()); $this->assertSame('2013-08-27 00:00:00', Carbon::parse('last tuesday')->toDateTimeString()); $this->assertSame('2013-08-28 00:00:00', Carbon::parse('last wednesday')->toDateTimeString()); $this->assertSame('2013-08-29 00:00:00', Carbon::parse('last thursday')->toDateTimeString()); $this->assertSame('2013-08-30 00:00:00', Carbon::parse('last friday')->toDateTimeString()); $this->assertSame('2013-08-31 00:00:00', Carbon::parse('last saturday')->toDateTimeString()); $this->assertSame('2013-08-25 00:00:00', Carbon::parse('last sunday')->toDateTimeString()); $this->assertSame('2013-09-02 00:00:00', Carbon::parse('this monday')->toDateTimeString()); $this->assertSame('2013-09-03 00:00:00', Carbon::parse('this tuesday')->toDateTimeString()); $this->assertSame('2013-09-04 00:00:00', Carbon::parse('this wednesday')->toDateTimeString()); $this->assertSame('2013-09-05 00:00:00', Carbon::parse('this thursday')->toDateTimeString()); $this->assertSame('2013-09-06 00:00:00', Carbon::parse('this friday')->toDateTimeString()); $this->assertSame('2013-09-07 00:00:00', Carbon::parse('this saturday')->toDateTimeString()); $this->assertSame('2013-09-01 00:00:00', Carbon::parse('this sunday')->toDateTimeString()); $this->assertSame('2013-10-01 05:15:05', Carbon::parse('first day of next month')->toDateTimeString()); $this->assertSame('2013-09-30 05:15:05', Carbon::parse('last day of this month')->toDateTimeString()); }, $testNow); } public function testHasRelativeKeywords() { $this->assertFalse(Carbon::hasRelativeKeywords('sunday 2015-02-23')); $this->assertTrue(Carbon::hasRelativeKeywords('today +2014 days')); $this->assertTrue(Carbon::hasRelativeKeywords('next sunday -3600 seconds')); $this->assertTrue(Carbon::hasRelativeKeywords('last day of this month')); $this->assertFalse(Carbon::hasRelativeKeywords('last day of december 2015')); $this->assertTrue(Carbon::hasRelativeKeywords('first sunday of next month')); $this->assertFalse(Carbon::hasRelativeKeywords('first sunday of January 2017')); } public function testParseRelativeWithMinusSignsInDate() { $testNow = Carbon::parse('2013-09-01 05:15:05'); $this->wrapWithTestNow(function () { $this->assertSame('2000-01-03 00:00:00', Carbon::parse('2000-1-3')->toDateTimeString()); $this->assertSame('2000-10-10 00:00:00', Carbon::parse('2000-10-10')->toDateTimeString()); }, $testNow); $this->assertSame('2000-01-03 00:00:00', Carbon::parse('2000-1-3')->toDateTimeString()); $this->assertSame('2000-10-10 00:00:00', Carbon::parse('2000-10-10')->toDateTimeString()); } public function testTimeZoneWithTestValueSet() { $testNow = Carbon::parse('2013-07-01 12:00:00', 'America/New_York'); $this->wrapWithTestNow(function () { $this->assertSame('2013-07-01T12:00:00-04:00', Carbon::parse('now')->toIso8601String()); $this->assertSame('2013-07-01T11:00:00-05:00', Carbon::parse('now', 'America/Mexico_City')->toIso8601String()); $this->assertSame('2013-07-01T09:00:00-07:00', Carbon::parse('now', 'America/Vancouver')->toIso8601String()); }, $testNow); } public function testCreateFromPartialFormat() { Carbon::setTestNowAndTimezone(Carbon::parse('2013-09-01 05:10:15', 'America/Vancouver')); // Simple partial time. $this->assertSame('2018-05-06T05:10:15-07:00', Carbon::createFromFormat('Y-m-d', '2018-05-06')->toIso8601String()); $this->assertSame('2013-09-01T10:20:30-07:00', Carbon::createFromFormat('H:i:s', '10:20:30')->toIso8601String()); // Custom timezone. $this->assertSame('2013-09-01T10:20:00+03:00', Carbon::createFromFormat('H:i e', '10:20 Europe/Kiev')->toIso8601String()); $this->assertSame('2013-09-01T10:20:00+01:00', Carbon::createFromFormat('H:i', '10:20', 'Europe/London')->toIso8601String()); $this->assertSame('2013-09-01T11:30:00+07:00', Carbon::createFromFormat('H:i:s e', '11:30:00+07:00')->toIso8601String()); $this->assertSame('2013-09-01T11:30:00+05:00', Carbon::createFromFormat('H:i:s', '11:30:00', '+05:00')->toIso8601String()); // Escaped timezone. $this->assertSame('2013-09-01T05:10:15-07:00', Carbon::createFromFormat('\e', 'e')->toIso8601String()); // Weird format, naive modify would fail here. $this->assertSame('2005-08-09T05:10:15-07:00', Carbon::createFromFormat('l jS \of F Y', 'Tuesday 9th of August 2005')->toIso8601String()); $this->assertSame('2013-09-01T00:12:13-07:00', Carbon::createFromFormat('i:s', '12:13')->toIso8601String()); $this->assertSame('2018-09-05T05:10:15-07:00', Carbon::createFromFormat('Y/d', '2018/5')->toIso8601String()); // Resetting to epoch. $this->assertSame('2018-05-06T00:00:00-07:00', Carbon::createFromFormat('!Y-m-d', '2018-05-06')->toIso8601String()); $this->assertSame('1970-01-01T10:20:30-08:00', Carbon::createFromFormat('Y-m-d! H:i:s', '2018-05-06 10:20:30')->toIso8601String()); $this->assertSame('2018-05-06T00:00:00-07:00', Carbon::createFromFormat('Y-m-d|', '2018-05-06')->toIso8601String()); $this->assertSame('1970-01-01T10:20:30-08:00', Carbon::createFromFormat('|H:i:s', '10:20:30')->toIso8601String()); $kyiv = $this->firstValidTimezoneAmong(['Europe/Kyiv', 'Europe/Kiev'])->getName(); // Resetting to epoch (timezone fun). $this->assertSame('1970-01-01T00:00:00-08:00', Carbon::createFromFormat('|', '')->toIso8601String()); $this->assertSame('1970-01-01T00:00:00+03:00', Carbon::createFromFormat('e|', $kyiv)->toIso8601String()); $this->assertSame('1970-01-01T00:00:00+01:00', Carbon::createFromFormat('|', '', 'Europe/London')->toIso8601String()); $this->assertSame('1970-01-01T00:00:00-08:00', Carbon::createFromFormat('!', '')->toIso8601String()); $this->assertSame('1970-01-01T00:00:00+03:00', Carbon::createFromFormat('!e', $kyiv)->toIso8601String()); $this->assertSame('1970-01-01T00:00:00+01:00', Carbon::createFromFormat('!', '', 'Europe/London')->toIso8601String()); $this->assertSame('1970-01-01T00:00:00-08:00', Carbon::createFromFormat('e!', $kyiv)->toIso8601String()); // Escaped epoch resets. $this->assertSame('2013-09-01T05:10:15-07:00', Carbon::createFromFormat('\|', '|')->toIso8601String()); $this->assertSame('2013-09-01T05:10:15-07:00', Carbon::createFromFormat('\!', '!')->toIso8601String()); $this->assertSame('2013-09-01T05:10:15+03:00', Carbon::createFromFormat('e \!', $kyiv.' !')->toIso8601String()); Carbon::setTestNow('2023-12-05 21:09:54'); $this->assertSame('2023-12-05 15:00:00.000000', Carbon::createFromFormat('H', '15')->format('Y-m-d H:i:s.u')); } public function testCreateFromPartialFormatWithMicroseconds() { Carbon::setTestNowAndTimezone(Carbon::parse('2013-09-01 05:10:15.123456', 'America/Vancouver')); $this->assertSame('2018-05-06 05:10:15.123456', Carbon::createFromFormat('Y-m-d', '2018-05-06')->format('Y-m-d H:i:s.u')); $this->assertSame('2013-09-01 10:20:30.654321', Carbon::createFromFormat('H:i:s.u', '10:20:30.654321')->format('Y-m-d H:i:s.u')); } public function testCreateFromDateTimeInterface() { Carbon::setTestNowAndTimezone(date_create_immutable('2013-09-01 05:10:15.123456', new DateTimeZone('America/Vancouver'))); $this->assertSame('2018-05-06 05:10:15.123456', Carbon::createFromFormat('Y-m-d', '2018-05-06')->format('Y-m-d H:i:s.u')); $this->assertSame('2013-09-01 10:20:30.654321', Carbon::createFromFormat('H:i:s.u', '10:20:30.654321')->format('Y-m-d H:i:s.u')); } public function testWithTestNow() { $self = $this; $testNow = '2020-09-16 10:20:00'; $object = new stdClass(); $result = Carbon::withTestNow($testNow, static function () use ($self, $testNow, $object) { $currentTime = Carbon::now(); $self->assertSame($testNow, $currentTime->format('Y-m-d H:i:s')); return $object; }); $this->assertSame($object, $result); $currentTime = Carbon::now(); $this->assertNotEquals($testNow, $currentTime->format('Y-m-d H:i:s')); } public function testWithTestNowWithException() { $testNow = '2020-09-16 10:20:00'; try { Carbon::withTestNow($testNow, static function () { throw new Exception(); }); } catch (Exception $e) { // ignore } $currentTime = Carbon::now(); $this->assertNotEquals($testNow, $currentTime->format('Y-m-d H:i:s')); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/NowAndOtherStaticHelpersTest.php
tests/CarbonImmutable/NowAndOtherStaticHelpersTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use DateTime; use DateTimeZone; use Tests\AbstractTestCase; class NowAndOtherStaticHelpersTest extends AbstractTestCase { public function testNow() { $dt = Carbon::now(); $this->assertSame($this->immutableNow->getTimestamp(), $dt->timestamp); Carbon::setTestNow(); $before = $this->getTimestamp(); $dt = Carbon::now(); $after = $this->getTimestamp(); $this->assertGreaterThanOrEqual($before, $dt->timestamp); $this->assertLessThanOrEqual($after, $dt->timestamp); } public function testGetPreciseTimestamp() { $dt = Carbon::parse('2018-01-06 12:34:10.987126'); $this->assertSame(1515260.0, $dt->getPreciseTimestamp(-3)); $this->assertSame(151526005.0, $dt->getPreciseTimestamp(-1)); $this->assertSame(1515260051.0, $dt->getPreciseTimestamp(0)); $this->assertSame(15152600510.0, $dt->getPreciseTimestamp(1)); $this->assertSame(151526005099.0, $dt->getPreciseTimestamp(2)); $this->assertSame(1515260050987.0, $dt->valueOf()); $this->assertSame(15152600509871.0, $dt->getPreciseTimestamp(4)); $this->assertSame(151526005098713.0, $dt->getPreciseTimestamp(5)); $this->assertSame(1515260050987126.0, $dt->getPreciseTimestamp(6)); $this->assertSame(151526005098712600.0, $dt->getPreciseTimestamp(8)); $this->assertSame(1515260050987126000.0, $dt->getPreciseTimestamp(9)); } public function testGetTimestampMs() { $dt = Carbon::parse('2018-01-06 12:34:10.987126'); $this->assertSame(1515260050987, $dt->getTimestampMs()); } public function testNowWithTimezone() { $dt = Carbon::now('Europe/London'); $this->assertSame($this->immutableNow->getTimestamp(), $dt->timestamp); Carbon::setTestNow(); $before = $this->getTimestamp(); $dt = Carbon::now('Europe/London'); $after = $this->getTimestamp(); $this->assertGreaterThanOrEqual($before, $dt->timestamp); $this->assertLessThanOrEqual($after, $dt->timestamp); $this->assertSame('Europe/London', $dt->tzName); } public function testToday() { $dt = Carbon::today(); $this->assertSame(date('Y-m-d 00:00:00'), $dt->toDateTimeString()); } public function testTodayWithTimezone() { $dt = Carbon::today('Europe/London'); $dt2 = new DateTime('now', new DateTimeZone('Europe/London')); $this->assertSame($dt2->format('Y-m-d 00:00:00'), $dt->toDateTimeString()); } public function testTomorrow() { $dt = Carbon::tomorrow(); $dt2 = new DateTime('tomorrow'); $this->assertSame($dt2->format('Y-m-d 00:00:00'), $dt->toDateTimeString()); } public function testTomorrowWithTimezone() { $dt = Carbon::tomorrow('Europe/London'); $dt2 = new DateTime('tomorrow', new DateTimeZone('Europe/London')); $this->assertSame($dt2->format('Y-m-d 00:00:00'), $dt->toDateTimeString()); } public function testYesterday() { $dt = Carbon::yesterday(); $dt2 = new DateTime('yesterday'); $this->assertSame($dt2->format('Y-m-d 00:00:00'), $dt->toDateTimeString()); } public function testYesterdayWithTimezone() { $dt = Carbon::yesterday('Europe/London'); $dt2 = new DateTime('yesterday', new DateTimeZone('Europe/London')); $this->assertSame($dt2->format('Y-m-d 00:00:00'), $dt->toDateTimeString()); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/CopyTest.php
tests/CarbonImmutable/CopyTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Tests\AbstractTestCase; class CopyTest extends AbstractTestCase { public function testCopy() { $dating = Carbon::now(); $dating2 = $dating->copy(); $this->assertNotSame($dating, $dating2); } public function testClone() { $dating = Carbon::now(); $dating2 = $dating->clone(); $this->assertNotSame($dating, $dating2); } public function testCopyEnsureTzIsCopied() { $dating = Carbon::createFromDate(2000, 1, 1, 'Europe/London'); $dating2 = $dating->copy(); $this->assertSame($dating->tzName, $dating2->tzName); $this->assertSame($dating->offset, $dating2->offset); } public function testCopyEnsureMicrosAreCopied() { $micro = 254687; $dating = Carbon::createFromFormat('Y-m-d H:i:s.u', '2014-02-01 03:45:27.'.$micro); $dating2 = $dating->copy(); $this->assertSame($micro, $dating2->micro); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/CreateFromTimeStringTest.php
tests/CarbonImmutable/CreateFromTimeStringTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use DateTimeZone; use Tests\AbstractTestCase; class CreateFromTimeStringTest extends AbstractTestCase { protected function setUp(): void { parent::setUp(); Carbon::setTestNow(); } public function testCreateFromTimeString() { $d = Carbon::createFromTimeString('22:45'); $this->assertSame(22, $d->hour); $this->assertSame(45, $d->minute); $this->assertSame(0, $d->second); $this->assertSame(0, $d->micro); } public function testCreateFromTimeStringWithSecond() { $d = Carbon::createFromTimeString('22:45:12'); $this->assertSame(22, $d->hour); $this->assertSame(45, $d->minute); $this->assertSame(12, $d->second); $this->assertSame(0, $d->micro); } public function testCreateFromTimeStringWithMicroSecond() { $d = Carbon::createFromTimeString('22:45:00.625341'); $this->assertSame(22, $d->hour); $this->assertSame(45, $d->minute); $this->assertSame(0, $d->second); $this->assertSame(625341, $d->micro); } public function testCreateFromTimeStringWithDateTimeZone() { $d = Carbon::createFromTimeString('12:20:30', new DateTimeZone('Europe/London')); $this->assertCarbonTime($d, 12, 20, 30, 0); $this->assertSame('Europe/London', $d->tzName); } public function testCreateFromTimeStringWithTimeZoneString() { $d = Carbon::createFromTimeString('12:20:30', 'Europe/London'); $this->assertCarbonTime($d, 12, 20, 30, 0); $this->assertSame('Europe/London', $d->tzName); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/SetStateTest.php
tests/CarbonImmutable/SetStateTest.php
<?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 Tests\CarbonImmutable; use Carbon\Traits\Serialization; use stdClass; use Tests\AbstractTestCase; class SetStateTest extends AbstractTestCase { public function testSteState(): void { $obj = new class(null) { use Serialization; public function __construct(public mixed $data) { } public static function instance($value): static { return new static($value); } public function callSetState($value) { return static::__set_state($value); } }; $data = $obj->callSetState(['foo' => 'bar']); $this->assertInstanceOf(\get_class($obj), $data); $this->assertInstanceOf(stdClass::class, $data->data); $this->assertSame('bar', $data->data->foo); $this->assertSame(['foo' => 'bar'], (array) $data->data); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/WeekTest.php
tests/CarbonImmutable/WeekTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\CarbonInterface; use PHPUnit\Framework\Attributes\DataProvider; use Tests\AbstractTestCase; class WeekTest extends AbstractTestCase { public const SAMPLE = [ '1990-12-20' => [ 1990, 1990, 51, 51, 52, 52, ], '1990-12-21' => [ 1990, 1990, 51, 51, 52, 52, ], '1990-12-22' => [ 1990, 1990, 51, 51, 52, 52, ], '1990-12-23' => [ 1990, 1990, 52, 51, 52, 52, ], '1990-12-24' => [ 1990, 1990, 52, 52, 52, 52, ], '1990-12-25' => [ 1990, 1990, 52, 52, 52, 52, ], '1990-12-26' => [ 1990, 1990, 52, 52, 52, 52, ], '1990-12-27' => [ 1990, 1990, 52, 52, 52, 52, ], '1990-12-28' => [ 1990, 1990, 52, 52, 52, 52, ], '1990-12-29' => [ 1990, 1990, 52, 52, 52, 52, ], '1990-12-30' => [ 1991, 1990, 1, 52, 52, 52, ], '1990-12-31' => [ 1991, 1991, 1, 1, 52, 52, ], '1991-01-01' => [ 1991, 1991, 1, 1, 52, 52, ], '1991-01-02' => [ 1991, 1991, 1, 1, 52, 52, ], '1991-01-03' => [ 1991, 1991, 1, 1, 52, 52, ], '1991-01-04' => [ 1991, 1991, 1, 1, 52, 52, ], '1991-01-05' => [ 1991, 1991, 1, 1, 52, 52, ], '1991-01-06' => [ 1991, 1991, 2, 1, 52, 52, ], '1991-01-07' => [ 1991, 1991, 2, 2, 52, 52, ], '1991-01-08' => [ 1991, 1991, 2, 2, 52, 52, ], '1991-01-09' => [ 1991, 1991, 2, 2, 52, 52, ], '1991-01-10' => [ 1991, 1991, 2, 2, 52, 52, ], '1991-12-20' => [ 1991, 1991, 51, 51, 52, 52, ], '1991-12-21' => [ 1991, 1991, 51, 51, 52, 52, ], '1991-12-22' => [ 1991, 1991, 52, 51, 52, 52, ], '1991-12-23' => [ 1991, 1991, 52, 52, 52, 52, ], '1991-12-24' => [ 1991, 1991, 52, 52, 52, 52, ], '1991-12-25' => [ 1991, 1991, 52, 52, 52, 52, ], '1991-12-26' => [ 1991, 1991, 52, 52, 52, 52, ], '1991-12-27' => [ 1991, 1991, 52, 52, 52, 52, ], '1991-12-28' => [ 1991, 1991, 52, 52, 52, 52, ], '1991-12-29' => [ 1992, 1991, 1, 52, 52, 52, ], '1991-12-30' => [ 1992, 1992, 1, 1, 52, 52, ], '1991-12-31' => [ 1992, 1992, 1, 1, 52, 52, ], '1992-01-01' => [ 1992, 1992, 1, 1, 52, 53, ], '1992-01-02' => [ 1992, 1992, 1, 1, 52, 53, ], '1992-01-03' => [ 1992, 1992, 1, 1, 52, 53, ], '1992-01-04' => [ 1992, 1992, 1, 1, 52, 53, ], '1992-01-05' => [ 1992, 1992, 2, 1, 52, 53, ], '1992-01-06' => [ 1992, 1992, 2, 2, 52, 53, ], '1992-01-07' => [ 1992, 1992, 2, 2, 52, 53, ], '1992-01-08' => [ 1992, 1992, 2, 2, 52, 53, ], '1992-01-09' => [ 1992, 1992, 2, 2, 52, 53, ], '1992-01-10' => [ 1992, 1992, 2, 2, 52, 53, ], '1992-12-20' => [ 1992, 1992, 52, 51, 52, 53, ], '1992-12-21' => [ 1992, 1992, 52, 52, 52, 53, ], '1992-12-22' => [ 1992, 1992, 52, 52, 52, 53, ], '1992-12-23' => [ 1992, 1992, 52, 52, 52, 53, ], '1992-12-24' => [ 1992, 1992, 52, 52, 52, 53, ], '1992-12-25' => [ 1992, 1992, 52, 52, 52, 53, ], '1992-12-26' => [ 1992, 1992, 52, 52, 52, 53, ], '1992-12-27' => [ 1993, 1992, 1, 52, 52, 53, ], '1992-12-28' => [ 1993, 1992, 1, 53, 52, 53, ], '1992-12-29' => [ 1993, 1992, 1, 53, 52, 53, ], '1992-12-30' => [ 1993, 1992, 1, 53, 52, 53, ], '1992-12-31' => [ 1993, 1992, 1, 53, 52, 53, ], '1993-01-01' => [ 1993, 1992, 1, 53, 52, 52, ], '1993-01-02' => [ 1993, 1992, 1, 53, 52, 52, ], '1993-01-03' => [ 1993, 1992, 2, 53, 52, 52, ], '1993-01-04' => [ 1993, 1993, 2, 1, 52, 52, ], '1993-01-05' => [ 1993, 1993, 2, 1, 52, 52, ], '1993-01-06' => [ 1993, 1993, 2, 1, 52, 52, ], '1993-01-07' => [ 1993, 1993, 2, 1, 52, 52, ], '1993-01-08' => [ 1993, 1993, 2, 1, 52, 52, ], '1993-01-09' => [ 1993, 1993, 2, 1, 52, 52, ], '1993-01-10' => [ 1993, 1993, 3, 1, 52, 52, ], '1993-12-20' => [ 1993, 1993, 52, 51, 52, 52, ], '1993-12-21' => [ 1993, 1993, 52, 51, 52, 52, ], '1993-12-22' => [ 1993, 1993, 52, 51, 52, 52, ], '1993-12-23' => [ 1993, 1993, 52, 51, 52, 52, ], '1993-12-24' => [ 1993, 1993, 52, 51, 52, 52, ], '1993-12-25' => [ 1993, 1993, 52, 51, 52, 52, ], '1993-12-26' => [ 1994, 1993, 1, 51, 52, 52, ], '1993-12-27' => [ 1994, 1993, 1, 52, 52, 52, ], '1993-12-28' => [ 1994, 1993, 1, 52, 52, 52, ], '1993-12-29' => [ 1994, 1993, 1, 52, 52, 52, ], '1993-12-30' => [ 1994, 1993, 1, 52, 52, 52, ], '1993-12-31' => [ 1994, 1993, 1, 52, 52, 52, ], '1994-01-01' => [ 1994, 1993, 1, 52, 53, 52, ], '1994-01-02' => [ 1994, 1993, 2, 52, 53, 52, ], '1994-01-03' => [ 1994, 1994, 2, 1, 53, 52, ], '1994-01-04' => [ 1994, 1994, 2, 1, 53, 52, ], '1994-01-05' => [ 1994, 1994, 2, 1, 53, 52, ], '1994-01-06' => [ 1994, 1994, 2, 1, 53, 52, ], '1994-01-07' => [ 1994, 1994, 2, 1, 53, 52, ], '1994-01-08' => [ 1994, 1994, 2, 1, 53, 52, ], '1994-01-09' => [ 1994, 1994, 3, 1, 53, 52, ], '1994-01-10' => [ 1994, 1994, 3, 2, 53, 52, ], '1994-12-20' => [ 1994, 1994, 52, 51, 53, 52, ], '1994-12-21' => [ 1994, 1994, 52, 51, 53, 52, ], '1994-12-22' => [ 1994, 1994, 52, 51, 53, 52, ], '1994-12-23' => [ 1994, 1994, 52, 51, 53, 52, ], '1994-12-24' => [ 1994, 1994, 52, 51, 53, 52, ], '1994-12-25' => [ 1994, 1994, 53, 51, 53, 52, ], '1994-12-26' => [ 1994, 1994, 53, 52, 53, 52, ], '1994-12-27' => [ 1994, 1994, 53, 52, 53, 52, ], '1994-12-28' => [ 1994, 1994, 53, 52, 53, 52, ], '1994-12-29' => [ 1994, 1994, 53, 52, 53, 52, ], '1994-12-30' => [ 1994, 1994, 53, 52, 53, 52, ], '1994-12-31' => [ 1994, 1994, 53, 52, 53, 52, ], '1995-01-01' => [ 1995, 1994, 1, 52, 52, 52, ], '1995-01-02' => [ 1995, 1995, 1, 1, 52, 52, ], '1995-01-03' => [ 1995, 1995, 1, 1, 52, 52, ], '1995-01-04' => [ 1995, 1995, 1, 1, 52, 52, ], '1995-01-05' => [ 1995, 1995, 1, 1, 52, 52, ], '1995-01-06' => [ 1995, 1995, 1, 1, 52, 52, ], '1995-01-07' => [ 1995, 1995, 1, 1, 52, 52, ], '1995-01-08' => [ 1995, 1995, 2, 1, 52, 52, ], '1995-01-09' => [ 1995, 1995, 2, 2, 52, 52, ], '1995-01-10' => [ 1995, 1995, 2, 2, 52, 52, ], '1995-12-20' => [ 1995, 1995, 51, 51, 52, 52, ], '1995-12-21' => [ 1995, 1995, 51, 51, 52, 52, ], '1995-12-22' => [ 1995, 1995, 51, 51, 52, 52, ], '1995-12-23' => [ 1995, 1995, 51, 51, 52, 52, ], '1995-12-24' => [ 1995, 1995, 52, 51, 52, 52, ], '1995-12-25' => [ 1995, 1995, 52, 52, 52, 52, ], '1995-12-26' => [ 1995, 1995, 52, 52, 52, 52, ], '1995-12-27' => [ 1995, 1995, 52, 52, 52, 52, ], '1995-12-28' => [ 1995, 1995, 52, 52, 52, 52, ], '1995-12-29' => [ 1995, 1995, 52, 52, 52, 52, ], '1995-12-30' => [ 1995, 1995, 52, 52, 52, 52, ], '1995-12-31' => [ 1996, 1995, 1, 52, 52, 52, ], '1996-01-01' => [ 1996, 1996, 1, 1, 52, 52, ], '1996-01-02' => [ 1996, 1996, 1, 1, 52, 52, ], '1996-01-03' => [ 1996, 1996, 1, 1, 52, 52, ], '1996-01-04' => [ 1996, 1996, 1, 1, 52, 52, ], '1996-01-05' => [ 1996, 1996, 1, 1, 52, 52, ], '1996-01-06' => [ 1996, 1996, 1, 1, 52, 52, ], '1996-01-07' => [ 1996, 1996, 2, 1, 52, 52, ], '1996-01-08' => [ 1996, 1996, 2, 2, 52, 52, ], '1996-01-09' => [ 1996, 1996, 2, 2, 52, 52, ], '1996-01-10' => [ 1996, 1996, 2, 2, 52, 52, ], '1996-12-20' => [ 1996, 1996, 51, 51, 52, 52, ], '1996-12-21' => [ 1996, 1996, 51, 51, 52, 52, ], '1996-12-22' => [ 1996, 1996, 52, 51, 52, 52, ], '1996-12-23' => [ 1996, 1996, 52, 52, 52, 52, ], '1996-12-24' => [ 1996, 1996, 52, 52, 52, 52, ], '1996-12-25' => [ 1996, 1996, 52, 52, 52, 52, ], '1996-12-26' => [ 1996, 1996, 52, 52, 52, 52, ], '1996-12-27' => [ 1996, 1996, 52, 52, 52, 52, ], '1996-12-28' => [ 1996, 1996, 52, 52, 52, 52, ], '1996-12-29' => [ 1997, 1996, 1, 52, 52, 52, ], '1996-12-30' => [ 1997, 1997, 1, 1, 52, 52, ], '1996-12-31' => [ 1997, 1997, 1, 1, 52, 52, ], '1997-01-01' => [ 1997, 1997, 1, 1, 52, 52, ], '1997-01-02' => [ 1997, 1997, 1, 1, 52, 52, ], '1997-01-03' => [ 1997, 1997, 1, 1, 52, 52, ], '1997-01-04' => [ 1997, 1997, 1, 1, 52, 52, ], '1997-01-05' => [ 1997, 1997, 2, 1, 52, 52, ], '1997-01-06' => [ 1997, 1997, 2, 2, 52, 52, ], '1997-01-07' => [ 1997, 1997, 2, 2, 52, 52, ], '1997-01-08' => [ 1997, 1997, 2, 2, 52, 52, ], '1997-01-09' => [ 1997, 1997, 2, 2, 52, 52, ], '1997-01-10' => [ 1997, 1997, 2, 2, 52, 52, ], '1997-12-20' => [ 1997, 1997, 51, 51, 52, 52, ], '1997-12-21' => [ 1997, 1997, 52, 51, 52, 52, ], '1997-12-22' => [ 1997, 1997, 52, 52, 52, 52, ], '1997-12-23' => [ 1997, 1997, 52, 52, 52, 52, ], '1997-12-24' => [ 1997, 1997, 52, 52, 52, 52, ], '1997-12-25' => [ 1997, 1997, 52, 52, 52, 52, ], '1997-12-26' => [ 1997, 1997, 52, 52, 52, 52, ], '1997-12-27' => [ 1997, 1997, 52, 52, 52, 52, ], '1997-12-28' => [ 1998, 1997, 1, 52, 52, 52, ], '1997-12-29' => [ 1998, 1998, 1, 1, 52, 52, ], '1997-12-30' => [ 1998, 1998, 1, 1, 52, 52, ], '1997-12-31' => [ 1998, 1998, 1, 1, 52, 52, ], '1998-01-01' => [ 1998, 1998, 1, 1, 52, 53, ], '1998-01-02' => [ 1998, 1998, 1, 1, 52, 53, ], '1998-01-03' => [ 1998, 1998, 1, 1, 52, 53, ], '1998-01-04' => [ 1998, 1998, 2, 1, 52, 53, ], '1998-01-05' => [ 1998, 1998, 2, 2, 52, 53, ], '1998-01-06' => [ 1998, 1998, 2, 2, 52, 53, ], '1998-01-07' => [ 1998, 1998, 2, 2, 52, 53, ], '1998-01-08' => [ 1998, 1998, 2, 2, 52, 53, ], '1998-01-09' => [ 1998, 1998, 2, 2, 52, 53, ], '1998-01-10' => [ 1998, 1998, 2, 2, 52, 53, ], '1998-12-20' => [ 1998, 1998, 52, 51, 52, 53, ], '1998-12-21' => [ 1998, 1998, 52, 52, 52, 53, ], '1998-12-22' => [ 1998, 1998, 52, 52, 52, 53, ], '1998-12-23' => [ 1998, 1998, 52, 52, 52, 53, ], '1998-12-24' => [ 1998, 1998, 52, 52, 52, 53, ], '1998-12-25' => [ 1998, 1998, 52, 52, 52, 53, ], '1998-12-26' => [ 1998, 1998, 52, 52, 52, 53, ], '1998-12-27' => [ 1999, 1998, 1, 52, 52, 53, ], '1998-12-28' => [ 1999, 1998, 1, 53, 52, 53, ], '1998-12-29' => [ 1999, 1998, 1, 53, 52, 53, ], '1998-12-30' => [ 1999, 1998, 1, 53, 52, 53, ], '1998-12-31' => [ 1999, 1998, 1, 53, 52, 53, ], '1999-01-01' => [ 1999, 1998, 1, 53, 52, 52, ], '1999-01-02' => [ 1999, 1998, 1, 53, 52, 52, ], '1999-01-03' => [ 1999, 1998, 2, 53, 52, 52, ], '1999-01-04' => [ 1999, 1999, 2, 1, 52, 52, ], '1999-01-05' => [ 1999, 1999, 2, 1, 52, 52, ], '1999-01-06' => [ 1999, 1999, 2, 1, 52, 52, ], '1999-01-07' => [ 1999, 1999, 2, 1, 52, 52, ], '1999-01-08' => [ 1999, 1999, 2, 1, 52, 52, ], '1999-01-09' => [ 1999, 1999, 2, 1, 52, 52, ], '1999-01-10' => [ 1999, 1999, 3, 1, 52, 52, ], '1999-12-20' => [ 1999, 1999, 52, 51, 52, 52, ], '1999-12-21' => [ 1999, 1999, 52, 51, 52, 52, ], '1999-12-22' => [ 1999, 1999, 52, 51, 52, 52, ], '1999-12-23' => [ 1999, 1999, 52, 51, 52, 52, ], '1999-12-24' => [ 1999, 1999, 52, 51, 52, 52, ], '1999-12-25' => [ 1999, 1999, 52, 51, 52, 52, ], '1999-12-26' => [ 2000, 1999, 1, 51, 52, 52, ], '1999-12-27' => [ 2000, 1999, 1, 52, 52, 52, ], '1999-12-28' => [ 2000, 1999, 1, 52, 52, 52, ], '1999-12-29' => [ 2000, 1999, 1, 52, 52, 52, ], '1999-12-30' => [ 2000, 1999, 1, 52, 52, 52, ], '1999-12-31' => [ 2000, 1999, 1, 52, 52, 52, ], '2000-01-01' => [ 2000, 1999, 1, 52, 53, 52, ], '2000-01-02' => [ 2000, 1999, 2, 52, 53, 52, ], '2000-01-03' => [ 2000, 2000, 2, 1, 53, 52, ], '2000-01-04' => [ 2000, 2000, 2, 1, 53, 52, ], '2000-01-05' => [ 2000, 2000, 2, 1, 53, 52, ], '2000-01-06' => [ 2000, 2000, 2, 1, 53, 52, ], '2000-01-07' => [ 2000, 2000, 2, 1, 53, 52, ], '2000-01-08' => [ 2000, 2000, 2, 1, 53, 52, ], '2000-01-09' => [ 2000, 2000, 3, 1, 53, 52, ], '2000-01-10' => [ 2000, 2000, 3, 2, 53, 52, ], '2000-12-20' => [ 2000, 2000, 52, 51, 53, 52, ], '2000-12-21' => [ 2000, 2000, 52, 51, 53, 52, ], '2000-12-22' => [ 2000, 2000, 52, 51, 53, 52, ], '2000-12-23' => [ 2000, 2000, 52, 51, 53, 52, ], '2000-12-24' => [ 2000, 2000, 53, 51, 53, 52, ], '2000-12-25' => [ 2000, 2000, 53, 52, 53, 52, ], '2000-12-26' => [ 2000, 2000, 53, 52, 53, 52, ], '2000-12-27' => [ 2000, 2000, 53, 52, 53, 52, ], '2000-12-28' => [ 2000, 2000, 53, 52, 53, 52, ], '2000-12-29' => [ 2000, 2000, 53, 52, 53, 52, ], '2000-12-30' => [ 2000, 2000, 53, 52, 53, 52, ], '2000-12-31' => [ 2001, 2000, 1, 52, 53, 52, ], '2001-01-01' => [ 2001, 2001, 1, 1, 52, 52, ], '2001-01-02' => [ 2001, 2001, 1, 1, 52, 52, ], '2001-01-03' => [ 2001, 2001, 1, 1, 52, 52, ], '2001-01-04' => [ 2001, 2001, 1, 1, 52, 52, ], '2001-01-05' => [ 2001, 2001, 1, 1, 52, 52, ], '2001-01-06' => [
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
true
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/InstanceTest.php
tests/CarbonImmutable/InstanceTest.php
<?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 Tests\CarbonImmutable; use Carbon\Carbon as CarbonMutable; use Carbon\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Carbon\CarbonInterface; use DateTime; use DateTimeZone; use InvalidArgumentException; use Tests\AbstractTestCase; class InstanceTest extends AbstractTestCase { public function testInstanceFromDateTime() { $dating = Carbon::instance(DateTime::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11')); $this->assertCarbon($dating, 1975, 5, 21, 22, 32, 11); $dating = Carbon::parse(DateTime::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11')); $this->assertCarbon($dating, 1975, 5, 21, 22, 32, 11); } public function testInstanceFromCarbon() { $dating = Carbon::instance(Carbon::create(1975, 5, 21, 22, 32, 11)); $this->assertCarbon($dating, 1975, 5, 21, 22, 32, 11); } public function testInstanceFromDateTimeKeepsTimezoneName() { $dating = Carbon::instance(DateTime::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11')->setTimezone(new DateTimeZone('America/Vancouver'))); $this->assertSame('America/Vancouver', $dating->tzName); } public function testInstanceFromCarbonKeepsTimezoneName() { $dating = Carbon::instance(Carbon::create(1975, 5, 21, 22, 32, 11)->setTimezone(new DateTimeZone('America/Vancouver'))); $this->assertSame('America/Vancouver', $dating->tzName); } public function testInstanceFromDateTimeKeepsMicros() { $micro = 254687; $datetime = DateTime::createFromFormat('Y-m-d H:i:s.u', '2014-02-01 03:45:27.'.$micro); $carbon = Carbon::instance($datetime); $this->assertSame($micro, $carbon->micro); } public function testInstanceFromCarbonKeepsMicros() { $micro = 254687; $carbon = Carbon::createFromFormat('Y-m-d H:i:s.u', '2014-02-01 03:45:27.'.$micro); $carbon = Carbon::instance($carbon); $this->assertSame($micro, $carbon->micro); } public function testTimezoneCopy() { $carbon = new Carbon('2017-06-27 13:14:15.123456', 'Europe/Paris'); $carbon = CarbonMutable::instance($carbon); $this->assertSame('2017-06-27 13:14:15.123456 Europe/Paris', $carbon->format('Y-m-d H:i:s.u e')); } public function testInstanceStateSetBySetStateMethod() { $carbon = Carbon::__set_state([ 'date' => '2017-05-18 13:02:15.273420', 'timezone_type' => 3, 'timezone' => 'UTC', ]); $this->assertInstanceOf(Carbon::class, $carbon); $this->assertSame('2017-05-18 13:02:15.273420', $carbon->format('Y-m-d H:i:s.u')); } public function testInstanceStateSetBySetStateString() { $carbon = Carbon::__set_state('2017-05-18 13:02:15.273420'); $this->assertInstanceOf(Carbon::class, $carbon); $this->assertSame('2017-05-18 13:02:15.273420', $carbon->format('Y-m-d H:i:s.u')); } public function testDeserializationOccursCorrectly() { $carbon = new Carbon('2017-06-27 13:14:15.000000'); $serialized = 'return '.var_export($carbon, true).';'; $deserialized = eval($serialized); $this->assertInstanceOf(Carbon::class, $deserialized); } public function testMutableConversions() { $carbon = new Carbon('2017-06-27 13:14:15.123456', 'Europe/Paris'); $carbon = $carbon->locale('en_CA'); $copy = $carbon->toImmutable(); $this->assertEquals($copy, $carbon); $this->assertSame($copy, $carbon); $this->assertSame('en_CA', $copy->locale()); $this->assertInstanceOf(CarbonImmutable::class, $copy); $this->assertTrue($copy->isImmutable()); $this->assertFalse($copy->isMutable()); $this->assertSame('2017-06-27 13:14:15.123456', $copy->format(CarbonInterface::MOCK_DATETIME_FORMAT)); $this->assertSame('Europe/Paris', $copy->tzName); $this->assertNotSame($copy, $copy->modify('+1 day')); $copy = $carbon->toMutable(); $this->assertEquals($copy, $carbon); $this->assertNotSame($copy, $carbon); $this->assertSame('en_CA', $copy->locale()); $this->assertInstanceOf(CarbonMutable::class, $copy); $this->assertFalse($copy->isImmutable()); $this->assertTrue($copy->isMutable()); $this->assertSame('2017-06-27 13:14:15.123456', $copy->format(CarbonInterface::MOCK_DATETIME_FORMAT)); $this->assertSame('Europe/Paris', $copy->tzName); $this->assertSame($copy, $copy->modify('+1 day')); } public function testInvalidCast() { $this->expectExceptionObject(new InvalidArgumentException( 'DateTimeZone has not the instance() method needed to cast the date.', )); $carbon = new Carbon('2017-06-27 13:14:15.123456', 'Europe/Paris'); $carbon->cast(DateTimeZone::class); } public function testChildCast() { $class = \get_class(new class() extends Carbon { public function foo() { return 42; } }); $carbon = new Carbon('2017-06-27 13:14:15.123456', 'Europe/Paris'); /** @var object $casted */ $casted = $carbon->cast($class); $this->assertInstanceOf($class, $casted); $this->assertInstanceOf(Carbon::class, $casted); $this->assertSame(42, $casted->foo()); $this->assertSame('2017-06-27', $casted->format('Y-m-d')); } public function testSiblingCast() { $class = \get_class(new class() extends DateTime { public function foo() { return 42; } }); $carbon = new Carbon('2017-06-27 13:14:15.123456', 'Europe/Paris'); /** @var object $casted */ $casted = $carbon->cast($class); $this->assertInstanceOf($class, $casted); $this->assertInstanceOf(DateTime::class, $casted); $this->assertSame(42, $casted->foo()); $this->assertSame('2017-06-27', $casted->format('Y-m-d')); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/JsonSerializationTest.php
tests/CarbonImmutable/JsonSerializationTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Tests\AbstractTestCaseWithOldNow; class JsonSerializationTest extends AbstractTestCaseWithOldNow { public function testCarbonAllowsCustomSerializer() { Carbon::serializeUsing(function (Carbon $carbon) { return $carbon->getTimestamp(); }); $result = json_decode(json_encode(Carbon::now()), true); $this->assertSame(1498569255, $result); } public function testCarbonAllowsCustomSerializerString() { Carbon::serializeUsing('Y-m-d'); $this->assertSame('"2017-06-27"', json_encode(Carbon::now())); } public function testCarbonAllowsCustomSerializerViaSettings() { $date = Carbon::now()->settings([ 'toJsonFormat' => 'H:i:s', ]); $this->assertSame('"13:14:15"', json_encode($date)); } public function testCarbonCanSerializeToJson() { $this->assertSame('2017-06-27T13:14:15.000000Z', Carbon::now()->jsonSerialize()); } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false
briannesbitt/Carbon
https://github.com/briannesbitt/Carbon/blob/6e037cd6239a150d74a54c62e300b269e88a89e3/tests/CarbonImmutable/RelativeDateStringTest.php
tests/CarbonImmutable/RelativeDateStringTest.php
<?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 Tests\CarbonImmutable; use Carbon\CarbonImmutable as Carbon; use Tests\AbstractTestCase; class RelativeDateStringTest extends AbstractTestCase { public $scenarios = [ // ensure regular timestamps are flagged as relative '2018-01-02 03:04:05' => ['date' => '2018-01-02', 'is_relative' => false], '1500-01-02 12:00:00' => ['date' => '1500-01-02', 'is_relative' => false], '1985-12-10' => ['date' => '1985-12-10', 'is_relative' => false], 'Dec 2017' => ['date' => '2017-12-01', 'is_relative' => false], '25-Dec-2017' => ['date' => '2017-12-25', 'is_relative' => false], '25 December 2017' => ['date' => '2017-12-25', 'is_relative' => false], '25 Dec 2017' => ['date' => '2017-12-25', 'is_relative' => false], 'Dec 25 2017' => ['date' => '2017-12-25', 'is_relative' => false], // dates not relative now 'first day of January 2008' => ['date' => '2008-01-01', 'is_relative' => false], 'first day of January 1999' => ['date' => '1999-01-01', 'is_relative' => false], 'last day of January 1999' => ['date' => '1999-01-31', 'is_relative' => false], 'last monday of January 1999' => ['date' => '1999-01-25', 'is_relative' => false], 'first day of January 0001' => ['date' => '0001-01-01', 'is_relative' => false], 'monday december 1750' => ['date' => '1750-12-07', 'is_relative' => false], 'december 1750' => ['date' => '1750-12-01', 'is_relative' => false], 'last sunday of January 2005' => ['date' => '2005-01-30', 'is_relative' => false], 'January 2008' => ['date' => '2008-01-01', 'is_relative' => false], // dates relative to now 'first day of next month' => ['date' => '2017-02-01', 'is_relative' => true], 'sunday noon' => ['date' => '2017-01-01', 'is_relative' => true], 'sunday midnight' => ['date' => '2017-01-01', 'is_relative' => true], 'monday december' => ['date' => '2017-12-04', 'is_relative' => true], 'next saturday' => ['date' => '2017-01-07', 'is_relative' => true], 'april' => ['date' => '2017-04-01', 'is_relative' => true], ]; public function testKeywordMatching() { foreach ($this->scenarios as $string => $expected) { $actual = Carbon::hasRelativeKeywords($string); $this->assertSame( $expected['is_relative'], $actual, "Failed relative keyword matching for scenario: {$string} (expected: {$expected['is_relative']})", ); } } public function testRelativeInputStrings() { Carbon::setTestNow('2017-01-01 12:00:00'); foreach ($this->scenarios as $string => $expected) { $actual = Carbon::parse($string)->format('Y-m-d'); $this->assertSame( $expected['date'], $actual, "Failed relative date scenario: {$string}", ); } } }
php
MIT
6e037cd6239a150d74a54c62e300b269e88a89e3
2026-01-04T15:02:34.459238Z
false