Download the PHP package d34dman/consecutive-date without Composer
On this page you can find all versions of the php package d34dman/consecutive-date. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download d34dman/consecutive-date
More information about d34dman/consecutive-date
Files in d34dman/consecutive-date
Package consecutive-date
Short Description A utility to find consecutive dates
License MIT
Informations about the package consecutive-date
Consecutive Date
A PHP library for finding and counting consecutive dates in a sequence. This library provides a simple and efficient way to determine consecutive date patterns, useful for tracking streaks, daily logins, or any sequential date-based calculations.
Features
- Count consecutive dates backwards from a given date
- Count consecutive dates forwards from a given date
- Support for custom date formats
- Works with both DateTime objects and date strings
- Zero dependencies
- Type-safe implementation
- PSR-4 compliant
Installation
You can install the package via composer:
Usage
Basic Usage with DateTime Objects
Using String Dates
Custom Date Formats
API Reference
ConsecutiveDate Class
countPastDays(DateTimeInterface $date, array $list, string $date_format): int
Counts consecutive days backwards from the given date.
$date: The reference date to start counting from$list: Array of DateTime objects$date_format: Format string for date comparison (e.g., "Y-m-d")
countFutureDays(DateTimeInterface $date, array $list, string $date_format): int
Counts consecutive days forwards from the given date.
- Parameters are same as
countPastDays()
ConsecutiveDateStrings Class
Has the same methods as ConsecutiveDate but works with string dates instead of DateTime objects.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
- Shibin Das - d34dman
- Email: [email protected]
Support
If you encounter any problems or have suggestions, please open an issue on GitHub.