2017 © Pedro Peláez
 

library carbonate

Carbonate, more muscle to Carbon datetime wrapper

image

omitobisam/carbonate

Carbonate, more muscle to Carbon datetime wrapper

  • Saturday, June 2, 2018
  • by omitobisam
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Build Status Latest Stable Version Total Downloads Latest Unstable Version Monthly Downloads, (*1)

Carbonate - a muscle to PHP Carbon with Collections

- dev-master or bleeding edge

Installation

  • composer require omitobisam/carbonate

If the above does not work then simply include the latest release version as in:, (*2)

  • composer require omitobisam/carbonate ^0.2.1

For the dev-master simply change the version to dev-master, (*3)

Another option is to clone the dev-master branch and you can have the bleeding version, (*4)

Requirements

Minimum: PHP 5.6.4, (*5)

Usage:

```$php $mydate = new Carbonate('2017-09-01'); $enddate = new Carbonate('2017-10-30);, (*6)


#### Get WeekendDates within two dates ```php $result = $mydate->everyWeekendDays($enddate); // /* * Result - A collection of dates in the weekend */ // Illuminate\Support\Collection Object ( [items:protected] => Array ( [0] => Carbonate\Carbonate Object ( [date] => 2017-09-02 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) [1] => Carbonate\Carbonate Object ( [date] => 2017-09-03 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) [2] => Carbonate\Carbonate Object ( [date] => 2017-09-09 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) .......

Collections method can be further used on the result e.g

// Verify if the last Carbon instance is actually weekend

$mydate->everyWeekendDays($enddate)->last()->isWeekend();

The result of the operations is shown as transformed from Carbon/Carbonate object to string using stringify()

Carbonate::stringify($mydate->everyWeekendDays($enddate));

//
/*
* Result - A collection of dates in the weekends as string
*/
//

Illuminate\Support\Collection Object ( [items:protected] => Array ( 
[0] => 2017-09-02 00:00:00 
[1] => 2017-09-03 00:00:00 
[2] => 2017-09-09 00:00:00 
[3] => 2017-09-10 00:00:00 
[4] => 2017-09-16 00:00:00 
[5] => 2017-09-17 00:00:00 
[6] => 2017-09-23 00:00:00 
[7] => 2017-09-24 00:00:00 
[8] => 2017-09-30 00:00:00 
[9] => 2017-10-01 00:00:00 
[10] => 2017-10-07 00:00:00 
[11] => 2017-10-08 00:00:00 
[12] => 2017-10-14 00:00:00 
[13] => 2017-10-15 00:00:00 
[14] => 2017-10-21 00:00:00 
[15] => 2017-10-22 00:00:00 
[16] => 2017-10-28 00:00:00 
[17] => 2017-10-29 00:00:00 ) )

A string of dates can be converted whole into Carbonate/Carbon instances:

Carbonate::carbonate(['today', 'tomorrow', '2017-10-30']);


Illuminate\Support\Collection Object ( [items:protected] => Array ( 
[0] => Carbonate\Carbonate Object ( [date] => 2017-10-21 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Berlin ) 
[1] => Carbonate\Carbonate Object ( [date] => 2017-10-22 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Berlin ) 
[2] => Carbonate\Carbonate Object ( [date] => 2017-10-30 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Berlin ) ) )

Other methods


$mydate->thisMonth(); $mydate->getDatesOfDaysInMonth(['Monday', 'Saturday']); $mydate->everyWeekDays(); $mydate->everyDay('Monday'); $mydate->random(2); $mydate->randomOne(); $mydate->anyMonday(); $mydate->anyTuesday(); $mydate->anyWednesday(); $mydate->anyThursday(); $mydate->anyFriday(); $mydate->anySaturday(); $mydate->anySunday(); $mydate->any(); $mydate->anyOne('Monday'); $mydate->stringify([Carbonate::now(), Carbonate::now()->addDay(1)]); $mydate->carbonate(['today', 'tomorrow']); $mydate->weekends(Carbonate::now()->addDay(7));

Info

Contributions

The Versions

02/06 2018

dev-dev-master

dev-dev-master

Carbonate, more muscle to Carbon datetime wrapper

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oluwatobi Samuel Omisakin

carbonate

02/06 2018

dev-master

9999999-dev

Carbonate, more muscle to Carbon datetime wrapper

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oluwatobi Samuel Omisakin

carbonate

02/06 2018

1.0.0

1.0.0.0

Carbonate, more muscle to Carbon datetime wrapper

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oluwatobi Samuel Omisakin

carbonate

10/07 2017

0.0.2

0.0.2.0

Carbonate, more muscle to Carbon datetime wrapper

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oluwatobi Samuel Omisakin

carbonate

10/07 2017

0.2.0

0.2.0.0

Carbonate, more muscle to Carbon datetime wrapper

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oluwatobi Samuel Omisakin

carbonate

10/07 2017

0.2.1

0.2.1.0

Carbonate, more muscle to Carbon datetime wrapper

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oluwatobi Samuel Omisakin

carbonate

10/07 2017

0.1.0

0.1.0.0

Carbonate, more muscle to Carbon datetime wrapper

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oluwatobi Samuel Omisakin

carbonate

09/07 2017

0.0.1

0.0.1.0

Carbonate, more muscle to Carbon datetime wrapper

  Sources   Download

MIT

The Requires

 

The Development Requires

by Oluwatobi Samuel Omisakin

carbonate