- How do I install borsaco/jalali-date-time in a Laravel project?
- Run `composer require borsaco/jalali-date-time` to install via Composer. The package includes a single file (`jdatetime.class.php`) that you can require manually in your code. No Laravel-specific setup is needed, but you’ll need to handle integration with Carbon or Blade yourself.
- Does this package work with Laravel’s Carbon for date handling?
- No, this package doesn’t natively support Carbon. You’ll need to create a wrapper class or use Carbon macros to bridge Jalali ↔ Gregorian conversions. For example, you could extend Carbon with custom methods to convert to/from Jalali dates using the `JalaliDateTime` class.
- Can I use this package to store Jalali dates in an Eloquent model?
- Yes, but you’ll need to implement custom accessors/mutators or database casting. For instance, you could add a `getJalaliDateAttribute()` method to your model to convert stored Gregorian dates to Jalali format on retrieval, and vice versa for storage.
- What Laravel versions does borsaco/jalali-date-time support?
- The package itself doesn’t enforce Laravel version constraints, but it may not work seamlessly with newer Laravel features (e.g., PHP 8.x syntax like named arguments). Test thoroughly, especially if using PHP 8+, as the package lacks explicit PHP 8.x support.
- Does this package handle timezones or date arithmetic (e.g., adding days to Jalali dates)?
- No, this package only converts between Gregorian and Jalali dates and doesn’t support timezone handling or Jalali-specific date arithmetic. For advanced use cases, you’d need to implement additional logic or consider alternatives like custom Carbon extensions.
- Is borsaco/jalali-date-time actively maintained? What are the risks?
- The package hasn’t been updated since 2019 and has no active maintenance. Risks include potential bugs in edge cases (e.g., leap years, dates beyond 2038) and compatibility issues with newer PHP/Laravel versions. Consider forking or maintaining it long-term if critical.
- Can I use this package for frontend date formatting in Blade templates?
- Yes, but you’ll need to create custom Blade helpers or directives. For example, you could register a Blade directive to format dates using the `JalaliDateTime` class, or pass Jalali-formatted data from your controller to the view.
- Are there alternatives to borsaco/jalali-date-time for Laravel?
- Yes, alternatives include custom Carbon extensions (e.g., wrapping the package in a Carbon-compatible class) or frontend-only solutions like `moment-jalaali` for JavaScript. For a more maintained option, check PHP libraries like `mheydari/jalali` or consider building a Laravel-specific bridge.
- How do I test edge cases like leap years or dates beyond 2038?
- Since the package lacks active maintenance, manually test edge cases by converting known Jalali dates (e.g., Persian New Year, leap years like 1396/04/30) and verifying Gregorian outputs. Also test dates far beyond 2038 to ensure the package’s extended support holds.
- Will this package work in production for high-traffic Laravel apps?
- While the package is lightweight, its lack of maintenance and minimal adoption (0 stars/dependents) introduce risk for production use. Thoroughly test performance, edge cases, and compatibility with your Laravel version before deploying, and have a fallback plan (e.g., a maintained alternative).