Download the PHP package alitnk/radon without Composer
On this page you can find all versions of the php package alitnk/radon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package radon
Short Description :package_description
License MIT
Homepage https://github.com/wamadev/radon
Informations about the package radon
Radon
A library like Carbon but for Iranian (Jalali) calendar
Installation
Via Composer
Usage
Create new instance
Just like when you would do now()
and get a Carbon instance, you can do jnow()
and get a Radon instance for the current time.
To make a new instance based on the given datetime, you can use radon($datetimeString)
like:
$r = radon('1401-12-28 06:15')
and get a new instance for that datetime
Conversions
To convert Carbon instances to Radon instances, do:
To do the vice versa (Radon to Carbon), do:
Methods
You can use most of the carbon's methods on a Radon instance. e.g. $radonInstance->diffForHumans()
, $radonInstance->addDay(10)
, $radonInstance->setDay(1)
Eloquent / Querying
Radon introduces new querying features for Jalali dates. Available methods are:
whereBetweenJalali
Note that this method is also available on Collection
objects.
Example:
orWhereBetweenJalali
This method is like orWhereBetween
but for Jalali dates.
whereDateJalali
whereDayJalali
Compares the day
whereMonthJalali
Compares the month
whereYearJalali
Compares the year
Casts
You can use the Radon cast to make the conversion process easier. To use the cast, add the cast to your field in the respective model:
and get a Radon instance every time you get the field.
$product->sales_ends_at // returns a Radon instance
you can also update the model without having to worry about the datetime conversions:
or
Expansion
Radon tries to support most of the Carbon methods, but keep in mind that some of the Carbon methods are not supported yet and might be added in the next versions. This package uses Verta under the hood and therefore, expanding some functionalities might demand on the expansion of Verta.
Change log
Please see the changelog for more information on what has changed recently.
Testing
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
Credits
- Alireza Zamani
- All Contributors
License
license. Please see the license file for more information.