Skip to content

Commit

Permalink
Merge pull request #3105 from briannesbitt/job/update-documentation
Browse files Browse the repository at this point in the history
Update documentation
  • Loading branch information
kylekatarnls authored Nov 16, 2024
2 parents 0101e5b + b976755 commit b8f0e6b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 47 deletions.
88 changes: 44 additions & 44 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 14"
var_dump($modifiedMutable->isoFormat('dddd D')); // string(11) "Thursday 14"
var_dump($mutable->isoFormat('dddd D')); // string(11) "Saturday 16"
var_dump($modifiedMutable->isoFormat('dddd D')); // string(11) "Saturday 16"
// 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 13"
var_dump($modifiedImmutable->isoFormat('dddd D')); // string(11) "Thursday 14"
var_dump($immutable->isoFormat('dddd D')); // string(9) "Friday 15"
var_dump($modifiedImmutable->isoFormat('dddd D')); // string(11) "Saturday 16"
// 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-11-13 18:38:28
echo $now; // 2024-11-15 00:26:57
echo "\n";
$today = Carbon::today();
echo $today; // 2024-11-13 00:00:00
echo $today; // 2024-11-15 00:00:00
echo "\n";
$tomorrow = Carbon::tomorrow('Europe/London');
echo $tomorrow; // 2024-11-14 00:00:00
echo $tomorrow; // 2024-11-16 00:00:00
echo "\n";
$yesterday = Carbon::yesterday();
echo $yesterday; // 2024-11-12 00:00:00
echo $yesterday; // 2024-11-14 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 20:38 right now in Johannesburg.
echo "It's ".$meeting->nowWithSameTz()->format('H:i').' right now in Johannesburg.'; // It's 02:26 right now in Johannesburg.
</code></pre>
</p>

Expand Down Expand Up @@ -705,7 +705,7 @@ <h1 id="api-localization">Localization</h1>
echo "\n";
echo $date->monthName; // novembre
echo "\n";
echo $date->isoFormat('LLLL'); // mercredi 13 novembre 2024 18:38
echo $date->isoFormat('LLLL'); // vendredi 15 novembre 2024 00:26
</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 à 19:38
Aujourd’hui à 01:26
*/

echo $notificationForJohn;
/*
Jun 15, 2018 7:34 AM
Today at 12:38 PM
Today at 6:26 PM
*/
</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'); // 13/11 9h Asia/Tokyo
echo Carbon::today()->setTimezone('Asia/Tokyo')->format('d/m G\h e'); // 15/11 9h Asia/Tokyo
echo "\n";
echo Carbon::today()->shiftTimezone('Asia/Tokyo')->format('d/m G\h e'); // 13/11 0h Asia/Tokyo
echo Carbon::today()->shiftTimezone('Asia/Tokyo')->format('d/m G\h e'); // 15/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 6:38 PM
echo $date->calendar(); // Today at 12:26 AM
echo "\n";
echo $date->sub('1 day 3 hours')->calendar(); // Yesterday at 3:38 PM
echo $date->sub('1 day 3 hours')->calendar(); // Last Wednesday at 9:26 PM
echo "\n";
echo $date->sub('3 days 10 hours 23 minutes')->calendar(); // Last Sunday at 8:15 AM
echo $date->sub('3 days 10 hours 23 minutes')->calendar(); // Last Monday at 2:03 PM
echo "\n";
echo $date->sub('8 days')->calendar(); // 11/05/2024
echo $date->sub('8 days')->calendar(); // 11/07/2024
echo "\n";
echo $date->add('1 day 3 hours')->calendar(); // Tomorrow at 9:38 PM
echo $date->add('1 day 3 hours')->calendar(); // Tomorrow at 3:26 AM
echo "\n";
echo $date->add('3 days 10 hours 23 minutes')->calendar(); // Sunday at 5:01 AM
echo $date->add('3 days 10 hours 23 minutes')->calendar(); // Monday at 10:49 AM
echo "\n";
echo $date->add('8 days')->calendar(); // 11/21/2024
echo $date->add('8 days')->calendar(); // 11/23/2024
echo "\n";
echo $date->locale('fr')->calendar(); // Aujourd’hui à 18:38
echo $date->locale('fr')->calendar(); // Aujourd’hui à 00:26
</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-11-13 18:38:29
echo Carbon::now(); // 2024-11-15 00:26:57
// Instead of mock and clear mock, you also can use withTestNow():

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

// Returns timezone as CarbonTimeZone
var_dump(Carbon::createFromTimestamp(0, 'Europe/Paris')->getTimezone());
/* object(Carbon\CarbonTimeZone)#1152 (3) {
/* object(Carbon\CarbonTimeZone)#2699 (3) {
["clock":"Carbon\CarbonTimeZone":private]=>
NULL
["timezone_type"]=>
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(29)
var_dump(Carbon::now()->get($unit)); // int(57)
// equivalent to:
var_dump(Carbon::now()->$unit); // int(29)
var_dump(Carbon::now()->$unit); // int(57)
// If you have plural unit name, use singularUnit()
$unit = Carbon::singularUnit('seconds');
var_dump(Carbon::now()->get($unit)); // int(29)
var_dump(Carbon::now()->get($unit)); // int(57)
// 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 @@ -6176,7 +6176,7 @@ <h1 id="api-conversion">Conversion</h1>
["formatted"]=>
string(19) "2019-02-01 03:45:27"
["timezone"]=>
object(Carbon\CarbonTimeZone)#1162 (3) {
object(Carbon\CarbonTimeZone)#1166 (3) {
["clock":"Carbon\CarbonTimeZone":private]=>
NULL
["timezone_type"]=>
Expand All @@ -6189,7 +6189,7 @@ <h1 id="api-conversion">Conversion</h1>

var_dump($dt->toObject());
/*
object(stdClass)#1162 (12) {
object(stdClass)#1166 (12) {
["year"]=>
int(2019)
["month"]=>
Expand All @@ -6213,7 +6213,7 @@ <h1 id="api-conversion">Conversion</h1>
["formatted"]=>
string(19) "2019-02-01 03:45:27"
["timezone"]=>
object(Carbon\CarbonTimeZone)#536 (3) {
object(Carbon\CarbonTimeZone)#1163 (3) {
["clock":"Carbon\CarbonTimeZone":private]=>
NULL
["timezone_type"]=>
Expand All @@ -6226,7 +6226,7 @@ <h1 id="api-conversion">Conversion</h1>

var_dump($dt->toDate()); // Same as $dt->toDateTime()
/*
object(DateTime)#1162 (3) {
object(DateTime)#1166 (3) {
["date"]=>
string(26) "2019-02-01 03:45:27.612584"
["timezone_type"]=>
Expand All @@ -6240,7 +6240,7 @@ <h1 id="api-conversion">Conversion</h1>
// to both DateTime and DateTimeImmutable
var_dump($dt->toDateTimeImmutable());
/*
object(DateTimeImmutable)#1161 (3) {
object(DateTimeImmutable)#856 (3) {
["date"]=>
string(26) "2019-02-01 03:45:27.612584"
["timezone_type"]=>
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-11-13 18:38:29
echo $dt1->maximum(); // 2024-11-13 18:38:29
echo $dt1->max(); // 2024-11-15 00:26:57
echo $dt1->maximum(); // 2024-11-15 00:26:57

// 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')); // 1.0E-5
<pre><code class="php">echo Carbon::now('America/Vancouver')->diffInSeconds(Carbon::now('Europe/London')); // 4.0E-6

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

$date = Carbon::now()->addSeconds(3666);

echo $date->diffInSeconds(); // -3665.999868
echo $date->diffInMinutes(); // -61.099996066667
echo $date->diffInHours(); // -1.0183332433333
echo $date->diffInDays(); // -0.042430550821759
echo $date->diffInSeconds(); // -3665.999954
echo $date->diffInMinutes(); // -61.099998516667
echo $date->diffInHours(); // -1.0183332986111
echo $date->diffInDays(); // -0.042430553703704

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

Expand Down Expand Up @@ -7574,9 +7574,9 @@ <h1 id="api-serialization">Serialization</h1>
<p>
<pre><code class="php">$dt = Carbon::create(2012, 12, 25, 20, 30, 00, 'Europe/Moscow');

echo serialize($dt); // O:13:"Carbon\Carbon":3:{s:4:"date";s:26:"2012-12-25 20:30:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/Moscow";}
echo serialize($dt); // O:13:"Carbon\Carbon":4:{s:4:"date";s:26:"2012-12-25 20:30:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/Moscow";s:18:"dumpDateProperties";a:2:{s:4:"date";s:26:"2012-12-25 20:30:00.000000";s:8:"timezone";s:13:"Europe/Moscow";}}
// same as:
echo $dt->serialize(); // O:13:"Carbon\Carbon":3:{s:4:"date";s:26:"2012-12-25 20:30:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/Moscow";}
echo $dt->serialize(); // O:13:"Carbon\Carbon":4:{s:4:"date";s:26:"2012-12-25 20:30:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/Moscow";s:18:"dumpDateProperties";a:2:{s:4:"date";s:26:"2012-12-25 20:30:00.000000";s:8:"timezone";s:13:"Europe/Moscow";}}

$dt = 'O:13:"Carbon\Carbon":3:{s:4:"date";s:26:"2012-12-25 20:30:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/Moscow";}';

Expand Down Expand Up @@ -7706,7 +7706,7 @@ <h1 id="api-macro">Macro</h1>
echo "\n";
echo Carbon::tomorrow()->formatForUser(); // Demain à 01:00
echo "\n";
echo Carbon::now()->subDays(3)->formatForUser(); // dimanche dernier à 19:38
echo Carbon::now()->subDays(3)->formatForUser(); // mardi dernier à 01:26
</code></pre>
</p>

Expand Down Expand Up @@ -7971,7 +7971,7 @@ <h1 id="api-macro">Macro</h1>

dumpDateList(Carbon::getCurrentWeekDays()); // 2024-11-11 00:00:00, 2024-11-12 00:00:00, 2024-11-13 00:00:00, 2024-11-14 00:00:00, 2024-11-15 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-10-07 00:00:00, 2024-10-08 00:00:00, 2024-10-09 00:00:00, 2024-10-10 00:00:00, 2024-10-11 00:00...
dumpDateList(Carbon::now()->subMonth()->getCurrentWeekDays()); // 2024-10-14 00:00:00, 2024-10-15 00:00:00, 2024-10-16 00:00:00, 2024-10-17 00:00:00, 2024-10-18 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 @@ -8951,7 +8951,7 @@ <h1 id="api-period">CarbonPeriod</h1>
$days[] = $date->format('Y-m-d');
}

echo implode(', ', $days); // 2024-11-13, 2024-11-14, 2024-11-15
echo implode(', ', $days); // 2024-11-15, 2024-11-16, 2024-11-17
</code></pre>
</p>

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ <h2 id="backers">Backers</h2>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Real Targeted Traffic" href="https://www.seo25.com/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="Real Targeted Traffic" src="https://logo.clearbit.com/seo25.com" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="TargetedVisitors" href="https://www.targetedwebtraffic.com/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="TargetedVisitors" src="https://opencollective-production.s3.us-west-1.amazonaws.com/80325590-380f-11ec-9460-9b81799a208f.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="BB Creative Solutions" href="https://opencollective.com/bb-creative-solutions?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="BB Creative Solutions" src="https://images.opencollective.com/bb-creative-solutions/avatar/256.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="At TikTokFame, we take immense pride in our role as the premier platform for boosting TikTok engagement. Our expertise lies in enhancing likes." href="https://tiktokfame.co/buy-tiktok-followers/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="TikTokFame" src="https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/32ddc473-84f6-46df-8b5b-0fe04eedce2e/New%20Project%20(30).png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Helping people" href="https://glitteringgenerality.com?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="GlitteringGenerality" src="https://images.opencollective.com/glitteringgeneralityy/avatar/256.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Wagerbit" href="https://reddit.com/r/wagerbit?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="Wagerbit" src="https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/b8b578f6-e292-4670-b904-b8c0da9a7350/Wagerbit%20reddit.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="People Search" href="https://identor.com/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="People Search" src="https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/1390e8dd-8742-49dd-b23b-2f2bca11cf51/identor-white-250-250-1.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Sunset City Mushrooms" href="https://www.sunsetcity.ca/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="Sunset City Mushrooms" src="https://logo.clearbit.com/www.sunsetcity.ca" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="At TikTokFame, we take immense pride in our role as the premier platform for boosting TikTok engagement. Our expertise lies in enhancing likes." href="https://tiktokfame.co/buy-tiktok-followers/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="TikTokFame" src="https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/32ddc473-84f6-46df-8b5b-0fe04eedce2e/New%20Project%20(30).png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Salesforce" href="https://engineering.salesforce.com?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="Salesforce" src="https://opencollective-production.s3.us-west-1.amazonaws.com/24d34880-df8d-11e9-949c-6bc2037b6bd5.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="Free and anonymous Instagram Story Viewer &amp; Downloader, you may see videos, pictures, and more from anybody you&#039;re interested in quietly and securely" href="https://insnoop.com/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="Instagram Story Viewer" src="https://images.opencollective.com/insta-story-viewer/avatar/256.png" width="24" height="24"></a>
<a style="position: relative; margin: 3px; display: inline-block; border: 3px solid transparent; border-radius: 50%; overflow: hidden;" title="IG Downloader is an Instagram Downloader service that offers a variety of tools to download Instagram content for free. Listed below are all the tools" href="https://indownloader.app/?utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon" target="_blank"><img alt="IG Downloader" src="https://logo.clearbit.com/indownloader.app" width="24" height="24"></a>
Expand Down
6 changes: 4 additions & 2 deletions tools/generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ function getAllBackers(): array
}

$isYearly = str_contains(strtolower($member['tier'] ?? ''), 'yearly');
$monthlyContribution = (float) ($isYearly && $lastTransactionAt > CarbonImmutable::parse('-1 year')
$monthlyContribution = (float) (
$isYearly && $lastTransactionAt > CarbonImmutable::parse('-1 year')
? ($member['lastTransactionAmount'] / 11.2) // 11.2 instead of 12 to include the discount for yearly subscription
: ($member['totalAmountDonated'] / ceil($createdAt->floatDiffInMonths()))
);
Expand All @@ -333,7 +334,8 @@ function getAllBackers(): array
}
}

$yearlyContribution = (float) ($isYearly
$yearlyContribution = (float) (
$isYearly
? (12 * $monthlyContribution)
: ($member['totalAmountDonated'] / max(1, $createdAt->floatDiffInYears()))
);
Expand Down

0 comments on commit b8f0e6b

Please sign in to comment.