Skip to content

Commit

Permalink
Merge pull request #3099 from briannesbitt/job/update-documentation
Browse files Browse the repository at this point in the history
Update documentation: 3.8.1
  • Loading branch information
kylekatarnls authored Nov 3, 2024
2 parents 9d8706a + 933db7f commit d4a1a66
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 71 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"cmixin/business-time": "dev-master",
"cmixin/season": "dev-main",
"kylekatarnls/carbonite": "dev-master",
"nesbot/carbon": "dev-master as 3.8.0"
"nesbot/carbon": "dev-master as 3.8.1"
},
"scripts": {
"check": "@php tools/check.php",
Expand Down
102 changes: 51 additions & 51 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ <h1 id="api-introduction">Introduction</h1>
$modifiedImmutable = CarbonImmutable::now()->add(1, 'day');

var_dump($modifiedMutable === $mutable); // bool(true)
var_dump($mutable->isoFormat('dddd D')); // string(11) "Thursday 24"
var_dump($modifiedMutable->isoFormat('dddd D')); // string(11) "Thursday 24"
var_dump($mutable->isoFormat('dddd D')); // string(8) "Monday 4"
var_dump($modifiedMutable->isoFormat('dddd D')); // string(8) "Monday 4"
// So it means $mutable and $modifiedMutable are the same object
// both set to now + 1 day.
var_dump($modifiedImmutable === $immutable); // bool(false)
var_dump($immutable->isoFormat('dddd D')); // string(12) "Wednesday 23"
var_dump($modifiedImmutable->isoFormat('dddd D')); // string(11) "Thursday 24"
var_dump($immutable->isoFormat('dddd D')); // string(8) "Sunday 3"
var_dump($modifiedImmutable->isoFormat('dddd D')); // string(8) "Monday 4"
// While $immutable is still set to now and cannot be changed and
// $modifiedImmutable is a new instance created from $immutable
// set to now + 1 day.
Expand Down Expand Up @@ -281,16 +281,16 @@ <h1 id="api-instantiation">Instantiation</h1>

<p>
<pre class="live-editor"><code class="php">$now = Carbon::now();
echo $now; // 2024-10-23 20:55:00
echo $now; // 2024-11-03 16:16:07
echo "\n";
$today = Carbon::today();
echo $today; // 2024-10-23 00:00:00
echo $today; // 2024-11-03 00:00:00
echo "\n";
$tomorrow = Carbon::tomorrow('Europe/London');
echo $tomorrow; // 2024-10-24 00:00:00
echo $tomorrow; // 2024-11-04 00:00:00
echo "\n";
$yesterday = Carbon::yesterday();
echo $yesterday; // 2024-10-22 00:00:00
echo $yesterday; // 2024-11-02 00:00:00
</code></pre>
</p>

Expand Down Expand Up @@ -451,7 +451,7 @@ <h1 id="api-instantiation">Instantiation</h1>
// 19:15 in Johannesburg
echo 'Meeting starts at '.$meeting->format('H:i').' in Johannesburg.'; // Meeting starts at 19:15 in Johannesburg.
// now in Johannesburg
echo "It's ".$meeting->nowWithSameTz()->format('H:i').' right now in Johannesburg.'; // It's 22:55 right now in Johannesburg.
echo "It's ".$meeting->nowWithSameTz()->format('H:i').' right now in Johannesburg.'; // It's 18:16 right now in Johannesburg.
</code></pre>
</p>

Expand Down Expand Up @@ -703,9 +703,9 @@ <h1 id="api-localization">Localization</h1>
echo "\n";
echo $date->diffForHumans(); // il y a 0 seconde
echo "\n";
echo $date->monthName; // octobre
echo $date->monthName; // novembre
echo "\n";
echo $date->isoFormat('LLLL'); // mercredi 23 octobre 2024 20:55
echo $date->isoFormat('LLLL'); // dimanche 3 novembre 2024 16:16
</code></pre>
</p>

Expand Down Expand Up @@ -736,13 +736,13 @@ <h1 id="api-localization">Localization</h1>
echo $toDisplay;
/*
15 juin 2018 14:34
Aujourd’hui à 22:55
Aujourd’hui à 17:16
*/

echo $notificationForJohn;
/*
Jun 15, 2018 7:34 AM
Today at 3:55 PM
Today at 10:16 AM
*/
</code></pre>
</p>
Expand All @@ -769,9 +769,9 @@ <h1 id="api-localization">Localization</h1>
]);
// Important note: timezone setting calls ->shiftTimezone() and not ->setTimezone(),
// It means it does not just set the timezone, but shift the time too:
echo Carbon::today()->setTimezone('Asia/Tokyo')->format('d/m G\h e'); // 23/10 9h Asia/Tokyo
echo Carbon::today()->setTimezone('Asia/Tokyo')->format('d/m G\h e'); // 03/11 9h Asia/Tokyo
echo "\n";
echo Carbon::today()->shiftTimezone('Asia/Tokyo')->format('d/m G\h e'); // 23/10 0h Asia/Tokyo
echo Carbon::today()->shiftTimezone('Asia/Tokyo')->format('d/m G\h e'); // 03/11 0h Asia/Tokyo

// You can find back which factory created a given object:
$a = $factory->now();
Expand Down Expand Up @@ -1654,21 +1654,21 @@ <h1 id="api-localization">Localization</h1>

<p>
<pre class="live-editor"><code class="php">$date = CarbonImmutable::now();
echo $date->calendar(); // Today at 8:55 PM
echo $date->calendar(); // Today at 4:16 PM
echo "\n";
echo $date->sub('1 day 3 hours')->calendar(); // Yesterday at 5:55 PM
echo $date->sub('1 day 3 hours')->calendar(); // Yesterday at 1:16 PM
echo "\n";
echo $date->sub('3 days 10 hours 23 minutes')->calendar(); // Last Sunday at 10:32 AM
echo $date->sub('3 days 10 hours 23 minutes')->calendar(); // Last Thursday at 5:53 AM
echo "\n";
echo $date->sub('8 days')->calendar(); // 10/15/2024
echo $date->sub('8 days')->calendar(); // 10/26/2024
echo "\n";
echo $date->add('1 day 3 hours')->calendar(); // Tomorrow at 11:55 PM
echo $date->add('1 day 3 hours')->calendar(); // Tomorrow at 7:16 PM
echo "\n";
echo $date->add('3 days 10 hours 23 minutes')->calendar(); // Sunday at 7:18 AM
echo $date->add('3 days 10 hours 23 minutes')->calendar(); // Thursday at 2:39 AM
echo "\n";
echo $date->add('8 days')->calendar(); // 10/31/2024
echo $date->add('8 days')->calendar(); // 11/11/2024
echo "\n";
echo $date->locale('fr')->calendar(); // Aujourd’hui à 20:55
echo $date->locale('fr')->calendar(); // Aujourd’hui à 16:16
</code></pre>
</p>

Expand Down Expand Up @@ -5588,7 +5588,7 @@ <h1 id="api-testing">Testing Aids</h1>
var_dump(Carbon::hasTestNow()); // bool(true)
Carbon::setTestNow(); // clear the mock
var_dump(Carbon::hasTestNow()); // bool(false)
echo Carbon::now(); // 2024-10-23 20:55:01
echo Carbon::now(); // 2024-11-03 16:16:07
// Instead of mock and clear mock, you also can use withTestNow():

Carbon::withTestNow('2010-09-15', static function () {
Expand Down Expand Up @@ -5831,12 +5831,12 @@ <h1 id="api-getters">Getters</h1>

// You can get any property dynamically too:
$unit = 'second';
var_dump(Carbon::now()->get($unit)); // int(1)
var_dump(Carbon::now()->get($unit)); // int(7)
// equivalent to:
var_dump(Carbon::now()->$unit); // int(1)
var_dump(Carbon::now()->$unit); // int(7)
// If you have plural unit name, use singularUnit()
$unit = Carbon::singularUnit('seconds');
var_dump(Carbon::now()->get($unit)); // int(1)
var_dump(Carbon::now()->get($unit)); // int(7)
// Prefer using singularUnit() because some plurals are not the word with S:
var_dump(Carbon::pluralUnit('century')); // string(9) "centuries"
var_dump(Carbon::pluralUnit('millennium')); // string(9) "millennia"
Expand Down Expand Up @@ -5912,23 +5912,23 @@ <h1 id="api-week">Weeks</h1>

var_dump($en->firstWeekDay); // int(0)
var_dump($en->lastWeekDay); // int(6)
var_dump($en->startOfWeek()->format('Y-m-d H:i')); // string(16) "2024-10-20 00:00"
var_dump($en->endOfWeek()->format('Y-m-d H:i')); // string(16) "2024-10-26 23:59"
var_dump($en->startOfWeek()->format('Y-m-d H:i')); // string(16) "2024-11-03 00:00"
var_dump($en->endOfWeek()->format('Y-m-d H:i')); // string(16) "2024-11-09 23:59"

echo "-----------\n";

// We still can force to use an other day as start/end of week
$start = $en->startOfWeek(Carbon::TUESDAY);
$end = $en->endOfWeek(Carbon::MONDAY);
var_dump($start->format('Y-m-d H:i')); // string(16) "2024-10-22 00:00"
var_dump($end->format('Y-m-d H:i')); // string(16) "2024-10-28 23:59"
var_dump($start->format('Y-m-d H:i')); // string(16) "2024-10-29 00:00"
var_dump($end->format('Y-m-d H:i')); // string(16) "2024-11-04 23:59"

echo "-----------\n";

var_dump($ar->firstWeekDay); // int(6)
var_dump($ar->lastWeekDay); // int(5)
var_dump($ar->startOfWeek()->format('Y-m-d H:i')); // string(16) "2024-10-19 00:00"
var_dump($ar->endOfWeek()->format('Y-m-d H:i')); // string(16) "2024-10-25 23:59"
var_dump($ar->startOfWeek()->format('Y-m-d H:i')); // string(16) "2024-11-02 00:00"
var_dump($ar->endOfWeek()->format('Y-m-d H:i')); // string(16) "2024-11-08 23:59"

$en = CarbonImmutable::parse('2015-02-05'); // use en_US as default locale

Expand Down Expand Up @@ -6413,8 +6413,8 @@ <h1 id="api-comparison">Comparison</h1>

// now is the default param
$dt1 = Carbon::createMidnightDate(2000, 1, 1);
echo $dt1->max(); // 2024-10-23 20:55:01
echo $dt1->maximum(); // 2024-10-23 20:55:01
echo $dt1->max(); // 2024-11-03 16:16:07
echo $dt1->maximum(); // 2024-11-03 16:16:07

// Remember min and max PHP native function work fine with dates too:
echo max(Carbon::create('2002-03-15'), Carbon::create('2003-01-07'), Carbon::create('2002-08-25')); // 2003-01-07 00:00:00
Expand Down Expand Up @@ -6909,7 +6909,7 @@ <h1 id="api-difference">Difference</h1>
greater than the other.</p>

<p>
<pre><code class="php">echo Carbon::now('America/Vancouver')->diffInSeconds(Carbon::now('Europe/London')); // 4.0E-6
<pre><code class="php">echo Carbon::now('America/Vancouver')->diffInSeconds(Carbon::now('Europe/London')); // 5.0E-6

$dtOttawa = Carbon::createMidnightDate(2000, 1, 1, 'America/Toronto');
$dtVancouver = Carbon::createMidnightDate(2000, 1, 1, 'America/Vancouver');
Expand Down Expand Up @@ -7049,9 +7049,9 @@ <h1 id="api-difference">Difference</h1>
$date = Carbon::now()->addSeconds(3666);

echo $date->diffInSeconds(); // -3665.999952
echo $date->diffInMinutes(); // -61.099998483333
echo $date->diffInHours(); // -1.0183332977778
echo $date->diffInDays(); // -0.042430553657407
echo $date->diffInMinutes(); // -61.0999985
echo $date->diffInHours(); // -1.0183332983333
echo $date->diffInDays(); // -0.04243055369213

$date = Carbon::create(2016, 1, 5, 22, 40, 32);

Expand Down Expand Up @@ -7704,9 +7704,9 @@ <h1 id="api-macro">Macro</h1>
// Then now you can easily display any date in a page/e-mail using those user settings and the chosen format
echo Carbon::parse($dateString, 'UTC')->formatForUser(); // 23/01/2010
echo "\n";
echo Carbon::tomorrow()->formatForUser(); // Demain à 02:00
echo Carbon::tomorrow()->formatForUser(); // Demain à 01:00
echo "\n";
echo Carbon::now()->subDays(3)->formatForUser(); // dimanche dernier à 22:55
echo Carbon::now()->subDays(3)->formatForUser(); // jeudi dernier à 17:16
</code></pre>
</p>

Expand Down Expand Up @@ -7969,10 +7969,10 @@ <h1 id="api-macro">Macro</h1>
echo substr(implode(', ', $dates), 0, 100).'...';
}

dumpDateList(Carbon::getCurrentWeekDays()); // 2024-10-21 00:00:00, 2024-10-22 00:00:00, 2024-10-23 00:00:00, 2024-10-24 00:00:00, 2024-10-25 00:00...
dumpDateList(Carbon::getCurrentMonthDays()); // 2024-10-01 00:00:00, 2024-10-02 00:00:00, 2024-10-03 00:00:00, 2024-10-04 00:00:00, 2024-10-05 00:00...
dumpDateList(Carbon::now()->subMonth()->getCurrentWeekDays()); // 2024-09-23 00:00:00, 2024-09-24 00:00:00, 2024-09-25 00:00:00, 2024-09-26 00:00:00, 2024-09-27 00:00...
dumpDateList(Carbon::now()->subMonth()->getCurrentMonthDays()); // 2024-09-01 00:00:00, 2024-09-02 00:00:00, 2024-09-03 00:00:00, 2024-09-04 00:00:00, 2024-09-05 00:00...
dumpDateList(Carbon::getCurrentWeekDays()); // 2024-10-28 00:00:00, 2024-10-29 00:00:00, 2024-10-30 00:00:00, 2024-10-31 00:00:00, 2024-11-01 00:00...
dumpDateList(Carbon::getCurrentMonthDays()); // 2024-11-01 00:00:00, 2024-11-02 00:00:00, 2024-11-03 00:00:00, 2024-11-04 00:00:00, 2024-11-05 00:00...
dumpDateList(Carbon::now()->subMonth()->getCurrentWeekDays()); // 2024-09-30 00:00:00, 2024-10-01 00:00:00, 2024-10-02 00:00:00, 2024-10-03 00:00:00, 2024-10-04 00:00...
dumpDateList(Carbon::now()->subMonth()->getCurrentMonthDays()); // 2024-10-01 00:00:00, 2024-10-02 00:00:00, 2024-10-03 00:00:00, 2024-10-04 00:00:00, 2024-10-05 00:00...
</code></pre>
</p>

Expand Down Expand Up @@ -8076,11 +8076,11 @@ <h1 id="api-macro">Macro</h1>
Carbon::mixin(new UserTimezoneCarbonMixin());

Carbon::setUserTimezone('Europe/Berlin');
echo Carbon::createFromTime(12, 0, 0, 'UTC')->tzFormat('H:i'); // 14:00
echo Carbon::createFromTime(15, 0, 0, 'UTC')->tzFormat('H:i'); // 17:00
echo Carbon::createFromTime(12, 0, 0, 'UTC')->tzFormat('H:i'); // 13:00
echo Carbon::createFromTime(15, 0, 0, 'UTC')->tzFormat('H:i'); // 16:00
Carbon::setUserTimezone('America/Toronto');
echo Carbon::createFromTime(12, 0, 0, 'UTC')->tzFormat('H:i'); // 08:00
echo Carbon::createFromTime(15, 0, 0, 'UTC')->tzFormat('H:i'); // 11:00
echo Carbon::createFromTime(12, 0, 0, 'UTC')->tzFormat('H:i'); // 07:00
echo Carbon::createFromTime(15, 0, 0, 'UTC')->tzFormat('H:i'); // 10:00
</code></pre>
</p>

Expand Down Expand Up @@ -8951,7 +8951,7 @@ <h1 id="api-period">CarbonPeriod</h1>
$days[] = $date->format('Y-m-d');
}

echo implode(', ', $days); // 2024-10-23, 2024-10-24, 2024-10-25
echo implode(', ', $days); // 2024-11-03, 2024-11-04, 2024-11-05
</code></pre>
</p>

Expand Down Expand Up @@ -9287,7 +9287,7 @@ <h1 id="api-timezone">CarbonTimeZone</h1>
echo $tz->toRegionName(); // Europe/Zurich
echo "\n";
// toOffsetName will give the current offset string for this timezone:
echo $tz->toOffsetName(); // +02:00
echo $tz->toOffsetName(); // +01:00
echo "\n";
// As with DST, this offset can change depending on the date, you may pass a date argument to specify it:
$winter = Carbon::parse('2018-01-01');
Expand Down
Loading

0 comments on commit d4a1a66

Please sign in to comment.