|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +StellarWP Dates is a PHP library for WordPress that provides comprehensive date and time utilities. It's forked from The Events Calendar's battle-tested date handling functionality and serves as a community resource from StellarWP. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +### Development Commands |
| 12 | +```bash |
| 13 | +# Generate documentation from PHPDoc comments |
| 14 | +composer create-docs |
| 15 | + |
| 16 | +# Run static code analysis |
| 17 | +composer test:analysis |
| 18 | + |
| 19 | +# Install dependencies |
| 20 | +composer install |
| 21 | +``` |
| 22 | + |
| 23 | +### Testing |
| 24 | +The project uses Codeception for testing. Tests are located in `tests/wpunit/` and require WordPress test environment setup. Test configuration is in `codeception.dist.yml` and `codeception.slic.yml`. |
| 25 | + |
| 26 | +## Architecture |
| 27 | + |
| 28 | +### Core Classes |
| 29 | +- **`Dates`** (src/Dates/Dates.php): Main utility class with 70+ static methods for date operations |
| 30 | +- **`Date_I18n`** (src/Dates/Date_I18n.php): Mutable DateTime extension with WordPress I18n support |
| 31 | +- **`Date_I18n_Immutable`** (src/Dates/Date_I18n_Immutable.php): Immutable version of Date_I18n |
| 32 | +- **`Timezones`** (src/Dates/Timezones.php): Timezone utilities integrated with WordPress |
| 33 | + |
| 34 | +### Key Design Patterns |
| 35 | +1. **All dates are built through `Dates::get()`** - This is the primary entry point for date creation |
| 36 | +2. **Fallback handling** - Methods accept optional fallback values for invalid dates |
| 37 | +3. **WordPress integration** - Deep integration with WordPress timezone and locale systems |
| 38 | +4. **Immutability support** - Both mutable and immutable date objects available |
| 39 | + |
| 40 | +### Important Constants |
| 41 | +The library defines format constants in `Dates.php`: |
| 42 | +- `DBDATEFORMAT` = 'Y-m-d' |
| 43 | +- `DBDATETIMEFORMAT` = 'Y-m-d H:i:s' |
| 44 | +- `DATEONLYFORMAT` = 'F j, Y' |
| 45 | +- `TIMEFORMAT` = 'g:i a' |
| 46 | + |
| 47 | +### Code Quality |
| 48 | +- **PHPStan Level 3** with WordPress-specific rules |
| 49 | +- Configuration in `phpstan.neon.dist` |
| 50 | +- Ignores certain WordPress patterns (func_get_args usage) |
| 51 | + |
| 52 | +## Development Notes |
| 53 | + |
| 54 | +1. **Namespace**: All code under `StellarWP\Dates` namespace |
| 55 | +2. **Installation**: Recommend using Strauss for namespace isolation to avoid conflicts |
| 56 | +3. **Date Building**: Always use `Dates::get()` rather than direct instantiation |
| 57 | +4. **Timezone Handling**: Library automatically falls back to WordPress timezone or UTC |
| 58 | +5. **Testing**: Requires WordPress test environment setup for full test suite execution |
0 commit comments