the whole shebang
This commit is contained in:
2
vendor/nesbot/carbon/.gitignore
vendored
Normal file
2
vendor/nesbot/carbon/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
vendor
|
||||
composer.phar
|
11
vendor/nesbot/carbon/.travis.yml
vendored
Normal file
11
vendor/nesbot/carbon/.travis.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
|
||||
before_script:
|
||||
- composer install
|
||||
|
||||
script: phpunit --coverage-text
|
19
vendor/nesbot/carbon/LICENSE
vendored
Normal file
19
vendor/nesbot/carbon/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (C) Brian Nesbitt
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
27
vendor/nesbot/carbon/composer.json
vendored
Normal file
27
vendor/nesbot/carbon/composer.json
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"type": "library",
|
||||
"description": "A simple API extension for DateTime.",
|
||||
"keywords": [
|
||||
"date",
|
||||
"time",
|
||||
"DateTime"
|
||||
],
|
||||
"homepage": "https://github.com/briannesbitt/Carbon",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Brian Nesbitt",
|
||||
"email": "brian@nesbot.com",
|
||||
"homepage": "http://nesbot.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Carbon": "src"
|
||||
}
|
||||
}
|
||||
}
|
41
vendor/nesbot/carbon/history.md
vendored
Normal file
41
vendor/nesbot/carbon/history.md
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
1.3.0 / 2013-08-21
|
||||
==================
|
||||
|
||||
* Added modifier methods firstOfMonth(), lastOfMonth(), nthOfMonth(), next(), previous(), and so on
|
||||
* Added modifiers startOfWeek() and endOfWeek()
|
||||
* Added testing helpers to allow mocking of new Carbon(), new Carbon('now') and Carbon::now()
|
||||
* Added formatLocalized() to format a string using strftime() with the current locale
|
||||
* Improved diffInSeconds()
|
||||
* Improved [add|sub][Years|Months|Days|Hours|Minutes|Seconds|Weeks]
|
||||
* Docblocks everywhere ;(
|
||||
* Magic class properties
|
||||
* Added PHP 5.5 to travis test coverage
|
||||
* General Code cleanup
|
||||
|
||||
1.2.0 / 2012-10-14
|
||||
==================
|
||||
|
||||
* Added history.md
|
||||
* Implemented __isset() (thanks @flevour)
|
||||
* Simplified tomorrow()/yesterday() to rely on today()... more DRY
|
||||
* Simplified __set() and fixed exception text
|
||||
* Updated readme
|
||||
|
||||
1.1.0 / 2012-09-16
|
||||
==================
|
||||
|
||||
* Updated composer.json
|
||||
* Added better error messaging for failed readme generation
|
||||
* Fixed readme typos
|
||||
* Added static helpers `today()`, `tomorrow()`, `yesterday()`
|
||||
* Simplified `now()` code
|
||||
|
||||
1.0.1 / 2012-09-10
|
||||
==================
|
||||
|
||||
* Added travis-ci.org
|
||||
|
||||
1.0.0 / 2012-09-10
|
||||
==================
|
||||
|
||||
* Initial release
|
25
vendor/nesbot/carbon/phpunit.xml.dist
vendored
Normal file
25
vendor/nesbot/carbon/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="tests/TestFixture.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>src/Carbon</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Carbon Test Suite">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
768
vendor/nesbot/carbon/readme.md
vendored
Normal file
768
vendor/nesbot/carbon/readme.md
vendored
Normal file
@@ -0,0 +1,768 @@
|
||||
> **This file is autogenerated. Please see the [Contributing](#about-contributing) section from more information.**
|
||||
|
||||
# Carbon
|
||||
|
||||
[](http://travis-ci.org/briannesbitt/Carbon)
|
||||
|
||||
A simple API extension for DateTime with PHP 5.3+
|
||||
|
||||
```php
|
||||
printf("Right now is %s", Carbon::now()->toDateTimeString());
|
||||
printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver')); //implicit __toString()
|
||||
$tomorrow = Carbon::now()->addDay();
|
||||
$lastWeek = Carbon::now()->subWeek();
|
||||
$nextSummerOlympics = Carbon::createFromDate(2012)->addYears(4);
|
||||
|
||||
$officialDate = Carbon::now()->toRFC2822String();
|
||||
|
||||
$howOldAmI = Carbon::createFromDate(1975, 5, 21)->age;
|
||||
|
||||
$noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London');
|
||||
|
||||
$worldWillEnd = Carbon::createFromDate(2012, 12, 21, 'GMT');
|
||||
|
||||
// Don't really want to die so mock now
|
||||
Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1));
|
||||
|
||||
// comparisons are always done in UTC
|
||||
if (Carbon::now()->gte($worldWillEnd)) {
|
||||
die();
|
||||
}
|
||||
|
||||
// Phew! Return to normal behaviour
|
||||
Carbon::setTestNow();
|
||||
|
||||
if (Carbon::now()->isWeekend()) {
|
||||
echo 'Party!';
|
||||
}
|
||||
echo Carbon::now()->subMinutes(2)->diffForHumans(); // '2 minutes ago'
|
||||
|
||||
// ... but also does 'from now', 'after' and 'before'
|
||||
// rolling up to seconds, minutes, hours, days, months, years
|
||||
|
||||
$daysSinceEpoch = Carbon::createFromTimeStamp(0)->diffInDays();
|
||||
```
|
||||
|
||||
## README Contents
|
||||
|
||||
* [Installation](#install)
|
||||
* [Requirements](#requirements)
|
||||
* [With composer](#install-composer)
|
||||
* [Without composer](#install-nocomposer)
|
||||
* [API](#api)
|
||||
* [Instantiation](#api-instantiation)
|
||||
* [Testing Aids](#api-testing)
|
||||
* [Getters](#api-getters)
|
||||
* [Setters](#api-setters)
|
||||
* [Fluent Setters](#api-settersfluent)
|
||||
* [IsSet](#api-isset)
|
||||
* [String Formatting and Localization](#api-formatting)
|
||||
* [Common Formats](#api-commonformats)
|
||||
* [Comparison](#api-comparison)
|
||||
* [Addition and Subtraction](#api-addsub)
|
||||
* [Difference](#api-difference)
|
||||
* [Difference for Humans](#api-humandiff)
|
||||
* [Modifiers](#api-modifiers)
|
||||
* [Constants](#api-constants)
|
||||
* [About](#about)
|
||||
* [Contributing](#about-contributing)
|
||||
* [Author](#about-author)
|
||||
* [License](#about-license)
|
||||
* [History](#about-history)
|
||||
* [Why the name Carbon?](#about-whyname)
|
||||
|
||||
<a name="install"/>
|
||||
## Installation
|
||||
|
||||
<a name="requirements"/>
|
||||
### Requirements
|
||||
|
||||
- Any flavour of PHP 5.3+ should do
|
||||
- [optional] PHPUnit to execute the test suite
|
||||
|
||||
<a name="install-composer"/>
|
||||
### With Composer
|
||||
|
||||
The easiest way to install Carbon is via [composer](http://getcomposer.org/). Create the following `composer.json` file and run the `php composer.phar install` command to install it.
|
||||
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"nesbot/Carbon": "*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```php
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
printf("Now: %s", Carbon::now());
|
||||
```
|
||||
|
||||
<a name="install-nocomposer"/>
|
||||
### Without Composer
|
||||
|
||||
Why are you not using [composer](http://getcomposer.org/)? Download [Carbon.php](https://github.com/briannesbitt/Carbon/blob/master/Carbon/Carbon.php) from the repo and save the file into your project path somewhere.
|
||||
|
||||
```php
|
||||
<?php
|
||||
require 'path/to/Carbon.php';
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
printf("Now: %s", Carbon::now());
|
||||
```
|
||||
|
||||
<a name="api"/>
|
||||
## API
|
||||
|
||||
The Carbon class is [inherited](http://php.net/manual/en/keyword.extends.php) from the PHP [DateTime](http://www.php.net/manual/en/class.datetime.php) class.
|
||||
|
||||
```php
|
||||
<?php
|
||||
class Carbon extends \DateTime
|
||||
{
|
||||
// code here
|
||||
}
|
||||
```
|
||||
|
||||
Carbon has all of the functions inherited from the base DateTime class. This approach allows you to access the base functionality if you see anything missing in Carbon but is there in DateTime.
|
||||
|
||||
> **Note: I live in Ottawa, Ontario, Canada and if the timezone is not specified in the examples then the default of 'America/Toronto' is to be assumed. Typically Ottawa is -0500 but when daylight savings time is on we are -0400.**
|
||||
|
||||
Special care has been taken to ensure timezones are handled correctly, and where appropriate are based on the underlying DateTime implementation. For example all comparisons are done in UTC or in the timezone of the datetime being used.
|
||||
|
||||
```php
|
||||
$dtToronto = Carbon::createFromDate(2012, 1, 1, 'America/Toronto');
|
||||
$dtVancouver = Carbon::createFromDate(2012, 1, 1, 'America/Vancouver');
|
||||
|
||||
echo $dtVancouver->diffInHours($dtToronto); // 3
|
||||
```
|
||||
|
||||
Also `is` comparisons are done in the timezone of the provided Carbon instance. For example my current timezone is -13 hours from Tokyo. So `Carbon::now('Asia/Tokyo')->isToday()` would only return false for any time past 1 PM my time. This doesn't make sense since `now()` in tokyo is always today in Tokyo. Thus the comparison to `now()` is done in the same timezone as the current instance.
|
||||
|
||||
<a name="api-instantiation"/>
|
||||
### Instantiation
|
||||
|
||||
There are several different methods available to create a new instance of Carbon. First there is a constructor. It overrides the [parent constructor](http://www.php.net/manual/en/datetime.construct.php) and you are best to read about the first parameter from the PHP manual and understand the date/time string formats it accepts. You'll hopefully find yourself rarely using the constructor but rather relying on the explicit static methods for improved readability.
|
||||
|
||||
```php
|
||||
$carbon = new Carbon(); // equivalent to Carbon::now()
|
||||
$carbon = new Carbon('first day of January 2008', 'America/Vancouver');
|
||||
echo get_class($carbon); // 'Carbon\Carbon'
|
||||
```
|
||||
|
||||
You'll notice above that the timezone (2nd) parameter was passed as a string rather than a `\DateTimeZone` instance. All DateTimeZone parameters have been augmented so you can pass a DateTimeZone instance or a string and the timezone will be created for you. This is again shown in the next example which also introduces the `now()` function.
|
||||
|
||||
```php
|
||||
$now = Carbon::now();
|
||||
|
||||
$nowInLondonTz = Carbon::now(new DateTimeZone('Europe/London'));
|
||||
|
||||
// or just pass the timezone as a string
|
||||
$nowInLondonTz = Carbon::now('Europe/London');
|
||||
```
|
||||
|
||||
If you really love your fluid method calls and get frustrated by the extra line or ugly pair of brackets necessary when using the constructor you'll enjoy the `parse` method.
|
||||
|
||||
```php
|
||||
echo (new Carbon('first day of December 2008'))->addWeeks(2); // 2008-12-15 00:00:00
|
||||
echo Carbon::parse('first day of December 2008')->addWeeks(2); // 2008-12-15 00:00:00
|
||||
```
|
||||
|
||||
To accompany `now()`, a few other static instantiation helpers exist to create widely known instances. The only thing to really notice here is that `today()`, `tomorrow()` and `yesterday()`, besides behaving as expected, all accept a timezone parameter and each has their time value set to `00:00:00`.
|
||||
|
||||
```php
|
||||
$now = Carbon::now();
|
||||
echo $now; // 2013-08-21 00:33:54
|
||||
$today = Carbon::today();
|
||||
echo $today; // 2013-08-21 00:00:00
|
||||
$tomorrow = Carbon::tomorrow('Europe/London');
|
||||
echo $tomorrow; // 2013-08-22 00:00:00
|
||||
$yesterday = Carbon::yesterday();
|
||||
echo $yesterday; // 2013-08-20 00:00:00
|
||||
```
|
||||
|
||||
The next group of static helpers are the `createXXX()` helpers. Most of the static `create` functions allow you to provide as many or as few arguments as you want and will provide default values for all others. Generally default values are the current date, time or timezone. Higher values will wrap appropriately but invalid values will throw an `InvalidArgumentException` with an informative message. The message is obtained from an [DateTime::getLastErrors()](http://php.net/manual/en/datetime.getlasterrors.php) call.
|
||||
|
||||
```php
|
||||
Carbon::createFromDate($year, $month, $day, $tz);
|
||||
Carbon::createFromTime($hour, $minute, $second, $tz);
|
||||
Carbon::create($year, $month, $day, $hour, $minute, $second, $tz);
|
||||
```
|
||||
|
||||
`createFromDate()` will default the time to now. `createFromTime()` will default the date to today. `create()` will default any null parameter to the current respective value. As before, the `$tz` defaults to the current timezone and otherwise can be a DateTimeZone instance or simply a string timezone value. The only special case for default values (mimicking the underlying PHP library) occurs when an hour value is specified but no minutes or seconds, they will get defaulted to 0.
|
||||
|
||||
```php
|
||||
$xmasThisYear = Carbon::createFromDate(null, 12, 25); // Year defaults to current year
|
||||
$Y2K = Carbon::create(2000, 1, 1, 0, 0, 0);
|
||||
$alsoY2K = Carbon::create(1999, 12, 31, 24);
|
||||
$noonLondonTz = Carbon::createFromTime(12, 0, 0, 'Europe/London');
|
||||
|
||||
// A two digit minute could not be found
|
||||
try { Carbon::create(1975, 5, 21, 22, -2, 0); } catch(InvalidArgumentException $x) { echo $x->getMessage(); }
|
||||
```
|
||||
|
||||
```php
|
||||
Carbon::createFromFormat($format, $time, $tz);
|
||||
```
|
||||
|
||||
`createFromFormat()` is mostly a wrapper for the base php function [DateTime::createFromFormat](http://php.net/manual/en/datetime.createfromformat.php). The difference being again the `$tz` argument can be a DateTimeZone instance or a string timezone value. Also, if there are errors with the format this function will call the `DateTime::getLastErrors()` method and then throw a `InvalidArgumentException` with the errors as the message. If you look at the source for the `createXX()` functions above, they all make a call to `createFromFormat()`.
|
||||
|
||||
```php
|
||||
echo Carbon::createFromFormat('Y-m-d H', '1975-05-21 22')->toDateTimeString(); // 1975-05-21 22:00:00
|
||||
```
|
||||
|
||||
The final two create functions are for working with [unix timestamps](http://en.wikipedia.org/wiki/Unix_time). The first will create a Carbon instance equal to the given timestamp and will set the timezone as well or default it to the current timezone. The second, `createFromTimestampUTC()`, is different in that the timezone will remain UTC (GMT). The second acts the same as `Carbon::createFromFormat('@'.$timestamp)` but I have just made it a little more explicit. Negative timestamps are also allowed.
|
||||
|
||||
```php
|
||||
echo Carbon::createFromTimeStamp(-1)->toDateTimeString(); // 1969-12-31 18:59:59
|
||||
echo Carbon::createFromTimeStamp(-1, 'Europe/London')->toDateTimeString(); // 1970-01-01 00:59:59
|
||||
echo Carbon::createFromTimeStampUTC(-1)->toDateTimeString(); // 1969-12-31 23:59:59
|
||||
```
|
||||
|
||||
You can also create a `copy()` of an existing Carbon instance. As expected the date, time and timezone values are all copied to the new instance.
|
||||
|
||||
```php
|
||||
$dt = Carbon::now();
|
||||
echo $dt->diffInYears($dt->copy()->addYear()); // 1
|
||||
|
||||
// $dt was unchanged and still holds the value of Carbon:now()
|
||||
```
|
||||
|
||||
Finally, if you find yourself inheriting a `\DateTime` instance from another library, fear not! You can create a `Carbon` instance via a friendly `instance()` function.
|
||||
|
||||
```php
|
||||
$dt = new \DateTime('first day of January 2008'); // <== instance from another API
|
||||
$carbon = Carbon::instance($dt);
|
||||
echo get_class($carbon); // 'Carbon\Carbon'
|
||||
echo $carbon->toDateTimeString(); // 2008-01-01 00:00:00
|
||||
```
|
||||
|
||||
<a name="api-testing"/>
|
||||
### Testing Aids
|
||||
|
||||
The testing methods allow you to set a Carbon instance (real or mock) to be returned when a "now" instance is created. The provided instance will be returned specifically under the following conditions:
|
||||
- A call to the static now() method, ex. Carbon::now()
|
||||
- When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
|
||||
- When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
|
||||
|
||||
```php
|
||||
$knownDate = Carbon::create(2001, 5, 21, 12); // create testing date
|
||||
Carbon::setTestNow($knownDate); // set the mock (of course this could be a real mock object)
|
||||
echo Carbon::now(); // 2001-05-21 12:00:00
|
||||
echo new Carbon(); // 2001-05-21 12:00:00
|
||||
echo Carbon::parse(); // 2001-05-21 12:00:00
|
||||
echo new Carbon('now'); // 2001-05-21 12:00:00
|
||||
echo Carbon::parse('now'); // 2001-05-21 12:00:00
|
||||
var_dump(Carbon::hasTestNow()); // bool(true)
|
||||
Carbon::setTestNow(); // clear the mock
|
||||
var_dump(Carbon::hasTestNow()); // bool(false)
|
||||
echo Carbon::now(); // 2013-08-21 00:33:54
|
||||
```
|
||||
|
||||
A more meaning full example:
|
||||
|
||||
```php
|
||||
class SeasonalProduct
|
||||
{
|
||||
protected $price;
|
||||
|
||||
public function __construct($price)
|
||||
{
|
||||
$this->price = $price;
|
||||
}
|
||||
|
||||
public function getPrice() {
|
||||
$multiplier = 1;
|
||||
if (Carbon::now()->month == 12) {
|
||||
$multiplier = 2;
|
||||
}
|
||||
|
||||
return $this->price * $multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
$product = new SeasonalProduct(100);
|
||||
Carbon::setTestNow(Carbon::parse('first day of March 2000'));
|
||||
echo $product->getPrice(); // 100
|
||||
Carbon::setTestNow(Carbon::parse('first day of December 2000'));
|
||||
echo $product->getPrice(); // 200
|
||||
Carbon::setTestNow(Carbon::parse('first day of May 2000'));
|
||||
echo $product->getPrice(); // 100
|
||||
Carbon::setTestNow();
|
||||
```
|
||||
|
||||
<a name="api-getters"/>
|
||||
### Getters
|
||||
|
||||
The getters are implemented via PHP's `__get()` method. This enables you to access the value as if it was a property rather than a function call.
|
||||
|
||||
```php
|
||||
$dt = Carbon::create(2012, 9, 5, 23, 26, 11);
|
||||
|
||||
// These getters specifically return integers, ie intval()
|
||||
var_dump($dt->year); // int(2012)
|
||||
var_dump($dt->month); // int(9)
|
||||
var_dump($dt->day); // int(5)
|
||||
var_dump($dt->hour); // int(23)
|
||||
var_dump($dt->minute); // int(26)
|
||||
var_dump($dt->second); // int(11)
|
||||
var_dump($dt->dayOfWeek); // int(3)
|
||||
var_dump($dt->dayOfYear); // int(248)
|
||||
var_dump($dt->weekOfYear); // int(36)
|
||||
var_dump($dt->daysInMonth); // int(30)
|
||||
var_dump($dt->timestamp); // int(1346901971)
|
||||
var_dump(Carbon::createFromDate(1975, 5, 21)->age); // int(38) calculated vs now in the same tz
|
||||
var_dump($dt->quarter); // int(3)
|
||||
|
||||
// Returns an int of seconds difference from UTC (+/- sign included)
|
||||
var_dump(Carbon::createFromTimestampUTC(0)->offset); // int(0)
|
||||
var_dump(Carbon::createFromTimestamp(0)->offset); // int(-18000)
|
||||
|
||||
// Returns an int of hours difference from UTC (+/- sign included)
|
||||
var_dump(Carbon::createFromTimestamp(0)->offsetHours); // int(-5)
|
||||
|
||||
// Indicates if day light savings time is on
|
||||
var_dump(Carbon::createFromDate(2012, 1, 1)->dst); // bool(false)
|
||||
|
||||
// Gets the DateTimeZone instance
|
||||
echo get_class(Carbon::now()->timezone); // DateTimeZone
|
||||
echo get_class(Carbon::now()->tz); // DateTimeZone
|
||||
|
||||
// Gets the DateTimeZone instance name, shortcut for ->timezone->getName()
|
||||
echo Carbon::now()->timezoneName; // America/Toronto
|
||||
echo Carbon::now()->tzName; // America/Toronto
|
||||
```
|
||||
|
||||
<a name="api-setters"/>
|
||||
### Setters
|
||||
|
||||
The following setters are implemented via PHP's `__set()` method. Its good to take note here that none of the setters, with the obvious exception of explicitly setting the timezone, will change the timezone of the instance. Specifically, setting the timestamp will not set the corresponding timezone to UTC.
|
||||
|
||||
```php
|
||||
$dt = Carbon::now();
|
||||
|
||||
$dt->year = 1975;
|
||||
$dt->month = 13; // would force year++ and month = 1
|
||||
$dt->month = 5;
|
||||
$dt->day = 21;
|
||||
$dt->hour = 22;
|
||||
$dt->minute = 32;
|
||||
$dt->second = 5;
|
||||
|
||||
$dt->timestamp = 169957925; // This will not change the timezone
|
||||
|
||||
// Set the timezone via DateTimeZone instance or string
|
||||
$dt->timezone = new DateTimeZone('Europe/London');
|
||||
$dt->timezone = 'Europe/London';
|
||||
$dt->tz = 'Europe/London';
|
||||
```
|
||||
|
||||
<a name="api-settersfluent"/>
|
||||
### Fluent Setters
|
||||
|
||||
No arguments are optional for the setters, but there are enough variety in the function definitions that you shouldn't need them anyway. Its good to take note here that none of the setters, with the obvious exception of explicitly setting the timezone, will change the timezone of the instance. Specifically, setting the timestamp will not set the corresponding timezone to UTC.
|
||||
|
||||
```php
|
||||
$dt = Carbon::now();
|
||||
|
||||
$dt->year(1975)->month(5)->day(21)->hour(22)->minute(32)->second(5)->toDateTimeString();
|
||||
$dt->setDate(1975, 5, 21)->setTime(22, 32, 5)->toDateTimeString();
|
||||
$dt->setDateTime(1975, 5, 21, 22, 32, 5)->toDateTimeString();
|
||||
|
||||
$dt->timestamp(169957925)->timezone('Europe/London');
|
||||
|
||||
$dt->tz('America/Toronto')->setTimezone('America/Vancouver');
|
||||
```
|
||||
|
||||
<a name="api-isset"/>
|
||||
### IsSet
|
||||
|
||||
The PHP function `__isset()` is implemented. This was done as some external systems (ex. [Twig](http://twig.sensiolabs.org/doc/recipes.html#using-dynamic-object-properties)) validate the existence of a property before using it. This is done using the `isset()` or `empty()` method. You can read more about these on the PHP site: [__isset()](http://www.php.net/manual/en/language.oop5.overloading.php#object.isset), [isset()](http://www.php.net/manual/en/function.isset.php), [empty()](http://www.php.net/manual/en/function.empty.php).
|
||||
|
||||
```php
|
||||
var_dump(isset(Carbon::now()->iDoNotExist)); // bool(false)
|
||||
var_dump(isset(Carbon::now()->hour)); // bool(true)
|
||||
var_dump(empty(Carbon::now()->iDoNotExist)); // bool(true)
|
||||
var_dump(empty(Carbon::now()->year)); // bool(false)
|
||||
```
|
||||
|
||||
<a name="api-formatting"/>
|
||||
### String Formatting and Localization
|
||||
|
||||
All of the available `toXXXString()` methods rely on the base class method [DateTime::format()](http://php.net/manual/en/datetime.format.php). You'll notice the `__toString()` method is defined which allows a Carbon instance to be printed as a pretty date time string when used in a string context.
|
||||
|
||||
```php
|
||||
$dt = Carbon::create(1975, 12, 25, 14, 15, 16);
|
||||
|
||||
var_dump($dt->toDateTimeString() == $dt); // bool(true) => uses __toString()
|
||||
echo $dt->toDateString(); // 1975-12-25
|
||||
echo $dt->toFormattedDateString(); // Dec 25, 1975
|
||||
echo $dt->toTimeString(); // 14:15:16
|
||||
echo $dt->toDateTimeString(); // 1975-12-25 14:15:16
|
||||
echo $dt->toDayDateTimeString(); // Thu, Dec 25, 1975 2:15 PM
|
||||
|
||||
// ... of course format() is still available
|
||||
echo $dt->format('l jS \\of F Y h:i:s A'); // Thursday 25th of December 1975 02:15:16 PM
|
||||
```
|
||||
|
||||
Unfortunately the base class DateTime does not have any localization support. To begin localization support a `formatLocalized($format)` method has been added. The implementation makes a call to [strftime](http://www.php.net/strftime) using the current instance timestamp. If you first set the current locale with [setlocale()](http://www.php.net/setlocale) then the string returned will be formatted in the correct locale.
|
||||
|
||||
```php
|
||||
setlocale(LC_TIME, 'German');
|
||||
echo $dt->formatLocalized('%A %d %B %Y'); // Donnerstag 25 Dezember 1975
|
||||
setlocale(LC_TIME, '');
|
||||
echo $dt->formatLocalized('%A %d %B %Y'); // Thursday 25 December 1975
|
||||
```
|
||||
|
||||
<a name="api-commonformats"/>
|
||||
## Common Formats
|
||||
|
||||
The following are wrappers for the common formats provided in the [DateTime class](http://www.php.net/manual/en/class.datetime.php).
|
||||
|
||||
```php
|
||||
$dt = Carbon::now();
|
||||
|
||||
echo $dt->toATOMString(); // same as $dt->format(DateTime::ATOM);
|
||||
echo $dt->toCOOKIEString();
|
||||
echo $dt->toISO8601String();
|
||||
echo $dt->toRFC822String();
|
||||
echo $dt->toRFC850String();
|
||||
echo $dt->toRFC1036String();
|
||||
echo $dt->toRFC1123String();
|
||||
echo $dt->toRFC2822String();
|
||||
echo $dt->toRFC3339String();
|
||||
echo $dt->toRSSString();
|
||||
echo $dt->toW3CString();
|
||||
```
|
||||
|
||||
<a name="api-comparison"/>
|
||||
### Comparison
|
||||
|
||||
Simple comparison is offered up via the following functions. Remember that the comparison is done in the UTC timezone so things aren't always as they seem.
|
||||
|
||||
```php
|
||||
$first = Carbon::create(2012, 9, 5, 23, 26, 11);
|
||||
$second = Carbon::create(2012, 9, 5, 20, 26, 11, 'America/Vancouver');
|
||||
|
||||
echo $first->toDateTimeString(); // 2012-09-05 23:26:11
|
||||
echo $second->toDateTimeString(); // 2012-09-05 20:26:11
|
||||
|
||||
var_dump($first->eq($second)); // bool(true)
|
||||
var_dump($first->ne($second)); // bool(false)
|
||||
var_dump($first->gt($second)); // bool(false)
|
||||
var_dump($first->gte($second)); // bool(true)
|
||||
var_dump($first->lt($second)); // bool(false)
|
||||
var_dump($first->lte($second)); // bool(true)
|
||||
|
||||
$first->setDateTime(2012, 1, 1, 0, 0, 0);
|
||||
$second->setDateTime(2012, 1, 1, 0, 0, 0); // Remember tz is 'America/Vancouver'
|
||||
|
||||
var_dump($first->eq($second)); // bool(false)
|
||||
var_dump($first->ne($second)); // bool(true)
|
||||
var_dump($first->gt($second)); // bool(false)
|
||||
var_dump($first->gte($second)); // bool(false)
|
||||
var_dump($first->lt($second)); // bool(true)
|
||||
var_dump($first->lte($second)); // bool(true)
|
||||
```
|
||||
|
||||
To determine if the current instance is between two other instances you can use the aptly named `between()` method. The third parameter indicates if an equal to comparison should be done. The default is true which determines if its between or equal to the boundaries.
|
||||
|
||||
```php
|
||||
$first = Carbon::create(2012, 9, 5, 1);
|
||||
$second = Carbon::create(2012, 9, 5, 5);
|
||||
var_dump(Carbon::create(2012, 9, 5, 3)->between($first, $second)); // bool(true)
|
||||
var_dump(Carbon::create(2012, 9, 5, 5)->between($first, $second)); // bool(true)
|
||||
var_dump(Carbon::create(2012, 9, 5, 5)->between($first, $second, false)); // bool(false)
|
||||
```
|
||||
|
||||
To handle the most used cases there are some simple helper functions that hopefully are obvious from their names. For the methods that compare to `now()` (ex. isToday()) in some manner the `now()` is created in the same timezone as the instance.
|
||||
|
||||
```php
|
||||
$dt = Carbon::now();
|
||||
|
||||
$dt->isWeekday();
|
||||
$dt->isWeekend();
|
||||
$dt->isYesterday();
|
||||
$dt->isToday();
|
||||
$dt->isTomorrow();
|
||||
$dt->isFuture();
|
||||
$dt->isPast();
|
||||
$dt->isLeapYear();
|
||||
```
|
||||
|
||||
<a name="api-addsub"/>
|
||||
### Addition and Subtraction
|
||||
|
||||
The default DateTime provides a couple of different methods for easily adding and subtracting time. There is `modify()`, `add()` and `sub()`. `modify()` takes a *magical* date/time format string, 'last day of next month', that it parses and applies the modification while `add()` and `sub()` use a `DateInterval` class thats not so obvious, `new \DateInterval('P6YT5M')`. Hopefully using these fluent functions will be more clear and easier to read after not seeing your code for a few weeks. But of course I don't make you choose since the base class functions are still available.
|
||||
|
||||
```php
|
||||
$dt = Carbon::create(2012, 1, 31, 0);
|
||||
|
||||
echo $dt->toDateTimeString(); // 2012-01-31 00:00:00
|
||||
|
||||
echo $dt->addYears(5); // 2017-01-31 00:00:00
|
||||
echo $dt->addYear(); // 2018-01-31 00:00:00
|
||||
echo $dt->subYear(); // 2017-01-31 00:00:00
|
||||
echo $dt->subYears(5); // 2012-01-31 00:00:00
|
||||
|
||||
echo $dt->addMonths(60); // 2017-01-31 00:00:00
|
||||
echo $dt->addMonth(); // 2017-03-03 00:00:00 equivalent of $dt->month($dt->month + 1); so it wraps
|
||||
echo $dt->subMonth(); // 2017-02-03 00:00:00
|
||||
echo $dt->subMonths(60); // 2012-02-03 00:00:00
|
||||
|
||||
echo $dt->addDays(29); // 2012-03-03 00:00:00
|
||||
echo $dt->addDay(); // 2012-03-04 00:00:00
|
||||
echo $dt->subDay(); // 2012-03-03 00:00:00
|
||||
echo $dt->subDays(29); // 2012-02-03 00:00:00
|
||||
|
||||
echo $dt->addWeekdays(4); // 2012-02-09 00:00:00
|
||||
echo $dt->addWeekday(); // 2012-02-10 00:00:00
|
||||
echo $dt->subWeekday(); // 2012-02-09 00:00:00
|
||||
echo $dt->subWeekdays(4); // 2012-02-03 00:00:00
|
||||
|
||||
echo $dt->addWeeks(3); // 2012-02-24 00:00:00
|
||||
echo $dt->addWeek(); // 2012-03-02 00:00:00
|
||||
echo $dt->subWeek(); // 2012-02-24 00:00:00
|
||||
echo $dt->subWeeks(3); // 2012-02-03 00:00:00
|
||||
|
||||
echo $dt->addHours(24); // 2012-02-04 00:00:00
|
||||
echo $dt->addHour(); // 2012-02-04 01:00:00
|
||||
echo $dt->subHour(); // 2012-02-04 00:00:00
|
||||
echo $dt->subHours(24); // 2012-02-03 00:00:00
|
||||
|
||||
echo $dt->addMinutes(61); // 2012-02-03 01:01:00
|
||||
echo $dt->addMinute(); // 2012-02-03 01:02:00
|
||||
echo $dt->subMinute(); // 2012-02-03 01:01:00
|
||||
echo $dt->subMinutes(61); // 2012-02-03 00:00:00
|
||||
|
||||
echo $dt->addSeconds(61); // 2012-02-03 00:01:01
|
||||
echo $dt->addSecond(); // 2012-02-03 00:01:02
|
||||
echo $dt->subSecond(); // 2012-02-03 00:01:01
|
||||
echo $dt->subSeconds(61); // 2012-02-03 00:00:00
|
||||
```
|
||||
|
||||
For fun you can also pass negative values to `addXXX()`, in fact that's how `subXXX()` is implemented.
|
||||
|
||||
<a name="api-difference"/>
|
||||
### Difference
|
||||
|
||||
These functions always return the **total difference** expressed in the specified time requested. This differs from the base class `diff()` function where an interval of 61 seconds would be returned as 1 minute and 1 second via a `DateInterval` instance. The `diffInMinutes()` function would simply return 1. All values are truncated and not rounded. Each function below has a default first parameter which is the Carbon instance to compare to, or null if you want to use `now()`. The 2nd parameter again is optional and indicates if you want the return value to be the absolute value or a relative value that might have a `-` (negative) sign if the passed in date is less than the current instance. This will default to true, return the absolute value. The comparisons are done in UTC.
|
||||
|
||||
```php
|
||||
// Carbon::diffInYears(Carbon $dt = null, $abs = true)
|
||||
|
||||
echo Carbon::now('America/Vancouver')->diffInSeconds(Carbon::now('Europe/London')); // 0
|
||||
|
||||
$dtOttawa = Carbon::createFromDate(2000, 1, 1, 'America/Toronto');
|
||||
$dtVancouver = Carbon::createFromDate(2000, 1, 1, 'America/Vancouver');
|
||||
echo $dtOttawa->diffInHours($dtVancouver); // 3
|
||||
|
||||
echo $dtOttawa->diffInHours($dtVancouver, false); // 3
|
||||
echo $dtVancouver->diffInHours($dtOttawa, false); // -3
|
||||
|
||||
$dt = Carbon::create(2012, 1, 31, 0);
|
||||
echo $dt->diffInDays($dt->copy()->addMonth()); // 31
|
||||
echo $dt->diffInDays($dt->copy()->subMonth(), false); // -31
|
||||
|
||||
$dt = Carbon::create(2012, 4, 30, 0);
|
||||
echo $dt->diffInDays($dt->copy()->addMonth()); // 30
|
||||
echo $dt->diffInDays($dt->copy()->addWeek()); // 7
|
||||
|
||||
$dt = Carbon::create(2012, 1, 1, 0);
|
||||
echo $dt->diffInMinutes($dt->copy()->addSeconds(59)); // 0
|
||||
echo $dt->diffInMinutes($dt->copy()->addSeconds(60)); // 1
|
||||
echo $dt->diffInMinutes($dt->copy()->addSeconds(119)); // 1
|
||||
echo $dt->diffInMinutes($dt->copy()->addSeconds(120)); // 2
|
||||
|
||||
// others that are defined
|
||||
// diffInYears(), diffInMonths(), diffInDays()
|
||||
// diffInHours(), diffInMinutes(), diffInSeconds()
|
||||
```
|
||||
|
||||
<a name="api-humandiff"/>
|
||||
### Difference for Humans
|
||||
|
||||
It is easier for humans to read `1 month ago` compared to 30 days ago. This is a common function seen in most date libraries so I thought I would add it here as well. It uses approximations for month being 30 days which then equates a year to 360 days. The lone argument for the function is the other Carbon instance to diff against, and of course it defaults to `now()` if not specified.
|
||||
|
||||
This method will add a phrase after the difference value relative to the instance and the passed in instance. There are 4 possibilities:
|
||||
|
||||
* When comparing a value in the past to default now:
|
||||
* 1 hour ago
|
||||
* 5 months ago
|
||||
|
||||
* When comparing a value in the future to default now:
|
||||
* 1 hour from now
|
||||
* 5 months from now
|
||||
|
||||
* When comparing a value in the past to another value:
|
||||
* 1 hour before
|
||||
* 5 months before
|
||||
|
||||
* When comparing a value in the future to another value:
|
||||
* 1 hour after
|
||||
* 5 months after
|
||||
|
||||
```php
|
||||
// The most typical usage is for comments
|
||||
// The instance is the date the comment was created and its being compared to default now()
|
||||
echo Carbon::now()->subDays(5)->diffForHumans(); // 5 days ago
|
||||
|
||||
echo Carbon::now()->diffForHumans(Carbon::now()->subYear()); // 1 year after
|
||||
|
||||
$dt = Carbon::createFromDate(2011, 2, 1);
|
||||
|
||||
echo $dt->diffForHumans($dt->copy()->addMonth()); // 28 days before
|
||||
echo $dt->diffForHumans($dt->copy()->subMonth()); // 1 month after
|
||||
|
||||
echo Carbon::now()->addSeconds(5)->diffForHumans(); // 5 seconds from now
|
||||
```
|
||||
|
||||
<a name="api-modifiers"/>
|
||||
### Modifiers
|
||||
|
||||
These group of methods perform helpful modifications to the current instance. Most of them are self explanatory from their names... or at least should be. You'll also notice that the startOfXXX() methods set the time to 00:00:00 and the endOfXXX() methods set the time to 23:59:59.
|
||||
|
||||
```php
|
||||
$dt = Carbon::create(2012, 1, 31, 12, 0, 0);
|
||||
echo $dt->startOfDay(); // 2012-01-31 00:00:00
|
||||
|
||||
$dt = Carbon::create(2012, 1, 31, 12, 0, 0);
|
||||
echo $dt->endOfDay(); // 2012-01-31 23:59:59
|
||||
|
||||
$dt = Carbon::create(2012, 1, 31, 12, 0, 0);
|
||||
echo $dt->startOfMonth(); // 2012-01-01 00:00:00
|
||||
|
||||
$dt = Carbon::create(2012, 1, 31, 12, 0, 0);
|
||||
echo $dt->endOfMonth(); // 2012-01-31 23:59:59
|
||||
|
||||
$dt = Carbon::create(2012, 1, 31, 12, 0, 0);
|
||||
echo $dt->startOfWeek(); // 2012-01-30 00:00:00
|
||||
var_dump($dt->dayOfWeek == Carbon::MONDAY); // bool(true) : ISO8601 week starts on Monday
|
||||
|
||||
$dt = Carbon::create(2012, 1, 31, 12, 0, 0);
|
||||
echo $dt->endOfWeek(); // 2012-02-05 23:59:59
|
||||
var_dump($dt->dayOfWeek == Carbon::SUNDAY); // bool(true) : ISO8601 week ends on Sunday
|
||||
|
||||
$dt = Carbon::create(2012, 1, 31, 12, 0, 0);
|
||||
echo $dt->next(Carbon::WEDNESDAY); // 2012-02-01 00:00:00
|
||||
var_dump($dt->dayOfWeek == Carbon::WEDNESDAY); // bool(true)
|
||||
|
||||
$dt = Carbon::create(2012, 1, 1, 12, 0, 0);
|
||||
echo $dt->next(); // 2012-01-08 00:00:00
|
||||
|
||||
$dt = Carbon::create(2012, 1, 31, 12, 0, 0);
|
||||
echo $dt->previous(Carbon::WEDNESDAY); // 2012-01-25 00:00:00
|
||||
var_dump($dt->dayOfWeek == Carbon::WEDNESDAY); // bool(true)
|
||||
|
||||
$dt = Carbon::create(2012, 1, 1, 12, 0, 0);
|
||||
echo $dt->previous(); // 2011-12-25 00:00:00
|
||||
|
||||
// others that are defined that are similar
|
||||
// firstOfMonth(), lastOfMonth(), nthOfMonth()
|
||||
// firstOfQuarter(), lastOfQuarter(), nthOfQuarter()
|
||||
// firstOfYear(), lastOfYear(), nthOfYear()
|
||||
```
|
||||
|
||||
<a name="api-constants"/>
|
||||
### Constants
|
||||
|
||||
The following constants are defined in the Carbon class.
|
||||
|
||||
* SUNDAY = 0
|
||||
* MONDAY = 1
|
||||
* TUESDAY = 2
|
||||
* WEDNESDAY = 3
|
||||
* THURSDAY = 4
|
||||
* FRIDAY = 5
|
||||
* SATURDAY = 6
|
||||
* MONTHS_PER_YEAR = 12
|
||||
* HOURS_PER_DAY = 24
|
||||
* MINUTES_PER_HOUR = 60
|
||||
* SECONDS_PER_MINUTE = 60
|
||||
|
||||
```php
|
||||
$dt = Carbon::createFromDate(2012, 10, 6);
|
||||
if ($dt->dayOfWeek === Carbon::SATURDAY) {
|
||||
echo 'Place bets on Ottawa Senators Winning!';
|
||||
}
|
||||
```
|
||||
|
||||
<a name="about"/>
|
||||
## About
|
||||
|
||||
<a name="about-contributing"/>
|
||||
### Contributing
|
||||
|
||||
I hate reading a readme.md file that has code errors and/or sample output that is incorrect. I tried something new with this project and wrote a quick readme parser that can **lint** sample source code or **execute** and inject the actual result into a generated readme.
|
||||
|
||||
> **Don't make changes to the `readme.md` directly!!**
|
||||
|
||||
Change the `readme.src.md` and then use the `readme.php` to generate the new `readme.md` file. It can be run at the command line using `php readme.php` from the project root. Maybe someday I'll extract this out to another project or at least run it with a post receive hook, but for now its just a local tool, deal with it.
|
||||
|
||||
The commands are quickly explained below. To see some examples you can view the raw `readme.src.md` file in this repo.
|
||||
|
||||
`{{::lint()}}`
|
||||
|
||||
The `lint` command is meant for confirming the code is valid and will `eval()` the code passed into the function. Assuming there were no errors, the executed source code will then be injected back into the text replacing out the `{{::lint()}}`. When you look at the raw `readme.src.md` you will see that the code can span several lines. Remember the code is executed in the context of the running script so any variables will be available for the rest of the file.
|
||||
|
||||
{{::lint($var = 'brian nesbitt';)}} => $var = 'brian nesbitt';
|
||||
|
||||
> As mentioned the `$var` can later be echo'd and you would get 'brian nesbitt' as all of the source is executed in the same scope.
|
||||
|
||||
`{{varName::exec()}}` and `{{varName_eval}}`
|
||||
|
||||
The `exec` command begins by performing an `eval()` on the code passed into the function. The executed source code will then be injected back into the text replacing out the `{{varName::exec()}}`. This will also create a variable named `varName_eval` that you can then place anywhere in the file and it will get replaced with the output of the `eval()`. You can use any type of output (`echo`, `printf`, `var_dump` etc) statement to return the result value as an output buffer is setup to capture the output.
|
||||
|
||||
{{exVarName::exec(echo $var;)}} => echo $var;
|
||||
{{exVarName_eval}} => brian nesbitt // $var is still set from above
|
||||
|
||||
`/*pad()*/`
|
||||
|
||||
The `pad()` is a special source modifier. This will pad the code block to the indicated number of characters using spaces. Its particularly handy for aligning `//` comments when showing results.
|
||||
|
||||
{{exVarName1::exec(echo 12345;/*pad(20)*/)}} // {{exVarName1_eval}}
|
||||
{{exVarName2::exec(echo 6;/*pad(20)*/)}} // {{exVarName2_eval}}
|
||||
|
||||
... would generate to:
|
||||
|
||||
echo 12345; // 12345
|
||||
echo 6; // 6
|
||||
|
||||
Apart from the readme the typical steps can be used to contribute your own improvements.
|
||||
|
||||
* Fork
|
||||
* Clone
|
||||
* PHPUnit
|
||||
* Branch
|
||||
* PHPUnit
|
||||
* Code
|
||||
* PHPUnit
|
||||
* Commit
|
||||
* Push
|
||||
* Pull request
|
||||
* Relax and play Castle Crashers
|
||||
|
||||
<a name="about-author"/>
|
||||
### Author
|
||||
|
||||
Brian Nesbitt - <brian@nesbot.com> - <http://twitter.com/NesbittBrian>
|
||||
|
||||
<a name="about-license"/>
|
||||
### License
|
||||
|
||||
Carbon is licensed under the MIT License - see the `LICENSE` file for details
|
||||
|
||||
<a name="about-history"/>
|
||||
### History
|
||||
|
||||
You can view the history of the Carbon project in the [history file](https://github.com/briannesbitt/Carbon/blob/master/history.md).
|
||||
|
||||
<a name="about-whyname"/>
|
||||
### Why the name Carbon?
|
||||
|
||||
Read about [Carbon Dating](http://en.wikipedia.org/wiki/Radiocarbon_dating)
|
76
vendor/nesbot/carbon/readme.php
vendored
Normal file
76
vendor/nesbot/carbon/readme.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require 'src/Carbon/Carbon.php';
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
date_default_timezone_set('America/Toronto');
|
||||
|
||||
$readme = file_get_contents('readme.src.md');
|
||||
|
||||
$pre_src = 'use Carbon\Carbon; ';
|
||||
|
||||
// {{intro::exec(echo Carbon::now()->subMinutes(2)->diffForHumans();)}}
|
||||
preg_match_all('@{{(\w*)::(\w+)\((.+)\)}}@sU', $readme, $matches, PREG_SET_ORDER);
|
||||
|
||||
foreach ($matches as $match) {
|
||||
|
||||
list($orig, $name, $cmd, $src) = $match;
|
||||
|
||||
$src = trim($src, "\n\r");
|
||||
|
||||
ob_start();
|
||||
$result = eval($pre_src . $src);
|
||||
|
||||
$ob = ob_get_clean();
|
||||
|
||||
if ($result === false) {
|
||||
echo "Failed lint check.". PHP_EOL . PHP_EOL;
|
||||
|
||||
$error = error_get_last();
|
||||
if ($error != null) {
|
||||
echo $error['message'] . ' on line ' . $error['line'] . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
echo "---- eval'd source ---- " . PHP_EOL . PHP_EOL;
|
||||
|
||||
$i = 1;
|
||||
foreach (preg_split("/$[\n\r]^/m", $src) as $ln) {
|
||||
printf('%3s : %s%s', $i++, $ln, PHP_EOL);
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// remove the extra newline from a var_dump
|
||||
if (strpos($src, 'var_dump(') === 0) {
|
||||
$ob = trim($ob);
|
||||
}
|
||||
|
||||
// Add any necessary padding to lineup comments
|
||||
if (preg_match('@/\*pad\(([0-9]+)\)\*/@', $src, $matches)) {
|
||||
$src = preg_replace('@/\*pad\(([0-9]+)\)\*/@', '', $src);
|
||||
$src = str_pad($src, intval($matches[1]));
|
||||
}
|
||||
|
||||
// Inject the source code
|
||||
$readme = str_replace($orig, $src, $readme);
|
||||
|
||||
// Inject the eval'd result
|
||||
if ($cmd == 'exec') {
|
||||
$readme = str_replace('{{'.$name.'_eval}}', $ob, $readme);
|
||||
}
|
||||
}
|
||||
|
||||
// allow for escaping a command
|
||||
$readme = str_replace('\{\{', '{{', $readme);
|
||||
|
||||
file_put_contents('readme.md', $readme);
|
786
vendor/nesbot/carbon/readme.src.md
vendored
Normal file
786
vendor/nesbot/carbon/readme.src.md
vendored
Normal file
@@ -0,0 +1,786 @@
|
||||
> **This file is autogenerated. Please see the [Contributing](#about-contributing) section from more information.**
|
||||
|
||||
# Carbon
|
||||
|
||||
[](http://travis-ci.org/briannesbitt/Carbon)
|
||||
|
||||
A simple API extension for DateTime with PHP 5.3+
|
||||
|
||||
```php
|
||||
{{::lint(
|
||||
printf("Right now is %s", Carbon::now()->toDateTimeString());
|
||||
printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver')); //implicit __toString()
|
||||
$tomorrow = Carbon::now()->addDay();
|
||||
$lastWeek = Carbon::now()->subWeek();
|
||||
$nextSummerOlympics = Carbon::createFromDate(2012)->addYears(4);
|
||||
|
||||
$officialDate = Carbon::now()->toRFC2822String();
|
||||
|
||||
$howOldAmI = Carbon::createFromDate(1975, 5, 21)->age;
|
||||
|
||||
$noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London');
|
||||
|
||||
$worldWillEnd = Carbon::createFromDate(2012, 12, 21, 'GMT');
|
||||
|
||||
// Don't really want to die so mock now
|
||||
Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1));
|
||||
|
||||
// comparisons are always done in UTC
|
||||
if (Carbon::now()->gte($worldWillEnd)) {
|
||||
die();
|
||||
}
|
||||
|
||||
// Phew! Return to normal behaviour
|
||||
Carbon::setTestNow();
|
||||
|
||||
if (Carbon::now()->isWeekend()) {
|
||||
echo 'Party!';
|
||||
}
|
||||
)}}
|
||||
{{intro::exec(echo Carbon::now()->subMinutes(2)->diffForHumans();)}} // '{{intro_eval}}'
|
||||
|
||||
// ... but also does 'from now', 'after' and 'before'
|
||||
// rolling up to seconds, minutes, hours, days, months, years
|
||||
|
||||
{{::lint(
|
||||
$daysSinceEpoch = Carbon::createFromTimeStamp(0)->diffInDays();
|
||||
)}}
|
||||
```
|
||||
|
||||
## README Contents
|
||||
|
||||
* [Installation](#install)
|
||||
* [Requirements](#requirements)
|
||||
* [With composer](#install-composer)
|
||||
* [Without composer](#install-nocomposer)
|
||||
* [API](#api)
|
||||
* [Instantiation](#api-instantiation)
|
||||
* [Testing Aids](#api-testing)
|
||||
* [Getters](#api-getters)
|
||||
* [Setters](#api-setters)
|
||||
* [Fluent Setters](#api-settersfluent)
|
||||
* [IsSet](#api-isset)
|
||||
* [String Formatting and Localization](#api-formatting)
|
||||
* [Common Formats](#api-commonformats)
|
||||
* [Comparison](#api-comparison)
|
||||
* [Addition and Subtraction](#api-addsub)
|
||||
* [Difference](#api-difference)
|
||||
* [Difference for Humans](#api-humandiff)
|
||||
* [Modifiers](#api-modifiers)
|
||||
* [Constants](#api-constants)
|
||||
* [About](#about)
|
||||
* [Contributing](#about-contributing)
|
||||
* [Author](#about-author)
|
||||
* [License](#about-license)
|
||||
* [History](#about-history)
|
||||
* [Why the name Carbon?](#about-whyname)
|
||||
|
||||
<a name="install"/>
|
||||
## Installation
|
||||
|
||||
<a name="requirements"/>
|
||||
### Requirements
|
||||
|
||||
- Any flavour of PHP 5.3+ should do
|
||||
- [optional] PHPUnit to execute the test suite
|
||||
|
||||
<a name="install-composer"/>
|
||||
### With Composer
|
||||
|
||||
The easiest way to install Carbon is via [composer](http://getcomposer.org/). Create the following `composer.json` file and run the `php composer.phar install` command to install it.
|
||||
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"nesbot/Carbon": "*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```php
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
{{::lint(printf("Now: %s", Carbon::now());)}}
|
||||
```
|
||||
|
||||
<a name="install-nocomposer"/>
|
||||
### Without Composer
|
||||
|
||||
Why are you not using [composer](http://getcomposer.org/)? Download [Carbon.php](https://github.com/briannesbitt/Carbon/blob/master/Carbon/Carbon.php) from the repo and save the file into your project path somewhere.
|
||||
|
||||
```php
|
||||
<?php
|
||||
require 'path/to/Carbon.php';
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
{{::lint(printf("Now: %s", Carbon::now());)}}
|
||||
```
|
||||
|
||||
<a name="api"/>
|
||||
## API
|
||||
|
||||
The Carbon class is [inherited](http://php.net/manual/en/keyword.extends.php) from the PHP [DateTime](http://www.php.net/manual/en/class.datetime.php) class.
|
||||
|
||||
```php
|
||||
<?php
|
||||
class Carbon extends \DateTime
|
||||
{
|
||||
// code here
|
||||
}
|
||||
```
|
||||
|
||||
Carbon has all of the functions inherited from the base DateTime class. This approach allows you to access the base functionality if you see anything missing in Carbon but is there in DateTime.
|
||||
|
||||
> **Note: I live in Ottawa, Ontario, Canada and if the timezone is not specified in the examples then the default of 'America/Toronto' is to be assumed. Typically Ottawa is -0500 but when daylight savings time is on we are -0400.**
|
||||
|
||||
Special care has been taken to ensure timezones are handled correctly, and where appropriate are based on the underlying DateTime implementation. For example all comparisons are done in UTC or in the timezone of the datetime being used.
|
||||
|
||||
```php
|
||||
{{::lint($dtToronto = Carbon::createFromDate(2012, 1, 1, 'America/Toronto');)}}
|
||||
{{::lint($dtVancouver = Carbon::createFromDate(2012, 1, 1, 'America/Vancouver');)}}
|
||||
|
||||
{{tz::exec(echo $dtVancouver->diffInHours($dtToronto);)}} // {{tz_eval}}
|
||||
```
|
||||
|
||||
Also `is` comparisons are done in the timezone of the provided Carbon instance. For example my current timezone is -13 hours from Tokyo. So `Carbon::now('Asia/Tokyo')->isToday()` would only return false for any time past 1 PM my time. This doesn't make sense since `now()` in tokyo is always today in Tokyo. Thus the comparison to `now()` is done in the same timezone as the current instance.
|
||||
|
||||
<a name="api-instantiation"/>
|
||||
### Instantiation
|
||||
|
||||
There are several different methods available to create a new instance of Carbon. First there is a constructor. It overrides the [parent constructor](http://www.php.net/manual/en/datetime.construct.php) and you are best to read about the first parameter from the PHP manual and understand the date/time string formats it accepts. You'll hopefully find yourself rarely using the constructor but rather relying on the explicit static methods for improved readability.
|
||||
|
||||
```php
|
||||
{{::lint($carbon = new Carbon();/*pad(40)*/)}} // equivalent to Carbon::now()
|
||||
{{::lint($carbon = new Carbon('first day of January 2008', 'America/Vancouver');)}}
|
||||
{{ctorType::exec(echo get_class($carbon);/*pad(40)*/)}} // '{{ctorType_eval}}'
|
||||
```
|
||||
|
||||
You'll notice above that the timezone (2nd) parameter was passed as a string rather than a `\DateTimeZone` instance. All DateTimeZone parameters have been augmented so you can pass a DateTimeZone instance or a string and the timezone will be created for you. This is again shown in the next example which also introduces the `now()` function.
|
||||
|
||||
```php
|
||||
{{::lint(
|
||||
$now = Carbon::now();
|
||||
|
||||
$nowInLondonTz = Carbon::now(new DateTimeZone('Europe/London'));
|
||||
|
||||
// or just pass the timezone as a string
|
||||
$nowInLondonTz = Carbon::now('Europe/London');
|
||||
)}}
|
||||
```
|
||||
|
||||
If you really love your fluid method calls and get frustrated by the extra line or ugly pair of brackets necessary when using the constructor you'll enjoy the `parse` method.
|
||||
|
||||
```php
|
||||
{{parse1::exec(echo (new Carbon('first day of December 2008'))->addWeeks(2);/*pad(65)*/)}} // {{parse1_eval}}
|
||||
{{parse2::exec(echo Carbon::parse('first day of December 2008')->addWeeks(2);/*pad(65)*/)}} // {{parse2_eval}}
|
||||
```
|
||||
|
||||
To accompany `now()`, a few other static instantiation helpers exist to create widely known instances. The only thing to really notice here is that `today()`, `tomorrow()` and `yesterday()`, besides behaving as expected, all accept a timezone parameter and each has their time value set to `00:00:00`.
|
||||
|
||||
```php
|
||||
{{::lint($now = Carbon::now();)}}
|
||||
{{now::exec(echo $now;/*pad(40)*/)}} // {{now_eval}}
|
||||
{{::lint($today = Carbon::today();)}}
|
||||
{{today::exec(echo $today;/*pad(40)*/)}} // {{today_eval}}
|
||||
{{::lint($tomorrow = Carbon::tomorrow('Europe/London');)}}
|
||||
{{tomorrow::exec(echo $tomorrow;/*pad(40)*/)}} // {{tomorrow_eval}}
|
||||
{{::lint($yesterday = Carbon::yesterday();)}}
|
||||
{{yesterday::exec(echo $yesterday;/*pad(40)*/)}} // {{yesterday_eval}}
|
||||
```
|
||||
|
||||
The next group of static helpers are the `createXXX()` helpers. Most of the static `create` functions allow you to provide as many or as few arguments as you want and will provide default values for all others. Generally default values are the current date, time or timezone. Higher values will wrap appropriately but invalid values will throw an `InvalidArgumentException` with an informative message. The message is obtained from an [DateTime::getLastErrors()](http://php.net/manual/en/datetime.getlasterrors.php) call.
|
||||
|
||||
```php
|
||||
Carbon::createFromDate($year, $month, $day, $tz);
|
||||
Carbon::createFromTime($hour, $minute, $second, $tz);
|
||||
Carbon::create($year, $month, $day, $hour, $minute, $second, $tz);
|
||||
```
|
||||
|
||||
`createFromDate()` will default the time to now. `createFromTime()` will default the date to today. `create()` will default any null parameter to the current respective value. As before, the `$tz` defaults to the current timezone and otherwise can be a DateTimeZone instance or simply a string timezone value. The only special case for default values (mimicking the underlying PHP library) occurs when an hour value is specified but no minutes or seconds, they will get defaulted to 0.
|
||||
|
||||
```php
|
||||
{{::lint(
|
||||
$xmasThisYear = Carbon::createFromDate(null, 12, 25); // Year defaults to current year
|
||||
$Y2K = Carbon::create(2000, 1, 1, 0, 0, 0);
|
||||
$alsoY2K = Carbon::create(1999, 12, 31, 24);
|
||||
$noonLondonTz = Carbon::createFromTime(12, 0, 0, 'Europe/London');
|
||||
)}}
|
||||
|
||||
// {{createFromDateException_eval}}
|
||||
{{createFromDateException::exec(try { Carbon::create(1975, 5, 21, 22, -2, 0); } catch(InvalidArgumentException $x) { echo $x->getMessage(); })}}
|
||||
```
|
||||
|
||||
```php
|
||||
Carbon::createFromFormat($format, $time, $tz);
|
||||
```
|
||||
|
||||
`createFromFormat()` is mostly a wrapper for the base php function [DateTime::createFromFormat](http://php.net/manual/en/datetime.createfromformat.php). The difference being again the `$tz` argument can be a DateTimeZone instance or a string timezone value. Also, if there are errors with the format this function will call the `DateTime::getLastErrors()` method and then throw a `InvalidArgumentException` with the errors as the message. If you look at the source for the `createXX()` functions above, they all make a call to `createFromFormat()`.
|
||||
|
||||
```php
|
||||
{{createFromFormat1::exec(echo Carbon::createFromFormat('Y-m-d H', '1975-05-21 22')->toDateTimeString();)}} // {{createFromFormat1_eval}}
|
||||
```
|
||||
|
||||
The final two create functions are for working with [unix timestamps](http://en.wikipedia.org/wiki/Unix_time). The first will create a Carbon instance equal to the given timestamp and will set the timezone as well or default it to the current timezone. The second, `createFromTimestampUTC()`, is different in that the timezone will remain UTC (GMT). The second acts the same as `Carbon::createFromFormat('@'.$timestamp)` but I have just made it a little more explicit. Negative timestamps are also allowed.
|
||||
|
||||
```php
|
||||
{{createFromTimeStamp1::exec(echo Carbon::createFromTimeStamp(-1)->toDateTimeString();/*pad(80)*/)}} // {{createFromTimeStamp1_eval}}
|
||||
{{createFromTimeStamp2::exec(echo Carbon::createFromTimeStamp(-1, 'Europe/London')->toDateTimeString();/*pad(80)*/)}} // {{createFromTimeStamp2_eval}}
|
||||
{{createFromTimeStampUTC::exec(echo Carbon::createFromTimeStampUTC(-1)->toDateTimeString();/*pad(80)*/)}} // {{createFromTimeStampUTC_eval}}
|
||||
```
|
||||
|
||||
You can also create a `copy()` of an existing Carbon instance. As expected the date, time and timezone values are all copied to the new instance.
|
||||
|
||||
```php
|
||||
{{::lint($dt = Carbon::now();)}}
|
||||
{{copy2::exec(echo $dt->diffInYears($dt->copy()->addYear());)}} // {{copy2_eval}}
|
||||
|
||||
// $dt was unchanged and still holds the value of Carbon:now()
|
||||
```
|
||||
|
||||
Finally, if you find yourself inheriting a `\DateTime` instance from another library, fear not! You can create a `Carbon` instance via a friendly `instance()` function.
|
||||
|
||||
```php
|
||||
{{::lint($dt = new \DateTime('first day of January 2008');)}} // <== instance from another API
|
||||
{{::lint($carbon = Carbon::instance($dt);)}}
|
||||
{{ctorType1::exec(echo get_class($carbon);/*pad(54)*/)}} // '{{ctorType1_eval}}'
|
||||
{{ctorType2::exec(echo $carbon->toDateTimeString();/*pad(54)*/)}} // {{ctorType2_eval}}
|
||||
```
|
||||
|
||||
<a name="api-testing"/>
|
||||
### Testing Aids
|
||||
|
||||
The testing methods allow you to set a Carbon instance (real or mock) to be returned when a "now" instance is created. The provided instance will be returned specifically under the following conditions:
|
||||
- A call to the static now() method, ex. Carbon::now()
|
||||
- When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
|
||||
- When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
|
||||
|
||||
```php
|
||||
{{::lint($knownDate = Carbon::create(2001, 5, 21, 12);/*pad(54)*/)}} // create testing date
|
||||
{{::lint(Carbon::setTestNow($knownDate);/*pad(54)*/)}} // set the mock (of course this could be a real mock object)
|
||||
{{testaid1::exec(echo Carbon::now();/*pad(54)*/)}} // {{testaid1_eval}}
|
||||
{{testaid2::exec(echo new Carbon();/*pad(54)*/)}} // {{testaid2_eval}}
|
||||
{{testaid3::exec(echo Carbon::parse();/*pad(54)*/)}} // {{testaid3_eval}}
|
||||
{{testaid4::exec(echo new Carbon('now');/*pad(54)*/)}} // {{testaid4_eval}}
|
||||
{{testaid5::exec(echo Carbon::parse('now');/*pad(54)*/)}} // {{testaid5_eval}}
|
||||
{{hasTestNow::exec(var_dump(Carbon::hasTestNow());/*pad(54)*/)}} // {{hasTestNow_eval}}
|
||||
{{::lint(Carbon::setTestNow();/*pad(54)*/)}} // clear the mock
|
||||
{{hasTestNowNo::exec(var_dump(Carbon::hasTestNow());/*pad(54)*/)}} // {{hasTestNowNo_eval}}
|
||||
{{backToNormal::exec(echo Carbon::now();/*pad(54)*/)}} // {{backToNormal_eval}}
|
||||
```
|
||||
|
||||
A more meaning full example:
|
||||
|
||||
```php
|
||||
{{::lint(
|
||||
class SeasonalProduct
|
||||
{
|
||||
protected $price;
|
||||
|
||||
public function __construct($price)
|
||||
{
|
||||
$this->price = $price;
|
||||
}
|
||||
|
||||
public function getPrice() {
|
||||
$multiplier = 1;
|
||||
if (Carbon::now()->month == 12) {
|
||||
$multiplier = 2;
|
||||
}
|
||||
|
||||
return $this->price * $multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
$product = new SeasonalProduct(100);
|
||||
)}}
|
||||
{{::lint(Carbon::setTestNow(Carbon::parse('first day of March 2000'));/*pad(40)*/)}}
|
||||
{{product1::exec(echo $product->getPrice();/*pad(70)*/)}} // {{product1_eval}}
|
||||
{{::lint(Carbon::setTestNow(Carbon::parse('first day of December 2000'));/*pad(40)*/)}}
|
||||
{{product2::exec(echo $product->getPrice();/*pad(70)*/)}} // {{product2_eval}}
|
||||
{{::lint(Carbon::setTestNow(Carbon::parse('first day of May 2000'));/*pad(40)*/)}}
|
||||
{{product3::exec(echo $product->getPrice();/*pad(70)*/)}} // {{product3_eval}}
|
||||
{{::lint(Carbon::setTestNow();)}}
|
||||
```
|
||||
|
||||
<a name="api-getters"/>
|
||||
### Getters
|
||||
|
||||
The getters are implemented via PHP's `__get()` method. This enables you to access the value as if it was a property rather than a function call.
|
||||
|
||||
```php
|
||||
{{::lint($dt = Carbon::create(2012, 9, 5, 23, 26, 11);)}}
|
||||
|
||||
// These getters specifically return integers, ie intval()
|
||||
{{getyear::exec(var_dump($dt->year);/*pad(54)*/)}} // {{getyear_eval}}
|
||||
{{getmonth::exec(var_dump($dt->month);/*pad(54)*/)}} // {{getmonth_eval}}
|
||||
{{getday::exec(var_dump($dt->day);/*pad(54)*/)}} // {{getday_eval}}
|
||||
{{gethour::exec(var_dump($dt->hour);/*pad(54)*/)}} // {{gethour_eval}}
|
||||
{{getminute::exec(var_dump($dt->minute);/*pad(54)*/)}} // {{getminute_eval}}
|
||||
{{getsecond::exec(var_dump($dt->second);/*pad(54)*/)}} // {{getsecond_eval}}
|
||||
{{getdow::exec(var_dump($dt->dayOfWeek);/*pad(54)*/)}} // {{getdow_eval}}
|
||||
{{getdoy::exec(var_dump($dt->dayOfYear);/*pad(54)*/)}} // {{getdoy_eval}}
|
||||
{{getwoy::exec(var_dump($dt->weekOfYear);/*pad(54)*/)}} // {{getwoy_eval}}
|
||||
{{getdnm::exec(var_dump($dt->daysInMonth);/*pad(54)*/)}} // {{getdnm_eval}}
|
||||
{{getts::exec(var_dump($dt->timestamp);/*pad(54)*/)}} // {{getts_eval}}
|
||||
{{getage::exec(var_dump(Carbon::createFromDate(1975, 5, 21)->age);/*pad(54)*/)}} // {{getage_eval}} calculated vs now in the same tz
|
||||
{{getq::exec(var_dump($dt->quarter);/*pad(54)*/)}} // {{getq_eval}}
|
||||
|
||||
// Returns an int of seconds difference from UTC (+/- sign included)
|
||||
{{get1::exec(var_dump(Carbon::createFromTimestampUTC(0)->offset);/*pad(54)*/)}} // {{get1_eval}}
|
||||
{{get2::exec(var_dump(Carbon::createFromTimestamp(0)->offset);/*pad(54)*/)}} // {{get2_eval}}
|
||||
|
||||
// Returns an int of hours difference from UTC (+/- sign included)
|
||||
{{get3::exec(var_dump(Carbon::createFromTimestamp(0)->offsetHours);/*pad(54)*/)}} // {{get3_eval}}
|
||||
|
||||
// Indicates if day light savings time is on
|
||||
{{get4::exec(var_dump(Carbon::createFromDate(2012, 1, 1)->dst);/*pad(54)*/)}} // {{get4_eval}}
|
||||
|
||||
// Gets the DateTimeZone instance
|
||||
{{get5::exec(echo get_class(Carbon::now()->timezone);/*pad(54)*/)}} // {{get5_eval}}
|
||||
{{get6::exec(echo get_class(Carbon::now()->tz);/*pad(54)*/)}} // {{get6_eval}}
|
||||
|
||||
// Gets the DateTimeZone instance name, shortcut for ->timezone->getName()
|
||||
{{get7::exec(echo Carbon::now()->timezoneName;/*pad(54)*/)}} // {{get7_eval}}
|
||||
{{get8::exec(echo Carbon::now()->tzName;/*pad(54)*/)}} // {{get8_eval}}
|
||||
```
|
||||
|
||||
<a name="api-setters"/>
|
||||
### Setters
|
||||
|
||||
The following setters are implemented via PHP's `__set()` method. Its good to take note here that none of the setters, with the obvious exception of explicitly setting the timezone, will change the timezone of the instance. Specifically, setting the timestamp will not set the corresponding timezone to UTC.
|
||||
|
||||
```php
|
||||
{{::lint(
|
||||
$dt = Carbon::now();
|
||||
|
||||
$dt->year = 1975;
|
||||
$dt->month = 13; // would force year++ and month = 1
|
||||
$dt->month = 5;
|
||||
$dt->day = 21;
|
||||
$dt->hour = 22;
|
||||
$dt->minute = 32;
|
||||
$dt->second = 5;
|
||||
|
||||
$dt->timestamp = 169957925; // This will not change the timezone
|
||||
|
||||
// Set the timezone via DateTimeZone instance or string
|
||||
$dt->timezone = new DateTimeZone('Europe/London');
|
||||
$dt->timezone = 'Europe/London';
|
||||
$dt->tz = 'Europe/London';
|
||||
)}}
|
||||
```
|
||||
|
||||
<a name="api-settersfluent"/>
|
||||
### Fluent Setters
|
||||
|
||||
No arguments are optional for the setters, but there are enough variety in the function definitions that you shouldn't need them anyway. Its good to take note here that none of the setters, with the obvious exception of explicitly setting the timezone, will change the timezone of the instance. Specifically, setting the timestamp will not set the corresponding timezone to UTC.
|
||||
|
||||
```php
|
||||
{{::lint(
|
||||
$dt = Carbon::now();
|
||||
|
||||
$dt->year(1975)->month(5)->day(21)->hour(22)->minute(32)->second(5)->toDateTimeString();
|
||||
$dt->setDate(1975, 5, 21)->setTime(22, 32, 5)->toDateTimeString();
|
||||
$dt->setDateTime(1975, 5, 21, 22, 32, 5)->toDateTimeString();
|
||||
|
||||
$dt->timestamp(169957925)->timezone('Europe/London');
|
||||
|
||||
$dt->tz('America/Toronto')->setTimezone('America/Vancouver');
|
||||
)}}
|
||||
```
|
||||
|
||||
<a name="api-isset"/>
|
||||
### IsSet
|
||||
|
||||
The PHP function `__isset()` is implemented. This was done as some external systems (ex. [Twig](http://twig.sensiolabs.org/doc/recipes.html#using-dynamic-object-properties)) validate the existence of a property before using it. This is done using the `isset()` or `empty()` method. You can read more about these on the PHP site: [__isset()](http://www.php.net/manual/en/language.oop5.overloading.php#object.isset), [isset()](http://www.php.net/manual/en/function.isset.php), [empty()](http://www.php.net/manual/en/function.empty.php).
|
||||
|
||||
```php
|
||||
{{isset1::exec(var_dump(isset(Carbon::now()->iDoNotExist));/*pad(50)*/)}} // {{isset1_eval}}
|
||||
{{isset2::exec(var_dump(isset(Carbon::now()->hour));/*pad(50)*/)}} // {{isset2_eval}}
|
||||
{{isset3::exec(var_dump(empty(Carbon::now()->iDoNotExist));/*pad(50)*/)}} // {{isset3_eval}}
|
||||
{{isset4::exec(var_dump(empty(Carbon::now()->year));/*pad(50)*/)}} // {{isset4_eval}}
|
||||
```
|
||||
|
||||
<a name="api-formatting"/>
|
||||
### String Formatting and Localization
|
||||
|
||||
All of the available `toXXXString()` methods rely on the base class method [DateTime::format()](http://php.net/manual/en/datetime.format.php). You'll notice the `__toString()` method is defined which allows a Carbon instance to be printed as a pretty date time string when used in a string context.
|
||||
|
||||
```php
|
||||
{{::lint($dt = Carbon::create(1975, 12, 25, 14, 15, 16);)}}
|
||||
|
||||
{{format1::exec(var_dump($dt->toDateTimeString() == $dt);/*pad(50)*/)}} // {{format1_eval}} => uses __toString()
|
||||
{{format2::exec(echo $dt->toDateString();/*pad(50)*/)}} // {{format2_eval}}
|
||||
{{format3::exec(echo $dt->toFormattedDateString();/*pad(50)*/)}} // {{format3_eval}}
|
||||
{{format4::exec(echo $dt->toTimeString();/*pad(50)*/)}} // {{format4_eval}}
|
||||
{{format5::exec(echo $dt->toDateTimeString();/*pad(50)*/)}} // {{format5_eval}}
|
||||
{{format6::exec(echo $dt->toDayDateTimeString();/*pad(50)*/)}} // {{format6_eval}}
|
||||
|
||||
// ... of course format() is still available
|
||||
{{format7::exec(echo $dt->format('l jS \\of F Y h:i:s A');/*pad(50)*/)}} // {{format7_eval}}
|
||||
```
|
||||
|
||||
Unfortunately the base class DateTime does not have any localization support. To begin localization support a `formatLocalized($format)` method has been added. The implementation makes a call to [strftime](http://www.php.net/strftime) using the current instance timestamp. If you first set the current locale with [setlocale()](http://www.php.net/setlocale) then the string returned will be formatted in the correct locale.
|
||||
|
||||
```php
|
||||
{{::lint(setlocale(LC_TIME, 'German');/*pad(50)*/)}}
|
||||
{{format20::exec(echo $dt->formatLocalized('%A %d %B %Y');/*pad(50)*/)}} // {{format20_eval}}
|
||||
{{::lint(setlocale(LC_TIME, '');/*pad(50)*/)}}
|
||||
{{format21::exec(echo $dt->formatLocalized('%A %d %B %Y');/*pad(50)*/)}} // {{format21_eval}}
|
||||
```
|
||||
|
||||
<a name="api-commonformats"/>
|
||||
## Common Formats
|
||||
|
||||
The following are wrappers for the common formats provided in the [DateTime class](http://www.php.net/manual/en/class.datetime.php).
|
||||
|
||||
```php
|
||||
$dt = Carbon::now();
|
||||
|
||||
echo $dt->toATOMString(); // same as $dt->format(DateTime::ATOM);
|
||||
echo $dt->toCOOKIEString();
|
||||
echo $dt->toISO8601String();
|
||||
echo $dt->toRFC822String();
|
||||
echo $dt->toRFC850String();
|
||||
echo $dt->toRFC1036String();
|
||||
echo $dt->toRFC1123String();
|
||||
echo $dt->toRFC2822String();
|
||||
echo $dt->toRFC3339String();
|
||||
echo $dt->toRSSString();
|
||||
echo $dt->toW3CString();
|
||||
```
|
||||
|
||||
<a name="api-comparison"/>
|
||||
### Comparison
|
||||
|
||||
Simple comparison is offered up via the following functions. Remember that the comparison is done in the UTC timezone so things aren't always as they seem.
|
||||
|
||||
```php
|
||||
{{::lint($first = Carbon::create(2012, 9, 5, 23, 26, 11);)}}
|
||||
{{::lint($second = Carbon::create(2012, 9, 5, 20, 26, 11, 'America/Vancouver');)}}
|
||||
|
||||
{{compare1::exec(echo $first->toDateTimeString();/*pad(50)*/)}} // {{compare1_eval}}
|
||||
{{compare2::exec(echo $second->toDateTimeString();/*pad(50)*/)}} // {{compare2_eval}}
|
||||
|
||||
{{compare3::exec(var_dump($first->eq($second));/*pad(50)*/)}} // {{compare3_eval}}
|
||||
{{compare4::exec(var_dump($first->ne($second));/*pad(50)*/)}} // {{compare4_eval}}
|
||||
{{compare5::exec(var_dump($first->gt($second));/*pad(50)*/)}} // {{compare5_eval}}
|
||||
{{compare6::exec(var_dump($first->gte($second));/*pad(50)*/)}} // {{compare6_eval}}
|
||||
{{compare7::exec(var_dump($first->lt($second));/*pad(50)*/)}} // {{compare7_eval}}
|
||||
{{compare8::exec(var_dump($first->lte($second));/*pad(50)*/)}} // {{compare8_eval}}
|
||||
|
||||
{{::lint($first->setDateTime(2012, 1, 1, 0, 0, 0);)}}
|
||||
{{::lint($second->setDateTime(2012, 1, 1, 0, 0, 0);/*pad(50)*/)}} // Remember tz is 'America/Vancouver'
|
||||
|
||||
{{compare9::exec(var_dump($first->eq($second));/*pad(50)*/)}} // {{compare9_eval}}
|
||||
{{compare10::exec(var_dump($first->ne($second));/*pad(50)*/)}} // {{compare10_eval}}
|
||||
{{compare11::exec(var_dump($first->gt($second));/*pad(50)*/)}} // {{compare11_eval}}
|
||||
{{compare12::exec(var_dump($first->gte($second));/*pad(50)*/)}} // {{compare12_eval}}
|
||||
{{compare13::exec(var_dump($first->lt($second));/*pad(50)*/)}} // {{compare13_eval}}
|
||||
{{compare14::exec(var_dump($first->lte($second));/*pad(50)*/)}} // {{compare14_eval}}
|
||||
```
|
||||
|
||||
To determine if the current instance is between two other instances you can use the aptly named `between()` method. The third parameter indicates if an equal to comparison should be done. The default is true which determines if its between or equal to the boundaries.
|
||||
|
||||
```php
|
||||
{{::lint($first = Carbon::create(2012, 9, 5, 1);)}}
|
||||
{{::lint($second = Carbon::create(2012, 9, 5, 5);)}}
|
||||
{{between1::exec(var_dump(Carbon::create(2012, 9, 5, 3)->between($first, $second));/*pad(75)*/)}} // {{between1_eval}}
|
||||
{{between2::exec(var_dump(Carbon::create(2012, 9, 5, 5)->between($first, $second));/*pad(75)*/)}} // {{between2_eval}}
|
||||
{{between3::exec(var_dump(Carbon::create(2012, 9, 5, 5)->between($first, $second, false));/*pad(75)*/)}} // {{between3_eval}}
|
||||
```
|
||||
|
||||
To handle the most used cases there are some simple helper functions that hopefully are obvious from their names. For the methods that compare to `now()` (ex. isToday()) in some manner the `now()` is created in the same timezone as the instance.
|
||||
|
||||
```php
|
||||
{{::lint(
|
||||
$dt = Carbon::now();
|
||||
|
||||
$dt->isWeekday();
|
||||
$dt->isWeekend();
|
||||
$dt->isYesterday();
|
||||
$dt->isToday();
|
||||
$dt->isTomorrow();
|
||||
$dt->isFuture();
|
||||
$dt->isPast();
|
||||
$dt->isLeapYear();
|
||||
)}}
|
||||
```
|
||||
|
||||
<a name="api-addsub"/>
|
||||
### Addition and Subtraction
|
||||
|
||||
The default DateTime provides a couple of different methods for easily adding and subtracting time. There is `modify()`, `add()` and `sub()`. `modify()` takes a *magical* date/time format string, 'last day of next month', that it parses and applies the modification while `add()` and `sub()` use a `DateInterval` class thats not so obvious, `new \DateInterval('P6YT5M')`. Hopefully using these fluent functions will be more clear and easier to read after not seeing your code for a few weeks. But of course I don't make you choose since the base class functions are still available.
|
||||
|
||||
```php
|
||||
{{::lint($dt = Carbon::create(2012, 1, 31, 0);)}}
|
||||
|
||||
{{addsub1::exec(echo $dt->toDateTimeString();/*pad(40)*/)}} // {{addsub1_eval}}
|
||||
|
||||
{{addsub2::exec(echo $dt->addYears(5);/*pad(40)*/)}} // {{addsub2_eval}}
|
||||
{{addsub3::exec(echo $dt->addYear();/*pad(40)*/)}} // {{addsub3_eval}}
|
||||
{{addsub4::exec(echo $dt->subYear();/*pad(40)*/)}} // {{addsub4_eval}}
|
||||
{{addsub5::exec(echo $dt->subYears(5);/*pad(40)*/)}} // {{addsub5_eval}}
|
||||
|
||||
{{addsub6::exec(echo $dt->addMonths(60);/*pad(40)*/)}} // {{addsub6_eval}}
|
||||
{{addsub7::exec(echo $dt->addMonth();/*pad(40)*/)}} // {{addsub7_eval}} equivalent of $dt->month($dt->month + 1); so it wraps
|
||||
{{addsub8::exec(echo $dt->subMonth();/*pad(40)*/)}} // {{addsub8_eval}}
|
||||
{{addsub9::exec(echo $dt->subMonths(60);/*pad(40)*/)}} // {{addsub9_eval}}
|
||||
|
||||
{{addsub10::exec(echo $dt->addDays(29);/*pad(40)*/)}} // {{addsub10_eval}}
|
||||
{{addsub11::exec(echo $dt->addDay();/*pad(40)*/)}} // {{addsub11_eval}}
|
||||
{{addsub12::exec(echo $dt->subDay();/*pad(40)*/)}} // {{addsub12_eval}}
|
||||
{{addsub13::exec(echo $dt->subDays(29);/*pad(40)*/)}} // {{addsub13_eval}}
|
||||
|
||||
{{addsub14::exec(echo $dt->addWeekdays(4);/*pad(40)*/)}} // {{addsub14_eval}}
|
||||
{{addsub15::exec(echo $dt->addWeekday();/*pad(40)*/)}} // {{addsub15_eval}}
|
||||
{{addsub16::exec(echo $dt->subWeekday();/*pad(40)*/)}} // {{addsub16_eval}}
|
||||
{{addsub17::exec(echo $dt->subWeekdays(4);/*pad(40)*/)}} // {{addsub17_eval}}
|
||||
|
||||
{{addsub18::exec(echo $dt->addWeeks(3);/*pad(40)*/)}} // {{addsub18_eval}}
|
||||
{{addsub19::exec(echo $dt->addWeek();/*pad(40)*/)}} // {{addsub19_eval}}
|
||||
{{addsub20::exec(echo $dt->subWeek();/*pad(40)*/)}} // {{addsub20_eval}}
|
||||
{{addsub21::exec(echo $dt->subWeeks(3);/*pad(40)*/)}} // {{addsub21_eval}}
|
||||
|
||||
{{addsub22::exec(echo $dt->addHours(24);/*pad(40)*/)}} // {{addsub22_eval}}
|
||||
{{addsub23::exec(echo $dt->addHour();/*pad(40)*/)}} // {{addsub23_eval}}
|
||||
{{addsub24::exec(echo $dt->subHour();/*pad(40)*/)}} // {{addsub24_eval}}
|
||||
{{addsub25::exec(echo $dt->subHours(24);/*pad(40)*/)}} // {{addsub25_eval}}
|
||||
|
||||
{{addsub26::exec(echo $dt->addMinutes(61);/*pad(40)*/)}} // {{addsub26_eval}}
|
||||
{{addsub27::exec(echo $dt->addMinute();/*pad(40)*/)}} // {{addsub27_eval}}
|
||||
{{addsub28::exec(echo $dt->subMinute();/*pad(40)*/)}} // {{addsub28_eval}}
|
||||
{{addsub29::exec(echo $dt->subMinutes(61);/*pad(40)*/)}} // {{addsub29_eval}}
|
||||
|
||||
{{addsub30::exec(echo $dt->addSeconds(61);/*pad(40)*/)}} // {{addsub30_eval}}
|
||||
{{addsub31::exec(echo $dt->addSecond();/*pad(40)*/)}} // {{addsub31_eval}}
|
||||
{{addsub32::exec(echo $dt->subSecond();/*pad(40)*/)}} // {{addsub32_eval}}
|
||||
{{addsub33::exec(echo $dt->subSeconds(61);/*pad(40)*/)}} // {{addsub33_eval}}
|
||||
```
|
||||
|
||||
For fun you can also pass negative values to `addXXX()`, in fact that's how `subXXX()` is implemented.
|
||||
|
||||
<a name="api-difference"/>
|
||||
### Difference
|
||||
|
||||
These functions always return the **total difference** expressed in the specified time requested. This differs from the base class `diff()` function where an interval of 61 seconds would be returned as 1 minute and 1 second via a `DateInterval` instance. The `diffInMinutes()` function would simply return 1. All values are truncated and not rounded. Each function below has a default first parameter which is the Carbon instance to compare to, or null if you want to use `now()`. The 2nd parameter again is optional and indicates if you want the return value to be the absolute value or a relative value that might have a `-` (negative) sign if the passed in date is less than the current instance. This will default to true, return the absolute value. The comparisons are done in UTC.
|
||||
|
||||
```php
|
||||
// Carbon::diffInYears(Carbon $dt = null, $abs = true)
|
||||
|
||||
{{diff1::exec(echo Carbon::now('America/Vancouver')->diffInSeconds(Carbon::now('Europe/London'));)}} // {{diff1_eval}}
|
||||
|
||||
{{::lint($dtOttawa = Carbon::createFromDate(2000, 1, 1, 'America/Toronto');)}}
|
||||
{{::lint($dtVancouver = Carbon::createFromDate(2000, 1, 1, 'America/Vancouver');)}}
|
||||
{{diff4::exec(echo $dtOttawa->diffInHours($dtVancouver);/*pad(70)*/)}} // {{diff4_eval}}
|
||||
|
||||
{{diff5::exec(echo $dtOttawa->diffInHours($dtVancouver, false);/*pad(70)*/)}} // {{diff5_eval}}
|
||||
{{diff6::exec(echo $dtVancouver->diffInHours($dtOttawa, false);/*pad(70)*/)}} // {{diff6_eval}}
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 1, 31, 0);)}}
|
||||
{{diff8::exec(echo $dt->diffInDays($dt->copy()->addMonth());/*pad(70)*/)}} // {{diff8_eval}}
|
||||
{{diff9::exec(echo $dt->diffInDays($dt->copy()->subMonth(), false);/*pad(70)*/)}} // {{diff9_eval}}
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 4, 30, 0);)}}
|
||||
{{diff11::exec(echo $dt->diffInDays($dt->copy()->addMonth());/*pad(70)*/)}} // {{diff11_eval}}
|
||||
{{diff12::exec(echo $dt->diffInDays($dt->copy()->addWeek());/*pad(70)*/)}} // {{diff12_eval}}
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 1, 1, 0);)}}
|
||||
{{diff14::exec(echo $dt->diffInMinutes($dt->copy()->addSeconds(59));/*pad(70)*/)}} // {{diff14_eval}}
|
||||
{{diff15::exec(echo $dt->diffInMinutes($dt->copy()->addSeconds(60));/*pad(70)*/)}} // {{diff15_eval}}
|
||||
{{diff16::exec(echo $dt->diffInMinutes($dt->copy()->addSeconds(119));/*pad(70)*/)}} // {{diff16_eval}}
|
||||
{{diff17::exec(echo $dt->diffInMinutes($dt->copy()->addSeconds(120));/*pad(70)*/)}} // {{diff17_eval}}
|
||||
|
||||
// others that are defined
|
||||
// diffInYears(), diffInMonths(), diffInDays()
|
||||
// diffInHours(), diffInMinutes(), diffInSeconds()
|
||||
```
|
||||
|
||||
<a name="api-humandiff"/>
|
||||
### Difference for Humans
|
||||
|
||||
It is easier for humans to read `1 month ago` compared to 30 days ago. This is a common function seen in most date libraries so I thought I would add it here as well. It uses approximations for month being 30 days which then equates a year to 360 days. The lone argument for the function is the other Carbon instance to diff against, and of course it defaults to `now()` if not specified.
|
||||
|
||||
This method will add a phrase after the difference value relative to the instance and the passed in instance. There are 4 possibilities:
|
||||
|
||||
* When comparing a value in the past to default now:
|
||||
* 1 hour ago
|
||||
* 5 months ago
|
||||
|
||||
* When comparing a value in the future to default now:
|
||||
* 1 hour from now
|
||||
* 5 months from now
|
||||
|
||||
* When comparing a value in the past to another value:
|
||||
* 1 hour before
|
||||
* 5 months before
|
||||
|
||||
* When comparing a value in the future to another value:
|
||||
* 1 hour after
|
||||
* 5 months after
|
||||
|
||||
```php
|
||||
// The most typical usage is for comments
|
||||
// The instance is the date the comment was created and its being compared to default now()
|
||||
{{humandiff1::exec(echo Carbon::now()->subDays(5)->diffForHumans();/*pad(62)*/)}} // {{humandiff1_eval}}
|
||||
|
||||
{{humandiff2::exec(echo Carbon::now()->diffForHumans(Carbon::now()->subYear());/*pad(62)*/)}} // {{humandiff2_eval}}
|
||||
|
||||
{{::lint($dt = Carbon::createFromDate(2011, 2, 1);)}}
|
||||
|
||||
{{humandiff4::exec(echo $dt->diffForHumans($dt->copy()->addMonth());/*pad(62)*/)}} // {{humandiff4_eval}}
|
||||
{{humandiff5::exec(echo $dt->diffForHumans($dt->copy()->subMonth());/*pad(62)*/)}} // {{humandiff5_eval}}
|
||||
|
||||
{{humandiff6::exec(echo Carbon::now()->addSeconds(5)->diffForHumans();/*pad(62)*/)}} // {{humandiff6_eval}}
|
||||
```
|
||||
|
||||
<a name="api-modifiers"/>
|
||||
### Modifiers
|
||||
|
||||
These group of methods perform helpful modifications to the current instance. Most of them are self explanatory from their names... or at least should be. You'll also notice that the startOfXXX() methods set the time to 00:00:00 and the endOfXXX() methods set the time to 23:59:59.
|
||||
|
||||
```php
|
||||
{{::lint($dt = Carbon::create(2012, 1, 31, 12, 0, 0);/*pad(40)*/)}}
|
||||
{{modifier1::exec(echo $dt->startOfDay();/*pad(50)*/)}} // {{modifier1_eval}}
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 1, 31, 12, 0, 0);)}}
|
||||
{{modifier2::exec(echo $dt->endOfDay();/*pad(50)*/)}} // {{modifier2_eval}}
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 1, 31, 12, 0, 0);)}}
|
||||
{{modifier3::exec(echo $dt->startOfMonth();/*pad(50)*/)}} // {{modifier3_eval}}
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 1, 31, 12, 0, 0);)}}
|
||||
{{modifier4::exec(echo $dt->endOfMonth();/*pad(50)*/)}} // {{modifier4_eval}}
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 1, 31, 12, 0, 0);)}}
|
||||
{{modifier5::exec(echo $dt->startOfWeek();/*pad(50)*/)}} // {{modifier5_eval}}
|
||||
{{modifier6::exec(var_dump($dt->dayOfWeek == Carbon::MONDAY);/*pad(50)*/)}} // {{modifier6_eval}} : ISO8601 week starts on Monday
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 1, 31, 12, 0, 0);)}}
|
||||
{{modifier7::exec(echo $dt->endOfWeek();/*pad(50)*/)}} // {{modifier7_eval}}
|
||||
{{modifier8::exec(var_dump($dt->dayOfWeek == Carbon::SUNDAY);/*pad(50)*/)}} // {{modifier8_eval}} : ISO8601 week ends on Sunday
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 1, 31, 12, 0, 0);)}}
|
||||
{{modifier9::exec(echo $dt->next(Carbon::WEDNESDAY);/*pad(50)*/)}} // {{modifier9_eval}}
|
||||
{{modifier10::exec(var_dump($dt->dayOfWeek == Carbon::WEDNESDAY);/*pad(50)*/)}} // {{modifier10_eval}}
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 1, 1, 12, 0, 0);)}}
|
||||
{{modifier11::exec(echo $dt->next();/*pad(50)*/)}} // {{modifier11_eval}}
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 1, 31, 12, 0, 0);)}}
|
||||
{{modifier12::exec(echo $dt->previous(Carbon::WEDNESDAY);/*pad(50)*/)}} // {{modifier12_eval}}
|
||||
{{modifier13::exec(var_dump($dt->dayOfWeek == Carbon::WEDNESDAY);/*pad(50)*/)}} // {{modifier13_eval}}
|
||||
|
||||
{{::lint($dt = Carbon::create(2012, 1, 1, 12, 0, 0);)}}
|
||||
{{modifier14::exec(echo $dt->previous();/*pad(50)*/)}} // {{modifier14_eval}}
|
||||
|
||||
// others that are defined that are similar
|
||||
// firstOfMonth(), lastOfMonth(), nthOfMonth()
|
||||
// firstOfQuarter(), lastOfQuarter(), nthOfQuarter()
|
||||
// firstOfYear(), lastOfYear(), nthOfYear()
|
||||
```
|
||||
|
||||
<a name="api-constants"/>
|
||||
### Constants
|
||||
|
||||
The following constants are defined in the Carbon class.
|
||||
|
||||
* SUNDAY = 0
|
||||
* MONDAY = 1
|
||||
* TUESDAY = 2
|
||||
* WEDNESDAY = 3
|
||||
* THURSDAY = 4
|
||||
* FRIDAY = 5
|
||||
* SATURDAY = 6
|
||||
* MONTHS_PER_YEAR = 12
|
||||
* HOURS_PER_DAY = 24
|
||||
* MINUTES_PER_HOUR = 60
|
||||
* SECONDS_PER_MINUTE = 60
|
||||
|
||||
```php
|
||||
{{::lint(
|
||||
$dt = Carbon::createFromDate(2012, 10, 6);
|
||||
if ($dt->dayOfWeek === Carbon::SATURDAY) {
|
||||
echo 'Place bets on Ottawa Senators Winning!';
|
||||
}
|
||||
)}}
|
||||
```
|
||||
|
||||
<a name="about"/>
|
||||
## About
|
||||
|
||||
<a name="about-contributing"/>
|
||||
### Contributing
|
||||
|
||||
I hate reading a readme.md file that has code errors and/or sample output that is incorrect. I tried something new with this project and wrote a quick readme parser that can **lint** sample source code or **execute** and inject the actual result into a generated readme.
|
||||
|
||||
> **Don't make changes to the `readme.md` directly!!**
|
||||
|
||||
Change the `readme.src.md` and then use the `readme.php` to generate the new `readme.md` file. It can be run at the command line using `php readme.php` from the project root. Maybe someday I'll extract this out to another project or at least run it with a post receive hook, but for now its just a local tool, deal with it.
|
||||
|
||||
The commands are quickly explained below. To see some examples you can view the raw `readme.src.md` file in this repo.
|
||||
|
||||
`\{\{::lint()}}`
|
||||
|
||||
The `lint` command is meant for confirming the code is valid and will `eval()` the code passed into the function. Assuming there were no errors, the executed source code will then be injected back into the text replacing out the `\{\{::lint()}}`. When you look at the raw `readme.src.md` you will see that the code can span several lines. Remember the code is executed in the context of the running script so any variables will be available for the rest of the file.
|
||||
|
||||
\{\{::lint($var = 'brian nesbitt';)}} => {{::lint($var = 'brian nesbitt';)}}
|
||||
|
||||
> As mentioned the `$var` can later be echo'd and you would get 'brian nesbitt' as all of the source is executed in the same scope.
|
||||
|
||||
`\{\{varName::exec()}}` and `{{varName_eval}}`
|
||||
|
||||
The `exec` command begins by performing an `eval()` on the code passed into the function. The executed source code will then be injected back into the text replacing out the `\{\{varName::exec()}}`. This will also create a variable named `varName_eval` that you can then place anywhere in the file and it will get replaced with the output of the `eval()`. You can use any type of output (`echo`, `printf`, `var_dump` etc) statement to return the result value as an output buffer is setup to capture the output.
|
||||
|
||||
\{\{exVarName::exec(echo $var;)}} => {{exVarName::exec(echo $var;)}}
|
||||
\{\{exVarName_eval}} => {{exVarName_eval}} // $var is still set from above
|
||||
|
||||
`/*pad()*/`
|
||||
|
||||
The `pad()` is a special source modifier. This will pad the code block to the indicated number of characters using spaces. Its particularly handy for aligning `//` comments when showing results.
|
||||
|
||||
\{\{exVarName1::exec(echo 12345;/*pad(20)*/)}} // \{\{exVarName1_eval}}
|
||||
\{\{exVarName2::exec(echo 6;/*pad(20)*/)}} // \{\{exVarName2_eval}}
|
||||
|
||||
... would generate to:
|
||||
|
||||
{{exVarName1::exec(echo 12345;/*pad(20)*/)}} // {{exVarName1_eval}}
|
||||
{{exVarName2::exec(echo 6;/*pad(20)*/)}} // {{exVarName2_eval}}
|
||||
|
||||
Apart from the readme the typical steps can be used to contribute your own improvements.
|
||||
|
||||
* Fork
|
||||
* Clone
|
||||
* PHPUnit
|
||||
* Branch
|
||||
* PHPUnit
|
||||
* Code
|
||||
* PHPUnit
|
||||
* Commit
|
||||
* Push
|
||||
* Pull request
|
||||
* Relax and play Castle Crashers
|
||||
|
||||
<a name="about-author"/>
|
||||
### Author
|
||||
|
||||
Brian Nesbitt - <brian@nesbot.com> - <http://twitter.com/NesbittBrian>
|
||||
|
||||
<a name="about-license"/>
|
||||
### License
|
||||
|
||||
Carbon is licensed under the MIT License - see the `LICENSE` file for details
|
||||
|
||||
<a name="about-history"/>
|
||||
### History
|
||||
|
||||
You can view the history of the Carbon project in the [history file](https://github.com/briannesbitt/Carbon/blob/master/history.md).
|
||||
|
||||
<a name="about-whyname"/>
|
||||
### Why the name Carbon?
|
||||
|
||||
Read about [Carbon Dating](http://en.wikipedia.org/wiki/Radiocarbon_dating)
|
1897
vendor/nesbot/carbon/src/Carbon/Carbon.php
vendored
Normal file
1897
vendor/nesbot/carbon/src/Carbon/Carbon.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
163
vendor/nesbot/carbon/tests/AddTest.php
vendored
Normal file
163
vendor/nesbot/carbon/tests/AddTest.php
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class AddTest extends TestFixture
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public function testAddMonthsPositive()
|
||||
{
|
||||
$this->assertSame(1, Carbon::createFromDate(1975, 12)->addMonths(1)->month);
|
||||
}
|
||||
public function testAddMonthsZero()
|
||||
{
|
||||
$this->assertSame(12, Carbon::createFromDate(1975, 12)->addMonths(0)->month);
|
||||
}
|
||||
public function testAddMonthsNegative()
|
||||
{
|
||||
$this->assertSame(11, Carbon::createFromDate(1975, 12, 1)->addMonths(-1)->month);
|
||||
}
|
||||
|
||||
public function testAddMonth()
|
||||
{
|
||||
$this->assertSame(1, Carbon::createFromDate(1975, 12)->addMonth()->month);
|
||||
}
|
||||
public function testAddMonthWithOverflow()
|
||||
{
|
||||
$this->assertSame(3, Carbon::createFromDate(2012, 1, 31)->addMonth()->month);
|
||||
}
|
||||
|
||||
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 testAddWeekdaysPositive()
|
||||
{
|
||||
$this->assertSame(17, Carbon::createFromDate(2012, 1, 4)->addWeekdays(9)->day);
|
||||
}
|
||||
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 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 testAddSecond()
|
||||
{
|
||||
$this->assertSame(1, Carbon::createFromTime(0, 0, 0)->addSecond()->second);
|
||||
}
|
||||
}
|
134
vendor/nesbot/carbon/tests/ComparisonTest.php
vendored
Normal file
134
vendor/nesbot/carbon/tests/ComparisonTest.php
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ComparisonTest extends TestFixture
|
||||
{
|
||||
public function testEqualToTrue()
|
||||
{
|
||||
$this->assertTrue(Carbon::createFromDate(2000, 1, 1)->eq(Carbon::createFromDate(2000, 1, 1)));
|
||||
}
|
||||
public function testEqualToFalse()
|
||||
{
|
||||
$this->assertFalse(Carbon::createFromDate(2000, 1, 1)->eq(Carbon::createFromDate(2000, 1, 2)));
|
||||
}
|
||||
public function testEqualWithTimezoneTrue()
|
||||
{
|
||||
$this->assertTrue(Carbon::create(2000, 1, 1, 12, 0, 0, 'America/Toronto')->eq(Carbon::create(2000, 1, 1, 9, 0, 0, 'America/Vancouver')));
|
||||
}
|
||||
public function testEqualWithTimezoneFalse()
|
||||
{
|
||||
$this->assertFalse(Carbon::createFromDate(2000, 1, 1, 'America/Toronto')->eq(Carbon::createFromDate(2000, 1, 1, 'America/Vancouver')));
|
||||
}
|
||||
|
||||
public function testNotEqualToTrue()
|
||||
{
|
||||
$this->assertTrue(Carbon::createFromDate(2000, 1, 1)->ne(Carbon::createFromDate(2000, 1, 2)));
|
||||
}
|
||||
public function testNotEqualToFalse()
|
||||
{
|
||||
$this->assertFalse(Carbon::createFromDate(2000, 1, 1)->ne(Carbon::createFromDate(2000, 1, 1)));
|
||||
}
|
||||
public function testNotEqualWithTimezone()
|
||||
{
|
||||
$this->assertTrue(Carbon::createFromDate(2000, 1, 1, 'America/Toronto')->ne(Carbon::createFromDate(2000, 1, 1, 'America/Vancouver')));
|
||||
}
|
||||
|
||||
public function testGreaterThanTrue()
|
||||
{
|
||||
$this->assertTrue(Carbon::createFromDate(2000, 1, 1)->gt(Carbon::createFromDate(1999, 12, 31)));
|
||||
}
|
||||
public function testGreaterThanFalse()
|
||||
{
|
||||
$this->assertFalse(Carbon::createFromDate(2000, 1, 1)->gt(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->gt($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->gt($dt2));
|
||||
}
|
||||
|
||||
public function testGreaterThanOrEqualTrue()
|
||||
{
|
||||
$this->assertTrue(Carbon::createFromDate(2000, 1, 1)->gte(Carbon::createFromDate(1999, 12, 31)));
|
||||
}
|
||||
public function testGreaterThanOrEqualTrueEqual()
|
||||
{
|
||||
$this->assertTrue(Carbon::createFromDate(2000, 1, 1)->gte(Carbon::createFromDate(2000, 1, 1)));
|
||||
}
|
||||
public function testGreaterThanOrEqualFalse()
|
||||
{
|
||||
$this->assertFalse(Carbon::createFromDate(2000, 1, 1)->gte(Carbon::createFromDate(2000, 1, 2)));
|
||||
}
|
||||
|
||||
public function testLessThanTrue()
|
||||
{
|
||||
$this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lt(Carbon::createFromDate(2000, 1, 2)));
|
||||
}
|
||||
public function testLessThanFalse()
|
||||
{
|
||||
$this->assertFalse(Carbon::createFromDate(2000, 1, 1)->lt(Carbon::createFromDate(1999, 12, 31)));
|
||||
}
|
||||
|
||||
public function testLessThanOrEqualTrue()
|
||||
{
|
||||
$this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lte(Carbon::createFromDate(2000, 1, 2)));
|
||||
}
|
||||
public function testLessThanOrEqualTrueEqual()
|
||||
{
|
||||
$this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lte(Carbon::createFromDate(2000, 1, 1)));
|
||||
}
|
||||
public function testLessThanOrEqualFalse()
|
||||
{
|
||||
$this->assertFalse(Carbon::createFromDate(2000, 1, 1)->lte(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));
|
||||
}
|
||||
}
|
80
vendor/nesbot/carbon/tests/ConstructTest.php
vendored
Normal file
80
vendor/nesbot/carbon/tests/ConstructTest.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ConstructTest extends TestFixture
|
||||
{
|
||||
public function testCreatesAnInstanceDefaultToNow()
|
||||
{
|
||||
$c = new Carbon();
|
||||
$now = Carbon::now();
|
||||
$this->assertEquals('Carbon\Carbon', get_class($c));
|
||||
$this->assertEquals($now->tzName, $c->tzName);
|
||||
$this->assertCarbon($c, $now->year, $now->month, $now->day, $now->hour, $now->minute, $now->second);
|
||||
}
|
||||
public function testParseCreatesAnInstanceDefaultToNow()
|
||||
{
|
||||
$c = Carbon::parse();
|
||||
$now = Carbon::now();
|
||||
$this->assertEquals('Carbon\Carbon', get_class($c));
|
||||
$this->assertEquals($now->tzName, $c->tzName);
|
||||
$this->assertCarbon($c, $now->year, $now->month, $now->day, $now->hour, $now->minute, $now->second);
|
||||
}
|
||||
|
||||
public function testWithFancyString()
|
||||
{
|
||||
$c = new Carbon('first day of January 2008');
|
||||
$this->assertCarbon($c, 2008, 1, 1, 0, 0, 0);
|
||||
}
|
||||
public function testParseWithFancyString()
|
||||
{
|
||||
$c = Carbon::parse('first day of January 2008');
|
||||
$this->assertCarbon($c, 2008, 1, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
$c = new Carbon('now', new \DateTimeZone('Europe/London'));
|
||||
$this->assertSame('Europe/London', $c->tzName);
|
||||
$this->assertSame(1, $c->offsetHours);
|
||||
}
|
||||
public function testParseSettingTimezone()
|
||||
{
|
||||
$c = Carbon::parse('now', new \DateTimeZone('Europe/London'));
|
||||
$this->assertSame('Europe/London', $c->tzName);
|
||||
$this->assertSame(1, $c->offsetHours);
|
||||
}
|
||||
|
||||
public function testSettingTimezoneWithString()
|
||||
{
|
||||
$c = new Carbon('now', 'Asia/Tokyo');
|
||||
$this->assertSame('Asia/Tokyo', $c->tzName);
|
||||
$this->assertSame(9, $c->offsetHours);
|
||||
}
|
||||
public function testParseSettingTimezoneWithString()
|
||||
{
|
||||
$c = Carbon::parse('now', 'Asia/Tokyo');
|
||||
$this->assertSame('Asia/Tokyo', $c->tzName);
|
||||
$this->assertSame(9, $c->offsetHours);
|
||||
}
|
||||
}
|
30
vendor/nesbot/carbon/tests/CopyTest.php
vendored
Normal file
30
vendor/nesbot/carbon/tests/CopyTest.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CopyTest extends TestFixture
|
||||
{
|
||||
public function testCopy()
|
||||
{
|
||||
$dating = Carbon::now();
|
||||
$dating2 = $dating->copy();
|
||||
$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);
|
||||
}
|
||||
}
|
59
vendor/nesbot/carbon/tests/CreateFromDateTest.php
vendored
Normal file
59
vendor/nesbot/carbon/tests/CreateFromDateTest.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateFromDateTest extends TestFixture
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
36
vendor/nesbot/carbon/tests/CreateFromFormatTest.php
vendored
Normal file
36
vendor/nesbot/carbon/tests/CreateFromFormatTest.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateFromFormatTest extends TestFixture
|
||||
{
|
||||
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->assertTrue($d instanceof Carbon);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
60
vendor/nesbot/carbon/tests/CreateFromTimeTest.php
vendored
Normal file
60
vendor/nesbot/carbon/tests/CreateFromTimeTest.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateFromTimeTest extends TestFixture
|
||||
{
|
||||
public function testCreateFromDateWithDefaults()
|
||||
{
|
||||
$d = Carbon::createFromTime();
|
||||
$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()->year, Carbon::now()->month, Carbon::now()->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()->year, Carbon::now()->month, Carbon::now()->day, 12, 0, 0);
|
||||
$this->assertSame('Europe/London', $d->tzName);
|
||||
}
|
||||
}
|
51
vendor/nesbot/carbon/tests/CreateFromTimestampTest.php
vendored
Normal file
51
vendor/nesbot/carbon/tests/CreateFromTimestampTest.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateFromTimestampTest extends TestFixture
|
||||
{
|
||||
public function testCreateReturnsDatingInstance()
|
||||
{
|
||||
$d = Carbon::createFromTimestamp(Carbon::create(1975, 5, 21, 22, 32, 5)->timestamp);
|
||||
$this->assertCarbon($d, 1975, 5, 21, 22, 32, 5);
|
||||
}
|
||||
|
||||
public function testCreateFromTimestampUsesDefaultTimezone()
|
||||
{
|
||||
$d = Carbon::createFromTimestamp(0);
|
||||
|
||||
// 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->assertTrue($d->offset === 0);
|
||||
$this->assertSame('UTC', $d->tzName);
|
||||
}
|
||||
|
||||
public function testCreateFromTimestampGMTDoesNotUseDefaultTimezone()
|
||||
{
|
||||
$d = Carbon::createFromTimestampUTC(0);
|
||||
$this->assertCarbon($d, 1970, 1, 1, 0, 0, 0);
|
||||
$this->assertTrue($d->offset === 0);
|
||||
}
|
||||
}
|
133
vendor/nesbot/carbon/tests/CreateTest.php
vendored
Normal file
133
vendor/nesbot/carbon/tests/CreateTest.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateTest extends TestFixture
|
||||
{
|
||||
public function testCreateReturnsDatingInstance()
|
||||
{
|
||||
$d = Carbon::create();
|
||||
$this->assertTrue($d instanceof Carbon);
|
||||
}
|
||||
|
||||
public function testCreateWithDefaults()
|
||||
{
|
||||
$d = Carbon::create();
|
||||
$this->assertSame($d->timestamp, Carbon::now()->timestamp);
|
||||
}
|
||||
|
||||
public function testCreateWithYear()
|
||||
{
|
||||
$d = Carbon::create(2012);
|
||||
$this->assertSame(2012, $d->year);
|
||||
}
|
||||
public function testCreateWithInvalidYear()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$d = Carbon::create(-3);
|
||||
}
|
||||
|
||||
public function testCreateWithMonth()
|
||||
{
|
||||
$d = Carbon::create(null, 3);
|
||||
$this->assertSame(3, $d->month);
|
||||
}
|
||||
public function testCreateWithInvalidMonth()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$d = 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->setExpectedException('InvalidArgumentException');
|
||||
$d = 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->setExpectedException('InvalidArgumentException');
|
||||
$d = 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->setExpectedException('InvalidArgumentException');
|
||||
$d = 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->setExpectedException('InvalidArgumentException');
|
||||
$d = 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);
|
||||
}
|
||||
}
|
256
vendor/nesbot/carbon/tests/DayOfWeekModifiersTest.php
vendored
Normal file
256
vendor/nesbot/carbon/tests/DayOfWeekModifiersTest.php
vendored
Normal file
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DayOfWeekModifiersTest extends TestFixture
|
||||
{
|
||||
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 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 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 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 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 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);
|
||||
}
|
||||
}
|
436
vendor/nesbot/carbon/tests/DiffTest.php
vendored
Normal file
436
vendor/nesbot/carbon/tests/DiffTest.php
vendored
Normal file
@@ -0,0 +1,436 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DiffTest extends TestFixture
|
||||
{
|
||||
public function testDiffInYearsPositive()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(1, $dt->diffInYears($dt->copy()->addYear()));
|
||||
}
|
||||
public function testDiffInYearsNegativeWithSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(-1, $dt->diffInYears($dt->copy()->subYear(), false));
|
||||
}
|
||||
public function testDiffInYearsNegativeNoSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(1, $dt->diffInYears($dt->copy()->subYear()));
|
||||
}
|
||||
public function testDiffInYearsVsDefaultNow()
|
||||
{
|
||||
$this->assertSame(1, Carbon::now()->subYear()->diffInYears());
|
||||
}
|
||||
public function testDiffInYearsEnsureIsTruncated()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(1, $dt->diffInYears($dt->copy()->addYear()->addMonths(7)));
|
||||
}
|
||||
|
||||
public function testDiffInMonthsPositive()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(13, $dt->diffInMonths($dt->copy()->addYear()->addMonth()));
|
||||
}
|
||||
public function testDiffInMonthsNegativeWithSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(-11, $dt->diffInMonths($dt->copy()->subYear()->addMonth(), false));
|
||||
}
|
||||
public function testDiffInMonthsNegativeNoSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(11, $dt->diffInMonths($dt->copy()->subYear()->addMonth()));
|
||||
}
|
||||
public function testDiffInMonthsVsDefaultNow()
|
||||
{
|
||||
$this->assertSame(12, Carbon::now()->subYear()->diffInMonths());
|
||||
}
|
||||
public function testDiffInMonthsEnsureIsTruncated()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(1, $dt->diffInMonths($dt->copy()->addMonth()->addDays(16)));
|
||||
}
|
||||
|
||||
public function testDiffInDaysPositive()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(366, $dt->diffInDays($dt->copy()->addYear()));
|
||||
}
|
||||
public function testDiffInDaysNegativeWithSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(-365, $dt->diffInDays($dt->copy()->subYear(), false));
|
||||
}
|
||||
public function testDiffInDaysNegativeNoSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(365, $dt->diffInDays($dt->copy()->subYear()));
|
||||
}
|
||||
public function testDiffInDaysVsDefaultNow()
|
||||
{
|
||||
$this->assertSame(7, Carbon::now()->subWeek()->diffInDays());
|
||||
}
|
||||
public function testDiffInDaysEnsureIsTruncated()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(1, $dt->diffInDays($dt->copy()->addDay()->addHours(13)));
|
||||
}
|
||||
|
||||
public function testDiffInHoursPositive()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(26, $dt->diffInHours($dt->copy()->addDay()->addHours(2)));
|
||||
}
|
||||
public function testDiffInHoursNegativeWithSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(-22, $dt->diffInHours($dt->copy()->subDay()->addHours(2), false));
|
||||
}
|
||||
public function testDiffInHoursNegativeNoSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(22, $dt->diffInHours($dt->copy()->subDay()->addHours(2)));
|
||||
}
|
||||
public function testDiffInHoursVsDefaultNow()
|
||||
{
|
||||
$this->assertSame(48, Carbon::now()->subDays(2)->diffInHours());
|
||||
}
|
||||
public function testDiffInHoursEnsureIsTruncated()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(1, $dt->diffInHours($dt->copy()->addHour()->addMinutes(31)));
|
||||
}
|
||||
|
||||
public function testDiffInMinutesPositive()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(62, $dt->diffInMinutes($dt->copy()->addHour()->addMinutes(2)));
|
||||
}
|
||||
public function testDiffInMinutesPositiveAlot()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(1502, $dt->diffInMinutes($dt->copy()->addHours(25)->addMinutes(2)));
|
||||
}
|
||||
public function testDiffInMinutesNegativeWithSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(-58, $dt->diffInMinutes($dt->copy()->subHour()->addMinutes(2), false));
|
||||
}
|
||||
public function testDiffInMinutesNegativeNoSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(58, $dt->diffInMinutes($dt->copy()->subHour()->addMinutes(2)));
|
||||
}
|
||||
public function testDiffInMinutesVsDefaultNow()
|
||||
{
|
||||
$this->assertSame(60, Carbon::now()->subHour()->diffInMinutes());
|
||||
}
|
||||
public function testDiffInMinutesEnsureIsTruncated()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(1, $dt->diffInMinutes($dt->copy()->addMinute()->addSeconds(31)));
|
||||
}
|
||||
|
||||
public function testDiffInSecondsPositive()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(62, $dt->diffInSeconds($dt->copy()->addMinute()->addSeconds(2)));
|
||||
}
|
||||
public function testDiffInSecondsPositiveAlot()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(7202, $dt->diffInSeconds($dt->copy()->addHours(2)->addSeconds(2)));
|
||||
}
|
||||
public function testDiffInSecondsNegativeWithSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(-58, $dt->diffInSeconds($dt->copy()->subMinute()->addSeconds(2), false));
|
||||
}
|
||||
public function testDiffInSecondsNegativeNoSign()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(58, $dt->diffInSeconds($dt->copy()->subMinute()->addSeconds(2)));
|
||||
}
|
||||
public function testDiffInSecondsVsDefaultNow()
|
||||
{
|
||||
$this->assertSame(3600, Carbon::now()->subHour()->diffInSeconds());
|
||||
}
|
||||
public function testDiffInSecondsEnsureIsTruncated()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertSame(1, $dt->diffInSeconds($dt->copy()->addSeconds(1.9)));
|
||||
}
|
||||
|
||||
public function testDiffInSecondsWithTimezones()
|
||||
{
|
||||
$dtOttawa = Carbon::createFromDate(2000, 1, 1, 'America/Toronto');
|
||||
$dtVancouver = Carbon::createFromDate(2000, 1, 1, 'America/Vancouver');
|
||||
$this->assertSame(3*60*60, $dtOttawa->diffInSeconds($dtVancouver));
|
||||
}
|
||||
public function testDiffInSecondsWithTimezonesAndVsDefault()
|
||||
{
|
||||
$dt = Carbon::now('America/Vancouver');
|
||||
$this->assertSame(0, $dt->diffInSeconds());
|
||||
}
|
||||
|
||||
public function testDiffForHumansNowAndSecond()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertSame('1 second ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndSecondWithTimezone()
|
||||
{
|
||||
$d = Carbon::now('America/Vancouver');
|
||||
$this->assertSame('1 second ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndSeconds()
|
||||
{
|
||||
$d = Carbon::now()->subSeconds(2);
|
||||
$this->assertSame('2 seconds ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndMinute()
|
||||
{
|
||||
$d = Carbon::now()->subMinute();
|
||||
$this->assertSame('1 minute ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndMinutes()
|
||||
{
|
||||
$d = Carbon::now()->subMinutes(2);
|
||||
$this->assertSame('2 minutes ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndHour()
|
||||
{
|
||||
$d = Carbon::now()->subHour();
|
||||
$this->assertSame('1 hour ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndHours()
|
||||
{
|
||||
$d = Carbon::now()->subHours(2);
|
||||
$this->assertSame('2 hours ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndDay()
|
||||
{
|
||||
$d = Carbon::now()->subDay();
|
||||
$this->assertSame('1 day ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndDays()
|
||||
{
|
||||
$d = Carbon::now()->subDays(2);
|
||||
$this->assertSame('2 days ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndMonth()
|
||||
{
|
||||
$d = Carbon::now()->subMonth();
|
||||
$this->assertSame('1 month ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndMonths()
|
||||
{
|
||||
$d = Carbon::now()->subMonths(2);
|
||||
$this->assertSame('2 months ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndYear()
|
||||
{
|
||||
$d = Carbon::now()->subYear();
|
||||
$this->assertSame('1 year ago', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndYears()
|
||||
{
|
||||
$d = Carbon::now()->subYears(2);
|
||||
$this->assertSame('2 years ago', $d->diffForHumans());
|
||||
}
|
||||
|
||||
public function testDiffForHumansNowAndFutureSecond()
|
||||
{
|
||||
$d = Carbon::now()->addSecond();
|
||||
$this->assertSame('1 second from now', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndFutureSeconds()
|
||||
{
|
||||
$d = Carbon::now()->addSeconds(2);
|
||||
$this->assertSame('2 seconds from now', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndFutureMinute()
|
||||
{
|
||||
$d = Carbon::now()->addMinute();
|
||||
$this->assertSame('1 minute from now', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndFutureMinutes()
|
||||
{
|
||||
$d = Carbon::now()->addMinutes(2);
|
||||
$this->assertSame('2 minutes from now', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndFutureHour()
|
||||
{
|
||||
$d = Carbon::now()->addHour();
|
||||
$this->assertSame('1 hour from now', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndFutureHours()
|
||||
{
|
||||
$d = Carbon::now()->addHours(2);
|
||||
$this->assertSame('2 hours from now', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndFutureDay()
|
||||
{
|
||||
$d = Carbon::now()->addDay();
|
||||
$this->assertSame('1 day from now', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndFutureDays()
|
||||
{
|
||||
$d = Carbon::now()->addDays(2);
|
||||
$this->assertSame('2 days from now', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndFutureMonth()
|
||||
{
|
||||
$d = Carbon::now()->addMonth();
|
||||
$this->assertSame('1 month from now', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndFutureMonths()
|
||||
{
|
||||
$d = Carbon::now()->addMonths(2);
|
||||
$this->assertSame('2 months from now', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndFutureYear()
|
||||
{
|
||||
$d = Carbon::now()->addYear();
|
||||
$this->assertSame('1 year from now', $d->diffForHumans());
|
||||
}
|
||||
public function testDiffForHumansNowAndFutureYears()
|
||||
{
|
||||
$d = Carbon::now()->addYears(2);
|
||||
$this->assertSame('2 years from now', $d->diffForHumans());
|
||||
}
|
||||
|
||||
public function testDiffForHumansOtherAndSecond()
|
||||
{
|
||||
$d = Carbon::now()->addSecond();
|
||||
$this->assertSame('1 second before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndSeconds()
|
||||
{
|
||||
$d = Carbon::now()->addSeconds(2);
|
||||
$this->assertSame('2 seconds before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndMinute()
|
||||
{
|
||||
$d = Carbon::now()->addMinute();
|
||||
$this->assertSame('1 minute before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndMinutes()
|
||||
{
|
||||
$d = Carbon::now()->addMinutes(2);
|
||||
$this->assertSame('2 minutes before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndHour()
|
||||
{
|
||||
$d = Carbon::now()->addHour();
|
||||
$this->assertSame('1 hour before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndHours()
|
||||
{
|
||||
$d = Carbon::now()->addHours(2);
|
||||
$this->assertSame('2 hours before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndDay()
|
||||
{
|
||||
$d = Carbon::now()->addDay();
|
||||
$this->assertSame('1 day before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndDays()
|
||||
{
|
||||
$d = Carbon::now()->addDays(2);
|
||||
$this->assertSame('2 days before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndMonth()
|
||||
{
|
||||
$d = Carbon::now()->addMonth();
|
||||
$this->assertSame('1 month before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndMonths()
|
||||
{
|
||||
$d = Carbon::now()->addMonths(2);
|
||||
$this->assertSame('2 months before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndYear()
|
||||
{
|
||||
$d = Carbon::now()->addYear();
|
||||
$this->assertSame('1 year before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndYears()
|
||||
{
|
||||
$d = Carbon::now()->addYears(2);
|
||||
$this->assertSame('2 years before', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
|
||||
public function testDiffForHumansOtherAndFutureSecond()
|
||||
{
|
||||
$d = Carbon::now()->subSecond();
|
||||
$this->assertSame('1 second after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndFutureSeconds()
|
||||
{
|
||||
$d = Carbon::now()->subSeconds(2);
|
||||
$this->assertSame('2 seconds after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndFutureMinute()
|
||||
{
|
||||
$d = Carbon::now()->subMinute();
|
||||
$this->assertSame('1 minute after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndFutureMinutes()
|
||||
{
|
||||
$d = Carbon::now()->subMinutes(2);
|
||||
$this->assertSame('2 minutes after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndFutureHour()
|
||||
{
|
||||
$d = Carbon::now()->subHour();
|
||||
$this->assertSame('1 hour after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndFutureHours()
|
||||
{
|
||||
$d = Carbon::now()->subHours(2);
|
||||
$this->assertSame('2 hours after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndFutureDay()
|
||||
{
|
||||
$d = Carbon::now()->subDay();
|
||||
$this->assertSame('1 day after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndFutureDays()
|
||||
{
|
||||
$d = Carbon::now()->subDays(2);
|
||||
$this->assertSame('2 days after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndFutureMonth()
|
||||
{
|
||||
$d = Carbon::now()->subMonth();
|
||||
$this->assertSame('1 month after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndFutureMonths()
|
||||
{
|
||||
$d = Carbon::now()->subMonths(2);
|
||||
$this->assertSame('2 months after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndFutureYear()
|
||||
{
|
||||
$d = Carbon::now()->subYear();
|
||||
$this->assertSame('1 year after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
public function testDiffForHumansOtherAndFutureYears()
|
||||
{
|
||||
$d = Carbon::now()->subYears(2);
|
||||
$this->assertSame('2 years after', Carbon::now()->diffForHumans($d));
|
||||
}
|
||||
}
|
108
vendor/nesbot/carbon/tests/FluidSettersTest.php
vendored
Normal file
108
vendor/nesbot/carbon/tests/FluidSettersTest.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class FluidSettersTest extends TestFixture
|
||||
{
|
||||
public function testFluidYearSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertTrue($d->year(1995) instanceof Carbon);
|
||||
$this->assertSame(1995, $d->year);
|
||||
}
|
||||
|
||||
public function testFluidMonthSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertTrue($d->month(3) instanceof Carbon);
|
||||
$this->assertSame(3, $d->month);
|
||||
}
|
||||
public function testFluidMonthSetterWithWrap()
|
||||
{
|
||||
$d = Carbon::createFromDate(2012, 8, 21);
|
||||
$this->assertTrue($d->month(13) instanceof Carbon);
|
||||
$this->assertSame(1, $d->month);
|
||||
}
|
||||
|
||||
public function testFluidDaySetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertTrue($d->day(2) instanceof Carbon);
|
||||
$this->assertSame(2, $d->day);
|
||||
}
|
||||
public function testFluidDaySetterWithWrap()
|
||||
{
|
||||
$d = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertTrue($d->day(32) instanceof Carbon);
|
||||
$this->assertSame(1, $d->day);
|
||||
}
|
||||
|
||||
public function testFluidSetDate()
|
||||
{
|
||||
$d = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertTrue($d->setDate(1995, 13, 32) instanceof Carbon);
|
||||
$this->assertCarbon($d, 1996, 2, 1);
|
||||
}
|
||||
|
||||
public function testFluidHourSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertTrue($d->hour(2) instanceof Carbon);
|
||||
$this->assertSame(2, $d->hour);
|
||||
}
|
||||
public function testFluidHourSetterWithWrap()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertTrue($d->hour(25) instanceof Carbon);
|
||||
$this->assertSame(1, $d->hour);
|
||||
}
|
||||
|
||||
public function testFluidMinuteSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertTrue($d->minute(2) instanceof Carbon);
|
||||
$this->assertSame(2, $d->minute);
|
||||
}
|
||||
public function testFluidMinuteSetterWithWrap()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertTrue($d->minute(61) instanceof Carbon);
|
||||
$this->assertSame(1, $d->minute);
|
||||
}
|
||||
|
||||
public function testFluidSecondSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertTrue($d->second(2) instanceof Carbon);
|
||||
$this->assertSame(2, $d->second);
|
||||
}
|
||||
public function testFluidSecondSetterWithWrap()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertTrue($d->second(62) instanceof Carbon);
|
||||
$this->assertSame(2, $d->second);
|
||||
}
|
||||
|
||||
public function testFluidSetTime()
|
||||
{
|
||||
$d = Carbon::createFromDate(2000, 1, 1);
|
||||
$this->assertTrue($d->setTime(25, 61, 61) instanceof Carbon);
|
||||
$this->assertCarbon($d, 2000, 1, 2, 2, 2, 1);
|
||||
}
|
||||
|
||||
public function testFluidTimestampSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertTrue($d->timestamp(10) instanceof Carbon);
|
||||
$this->assertSame(10, $d->timestamp);
|
||||
}
|
||||
}
|
198
vendor/nesbot/carbon/tests/GettersTest.php
vendored
Normal file
198
vendor/nesbot/carbon/tests/GettersTest.php
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class GettersTest extends TestFixture
|
||||
{
|
||||
public function testGettersThrowExceptionOnUnknownGetter()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
Carbon::create(1234, 5, 6, 7, 8, 9)->sdfsdfss;
|
||||
}
|
||||
public function testYearGetter()
|
||||
{
|
||||
$d = Carbon::create(1234, 5, 6, 7, 8, 9);
|
||||
$this->assertSame(1234, $d->year);
|
||||
}
|
||||
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 testDayOfWeeGetter()
|
||||
{
|
||||
$d = Carbon::create(2012, 5, 7, 7, 8, 9);
|
||||
$this->assertSame(Carbon::MONDAY, $d->dayOfWeek);
|
||||
}
|
||||
public function testDayOfYearGetter()
|
||||
{
|
||||
$d = Carbon::createFromDate(2012, 5, 7);
|
||||
$this->assertSame(127, $d->dayOfYear);
|
||||
}
|
||||
public function testDaysInMonthGetter()
|
||||
{
|
||||
$d = Carbon::createFromDate(2012, 5, 7);
|
||||
$this->assertSame(31, $d->daysInMonth);
|
||||
}
|
||||
public function testTimestampGetter()
|
||||
{
|
||||
$d = Carbon::create();
|
||||
$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 = intval(substr(date('Ymd') - date('Ymd', $d->timestamp), 0, -4));
|
||||
|
||||
$this->assertSame($age, $d->age);
|
||||
}
|
||||
|
||||
public function testGetQuarterFirst()
|
||||
{
|
||||
$d = Carbon::createFromDate(2012, 1, 1);
|
||||
$this->assertSame(1, $d->quarter);
|
||||
}
|
||||
public function testGetQuarterFirstEnd()
|
||||
{
|
||||
$d = Carbon::createFromDate(2012, 3, 31);
|
||||
$this->assertSame(1, $d->quarter);
|
||||
}
|
||||
public function testGetQuarterSecond()
|
||||
{
|
||||
$d = Carbon::createFromDate(2012, 4, 1);
|
||||
$this->assertSame(2, $d->quarter);
|
||||
}
|
||||
public function testGetQuarterThird()
|
||||
{
|
||||
$d = Carbon::createFromDate(2012, 7, 1);
|
||||
$this->assertSame(3, $d->quarter);
|
||||
}
|
||||
public function testGetQuarterFourth()
|
||||
{
|
||||
$d = Carbon::createFromDate(2012, 10, 1);
|
||||
$this->assertSame(4, $d->quarter);
|
||||
}
|
||||
public function testGetQuarterFirstLast()
|
||||
{
|
||||
$d = Carbon::createFromDate(2012, 12, 31);
|
||||
$this->assertSame(4, $d->quarter);
|
||||
}
|
||||
|
||||
public function testGetDstFalse()
|
||||
{
|
||||
$this->assertFalse(Carbon::createFromDate(2012, 1, 1, 'America/Toronto')->dst);
|
||||
}
|
||||
public function testGetDstTrue()
|
||||
{
|
||||
$this->assertTrue(Carbon::createFromDate(2012, 7, 1, 'America/Toronto')->dst);
|
||||
}
|
||||
|
||||
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 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());
|
||||
}
|
||||
public function testGetTz()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1, 'America/Toronto');
|
||||
$this->assertSame('America/Toronto', $dt->tz->getName());
|
||||
}
|
||||
public function testGetTimezoneName()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1, 'America/Toronto');
|
||||
$this->assertSame('America/Toronto', $dt->timezoneName);
|
||||
}
|
||||
public function testGetTzName()
|
||||
{
|
||||
$dt = Carbon::createFromDate(2000, 1, 1, 'America/Toronto');
|
||||
$this->assertSame('America/Toronto', $dt->tzName);
|
||||
}
|
||||
|
||||
public function testInvalidGetter()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$d = Carbon::now();
|
||||
$bb = $d->doesNotExit;
|
||||
}
|
||||
}
|
27
vendor/nesbot/carbon/tests/InstanceTest.php
vendored
Normal file
27
vendor/nesbot/carbon/tests/InstanceTest.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class InstanceTest extends TestFixture
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
97
vendor/nesbot/carbon/tests/IsTest.php
vendored
Normal file
97
vendor/nesbot/carbon/tests/IsTest.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class IsTest extends TestFixture
|
||||
{
|
||||
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 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 testIsPast()
|
||||
{
|
||||
$this->assertFalse(Carbon::now()->addSecond()->isPast());
|
||||
}
|
||||
}
|
27
vendor/nesbot/carbon/tests/IssetTest.php
vendored
Normal file
27
vendor/nesbot/carbon/tests/IssetTest.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class IssetTest extends TestFixture
|
||||
{
|
||||
public function testIssetReturnFalseForUnknownProperty()
|
||||
{
|
||||
$this->assertFalse(isset(Carbon::create(1234, 5, 6, 7, 8, 9)->sdfsdfss));
|
||||
}
|
||||
public function testIssetReturnTrueForProperties()
|
||||
{
|
||||
$properties = array('year', 'month', 'day', 'hour', 'minute', 'second', 'dayOfWeek', 'dayOfYear', 'daysInMonth', 'timestamp', 'age', 'quarter', 'dst', 'offset', 'offsetHours', 'timezone', 'timezoneName', 'tz', 'tzName');
|
||||
foreach ($properties as $property) {
|
||||
$this->assertTrue(isset(Carbon::create(1234, 5, 6, 7, 8, 9)->$property));
|
||||
}
|
||||
}
|
||||
}
|
65
vendor/nesbot/carbon/tests/NowAndOtherStaticHelpersTest.php
vendored
Normal file
65
vendor/nesbot/carbon/tests/NowAndOtherStaticHelpersTest.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class NowAndOtherStaticHelpersTest extends TestFixture
|
||||
{
|
||||
public function testNow()
|
||||
{
|
||||
$dt = Carbon::now();
|
||||
$this->assertSame(time(), $dt->timestamp);
|
||||
}
|
||||
public function testNowWithTimezone()
|
||||
{
|
||||
$dt = Carbon::now('Europe/London');
|
||||
$this->assertSame(time(), $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());
|
||||
}
|
||||
}
|
187
vendor/nesbot/carbon/tests/SettersTest.php
vendored
Normal file
187
vendor/nesbot/carbon/tests/SettersTest.php
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class SettersTest extends TestFixture
|
||||
{
|
||||
public function testYearSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->year = 1995;
|
||||
$this->assertSame(1995, $d->year);
|
||||
}
|
||||
|
||||
public function testMonthSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->month = 3;
|
||||
$this->assertSame(3, $d->month);
|
||||
}
|
||||
public function testMonthSetterWithWrap()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->month = 13;
|
||||
$this->assertSame(1, $d->month);
|
||||
}
|
||||
|
||||
public function testDaySetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->day = 2;
|
||||
$this->assertSame(2, $d->day);
|
||||
}
|
||||
public function testDaySetterWithWrap()
|
||||
{
|
||||
$d = Carbon::createFromDate(2012, 8, 5);
|
||||
$d->day = 32;
|
||||
$this->assertSame(1, $d->day);
|
||||
}
|
||||
|
||||
public function testHourSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->hour = 2;
|
||||
$this->assertSame(2, $d->hour);
|
||||
}
|
||||
public function testHourSetterWithWrap()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->hour = 25;
|
||||
$this->assertSame(1, $d->hour);
|
||||
}
|
||||
|
||||
public function testMinuteSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->minute = 2;
|
||||
$this->assertSame(2, $d->minute);
|
||||
}
|
||||
public function testMinuteSetterWithWrap()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->minute = 65;
|
||||
$this->assertSame(5, $d->minute);
|
||||
}
|
||||
|
||||
public function testSecondSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->second = 2;
|
||||
$this->assertSame(2, $d->second);
|
||||
}
|
||||
public function testSecondSetterWithWrap()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->second = 65;
|
||||
$this->assertSame(5, $d->second);
|
||||
}
|
||||
|
||||
public function testTimestampSetter()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->timestamp = 10;
|
||||
$this->assertSame(10, $d->timestamp);
|
||||
|
||||
$d->setTimestamp(11);
|
||||
$this->assertSame(11, $d->timestamp);
|
||||
}
|
||||
|
||||
public function testSetTimezoneWithInvalidTimezone()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$d = Carbon::now();
|
||||
$d->setTimezone('sdf');
|
||||
}
|
||||
public function testTimezoneWithInvalidTimezone()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
|
||||
try {
|
||||
$d->timezone = 'sdf';
|
||||
$this->fail('InvalidArgumentException was not been raised.');
|
||||
} catch (InvalidArgumentException $expected) {}
|
||||
|
||||
try {
|
||||
$d->timezone('sdf');
|
||||
$this->fail('InvalidArgumentException was not been raised.');
|
||||
} catch (InvalidArgumentException $expected) {}
|
||||
}
|
||||
public function testTzWithInvalidTimezone()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
|
||||
try {
|
||||
$d->tz = 'sdf';
|
||||
$this->fail('InvalidArgumentException was not been raised.');
|
||||
} catch (InvalidArgumentException $expected) {}
|
||||
|
||||
try {
|
||||
$d->tz('sdf');
|
||||
$this->fail('InvalidArgumentException was not been raised.');
|
||||
} catch (InvalidArgumentException $expected) {}
|
||||
}
|
||||
public function testSetTimezoneUsingString()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->setTimezone('America/Toronto');
|
||||
$this->assertSame('America/Toronto', $d->tzName);
|
||||
}
|
||||
public function testTimezoneUsingString()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->timezone = 'America/Toronto';
|
||||
$this->assertSame('America/Toronto', $d->tzName);
|
||||
|
||||
$d->timezone('America/Vancouver');
|
||||
$this->assertSame('America/Vancouver', $d->tzName);
|
||||
}
|
||||
public function testTzUsingString()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->tz = 'America/Toronto';
|
||||
$this->assertSame('America/Toronto', $d->tzName);
|
||||
|
||||
$d->tz('America/Vancouver');
|
||||
$this->assertSame('America/Vancouver', $d->tzName);
|
||||
}
|
||||
public function testSetTimezoneUsingDateTimeZone()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->setTimezone(new \DateTimeZone('America/Toronto'));
|
||||
$this->assertSame('America/Toronto', $d->tzName);
|
||||
}
|
||||
public function testTimezoneUsingDateTimeZone()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->timezone = new \DateTimeZone('America/Toronto');
|
||||
$this->assertSame('America/Toronto', $d->tzName);
|
||||
|
||||
$d->timezone(new \DateTimeZone('America/Vancouver'));
|
||||
$this->assertSame('America/Vancouver', $d->tzName);
|
||||
}
|
||||
public function testTzUsingDateTimeZone()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$d->tz = new \DateTimeZone('America/Toronto');
|
||||
$this->assertSame('America/Toronto', $d->tzName);
|
||||
|
||||
$d->tz(new \DateTimeZone('America/Vancouver'));
|
||||
$this->assertSame('America/Vancouver', $d->tzName);
|
||||
}
|
||||
|
||||
public function testInvalidSetter()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$d = Carbon::now();
|
||||
$d->doesNotExit = 'bb';
|
||||
}
|
||||
}
|
60
vendor/nesbot/carbon/tests/StartEndOfTest.php
vendored
Normal file
60
vendor/nesbot/carbon/tests/StartEndOfTest.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class StartEndOfTest extends TestFixture
|
||||
{
|
||||
public function testStartOfDay()
|
||||
{
|
||||
$dt = Carbon::now();
|
||||
$this->assertTrue($dt->startOfDay() instanceof Carbon);
|
||||
$this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, 0, 0, 0);
|
||||
}
|
||||
public function testEndOfDay()
|
||||
{
|
||||
$dt = Carbon::now();
|
||||
$this->assertTrue($dt->endOfDay() instanceof Carbon);
|
||||
$this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, 23, 59, 59);
|
||||
}
|
||||
|
||||
public function testStartOfMonthIsFluid()
|
||||
{
|
||||
$dt = Carbon::now();
|
||||
$this->assertTrue($dt->startOfMonth() instanceof Carbon);
|
||||
}
|
||||
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 testEndOfMonthIsFluid()
|
||||
{
|
||||
$dt = Carbon::now();
|
||||
$this->assertTrue($dt->endOfMonth() instanceof Carbon);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
124
vendor/nesbot/carbon/tests/StringsTest.php
vendored
Normal file
124
vendor/nesbot/carbon/tests/StringsTest.php
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class StringsTest extends TestFixture
|
||||
{
|
||||
public function testToString()
|
||||
{
|
||||
$d = Carbon::now();
|
||||
$this->assertSame(Carbon::now()->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 testToLocalizedFormattedDateString()
|
||||
{
|
||||
/****************
|
||||
|
||||
Working out a Travis issue on how to set a different locale
|
||||
other than EN to test this.
|
||||
|
||||
|
||||
$cache = setlocale(LC_TIME, 0);
|
||||
setlocale(LC_TIME, 'German');
|
||||
$d = Carbon::create(1975, 12, 25, 14, 15, 16);
|
||||
$this->assertSame('Donnerstag 25 Dezember 1975', $d->formatLocalized('%A %d %B %Y'));
|
||||
setlocale(LC_TIME, $cache);
|
||||
|
||||
*****************/
|
||||
}
|
||||
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('Thursday, 25-Dec-75 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-0500', $d->toISO8601String());
|
||||
}
|
||||
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());
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
159
vendor/nesbot/carbon/tests/SubTest.php
vendored
Normal file
159
vendor/nesbot/carbon/tests/SubTest.php
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class SubTest extends TestFixture
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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 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);
|
||||
}
|
||||
}
|
51
vendor/nesbot/carbon/tests/TestFixture.php
vendored
Normal file
51
vendor/nesbot/carbon/tests/TestFixture.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class TestFixture extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $saveTz;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
//save current timezone
|
||||
$this->saveTz = date_default_timezone_get();
|
||||
|
||||
date_default_timezone_set('America/Toronto');
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
date_default_timezone_set($this->saveTz);
|
||||
}
|
||||
|
||||
protected function assertCarbon(Carbon $d, $year, $month, $day, $hour = null, $minute = null, $second = null)
|
||||
{
|
||||
$this->assertSame($year, $d->year, 'Carbon->year');
|
||||
$this->assertSame($month, $d->month, 'Carbon->month');
|
||||
$this->assertSame($day, $d->day, 'Carbon->day');
|
||||
|
||||
if ($hour !== null) {
|
||||
$this->assertSame($hour, $d->hour, 'Carbon->hour');
|
||||
}
|
||||
|
||||
if ($minute !== null) {
|
||||
$this->assertSame($minute, $d->minute, 'Carbon->minute');
|
||||
}
|
||||
|
||||
if ($second !== null) {
|
||||
$this->assertSame($second, $d->second, 'Carbon->second');
|
||||
}
|
||||
}
|
||||
}
|
61
vendor/nesbot/carbon/tests/TestingAidsTest.php
vendored
Normal file
61
vendor/nesbot/carbon/tests/TestingAidsTest.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Carbon package.
|
||||
*
|
||||
* (c) Brian Nesbitt <brian@nesbot.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class TestingAidsTest extends TestFixture
|
||||
{
|
||||
public function testTestingAidsWithTestNowNotSet()
|
||||
{
|
||||
Carbon::setTestNow();
|
||||
|
||||
$this->assertFalse(Carbon::hasTestNow());
|
||||
$this->assertNull(Carbon::getTestNow());
|
||||
}
|
||||
public function testTestingAidsWithTestNowSet()
|
||||
{
|
||||
$notNow = Carbon::yesterday();
|
||||
Carbon::setTestNow($notNow);
|
||||
|
||||
$this->assertTrue(Carbon::hasTestNow());
|
||||
$this->assertSame($notNow, Carbon::getTestNow());
|
||||
}
|
||||
|
||||
public function testConstructorWithTestValueSet()
|
||||
{
|
||||
$notNow = Carbon::yesterday();
|
||||
Carbon::setTestNow($notNow);
|
||||
|
||||
$this->assertEquals($notNow, new Carbon());
|
||||
$this->assertEquals($notNow, new Carbon(null));
|
||||
$this->assertEquals($notNow, new Carbon(''));
|
||||
$this->assertEquals($notNow, new Carbon('now'));
|
||||
}
|
||||
|
||||
public function testNowWithTestValueSet()
|
||||
{
|
||||
$notNow = Carbon::yesterday();
|
||||
Carbon::setTestNow($notNow);
|
||||
|
||||
$this->assertEquals($notNow, Carbon::now());
|
||||
}
|
||||
|
||||
public function testParseWithTestValueSet()
|
||||
{
|
||||
$notNow = Carbon::yesterday();
|
||||
Carbon::setTestNow($notNow);
|
||||
|
||||
$this->assertEquals($notNow, Carbon::parse());
|
||||
$this->assertEquals($notNow, Carbon::parse(null));
|
||||
$this->assertEquals($notNow, Carbon::parse(''));
|
||||
$this->assertEquals($notNow, Carbon::parse('now'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user