chinleung/php-weekday

Easily get name of weekday and value from name between different languages.

v2.0.0 2020-04-27 18:22 UTC

This package is auto-updated.

Last update: 2024-10-28 04:59:19 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

Easily get name of weekday and value from name between different languages.

Installation

You can install the package via composer:

composer require chinleung/php-weekday

Usage

Retrieve a name from a value

Weekday::getNameFromValue(0, 'en'); // Sunday
(new Weekday(0, 'en'))->getName(); // Sunday

Retrieving a name from a value for a different locale

Weekday::getNameFromValue(0, 'fr'); // Dimanche
(new Weekday(0, 'en'))->getName('fr'); // Dimanche

Retrieving a value from the name

Weekday::getValueFromName('Sunday', 'en'); // 0
Weekday::getValueFromName('Lundi', 'fr'); // 1
(new Weekday('wednesday', 'en'))->getName(); // 3

Retrieving all names for a locale

Weekday::getNames('en'); // ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']

Changing the locale of an instance

(new Weekday(1, 'en'))->setLocale('fr')->getName(); // Lundi

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email hello@chinleung.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

PHP Package Boilerplate

This package was generated using the PHP Package Boilerplate.