Skip to content
/ days Public

A single helper class for converting a day of week name from full length, to abbreviations and vice versa.

License

Notifications You must be signed in to change notification settings

gtmassey/days

Repository files navigation

Days.php

Latest Version on Packagist Tests Total Downloads

Simple helper class for accessing the days of the week as strings in PHP.

Note from the developer:

This package is literally only one class. I will likely never update this package again. I just wanted to make a simple helper class for switching between days as names and as abbreviations in a separate project. If you have any suggestions for features or ideas, feel free to fork!

Thanks,

Garrett

Installation

You can install the package via composer:

composer require gtmassey/days

Usage

To use, you can either create a new days object with the new keyword, or you can use the make static method, or you can call the day of week directly as a static method:

use Gtmassey\Days\Days;

$monday = new Days('Monday');
$tuesday = Days::make('Tuesday');
$wednesday = Days::Wednesday();

Once you have a Days object, you can call the various methods to return the day of the week as a specific English formatted string:

$monday->asCharacterCode();      //'M'
$monday->asShortName();          //'Mon'
$sunday->asCharacterCode();      //'U'
$thursday->asFullName();         //'Thursday'

The character codes use R for Thursday to avoid confusion with Tuesday and U for Sunday to avoid confusion with Saturday.

Testing

To run the testsuite, run the following command:

composer test

License

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

About

A single helper class for converting a day of week name from full length, to abbreviations and vice versa.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages