Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Jalali Date Time Laravel Package

borsaco/jalali-date-time

Convert dates between Gregorian and Jalali (Shamsi/Hijri Shamsi) calendars in PHP. Simple standalone class or Composer package, with support for dates beyond the 2038 limit.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Niche Use Case: The package is highly specialized for Jalali (Shamsi) date-time conversions, which is critical for applications targeting Persian-speaking markets (e.g., Iran, Afghanistan). If your Laravel app requires localized date handling for these regions, this package provides a lightweight, self-contained solution.
  • Isolation: Since it’s a standalone class (jdatetime.class.php), it can be integrated without tight coupling to Laravel’s core. However, it lacks Laravel-specific integrations (e.g., Carbon compatibility, Eloquent casting, or Blade directives).
  • Alternative Comparison:
    • Pros: No external dependencies, supports dates beyond 2038 (unlike PHP’s native DateTime).
    • Cons: No active maintenance, minimal adoption (0 stars/dependents), and no Laravel ecosystem integrations (e.g., no Carbon bridge).

Integration Feasibility

  • Low Barrier to Entry: The package is simple to include via Composer or manual copy-paste. No complex setup required.
  • Manual Effort Needed:
    • Carbon Integration: If your app uses Carbon, you’ll need to wrap this package to bridge Jalali ↔ Gregorian conversions (e.g., custom Carbon macros or accessors).
    • Database/ORM: For Eloquent models, you’d need to implement custom accessors/mutators or database casting to handle Jalali dates.
    • Blade/Views: Custom helpers or directives would be required for frontend date formatting.
  • Testing Overhead: Since the package is unmaintained, you’ll need to verify edge cases (e.g., leap years, negative dates, timezones) manually.

Technical Risk

  • Maintenance Risk: Last release in 2019 with no updates since. Risk of bugs in edge cases (e.g., dates near 2038+).
  • Compatibility Risk:
    • PHP Version: No explicit PHP 8.x support (could have issues with named arguments, type hints, etc.).
    • Laravel Ecosystem: No native support for Laravel’s date utilities (e.g., Carbon, CarbonInterval).
  • Functional Gaps:
    • No timezone handling (Jalali dates are timezone-agnostic; Gregorian ↔ Jalali conversions may behave unexpectedly).
    • No date math (e.g., adding/subtracting Jalali dates directly).
    • No ICU/Intl compatibility (if your app uses IntlDateFormatter).

Key Questions

  1. Is Jalali date support a core requirement? If not, consider alternatives like:
  2. Can you tolerate manual integration? If the package lacks Laravel integrations, will you build them in-house?
  3. What’s the risk of unmaintained code? Are you comfortable forking/maintaining this package long-term?
  4. Do you need advanced features? If your app requires date arithmetic, timezones, or ICU support, this package may not suffice.
  5. Is there a fallback plan? If this package fails, how will you handle Jalali dates (e.g., switch to a maintained alternative)?

Integration Approach

Stack Fit

  • Best For:
    • Laravel apps with Persian/Iranian localization needs.
    • Projects where Jalali dates are a niche requirement (not a core feature).
    • Legacy systems where a lightweight, no-dependency solution is preferred.
  • Poor Fit:
    • High-traffic apps (risk of unmaintained code).
    • Projects using Carbon heavily (requires custom bridging).
    • Apps needing timezone-aware Jalali dates.

Migration Path

  1. Proof of Concept (PoC):
    • Install via Composer: composer require borsaco/jalali-date-time.
    • Test basic conversions in a sandbox environment:
      require_once 'vendor/borsaco/jalali-date-time/jdatetime.class.php';
      $jalali = new JalaliDateTime('1399/10/10'); // Jalali input
      echo $jalali->toGregorian(); // Convert to Gregorian
      
  2. Laravel Integration:
    • Option 1: Manual Wrapping (for Carbon compatibility):
      // app/Helpers/JalaliHelper.php
      use Carbon\Carbon;
      use JalaliDateTime;
      
      class JalaliHelper {
          public static function toJalali(Carbon $carbon): string {
              $gregorian = $carbon->format('Y/m/d');
              $jalali = new JalaliDateTime($gregorian);
              return $jalali->toString();
          }
      }
      
    • Option 2: Eloquent Casting (for database storage):
      use Illuminate\Database\Eloquent\Casts\Attribute;
      
      class JalaliDateCast implements Attribute {
          public function get($model, string $key, $value, array $attributes) {
              return JalaliHelper::toJalali($value);
          }
      }
      
  3. Frontend Integration:
    • Use JavaScript libraries (e.g., moment-jalaali) for client-side rendering.
    • Or create a Blade directive:
      Blade::directive('jalali', function ($date) {
          return "<?php echo app\\Helpers\\JalaliHelper::toJalali(new Carbon({$date})); ?>";
      });
      

Compatibility

Laravel Component Compatibility Workaround Needed?
Carbon ❌ No Yes (custom helper)
Eloquent ❌ No Yes (custom cast)
Blade ❌ No Yes (directive/helper)
Validation ❌ No Yes (custom rule)
Database (MySQL) ⚠️ Partial Store as Gregorian, convert in app
Timezones ❌ No Manual handling required

Sequencing

  1. Phase 1: Core Conversion Logic
    • Implement basic Gregorian ↔ Jalali conversions in a helper class.
    • Test edge cases (leap years, negative dates, max dates).
  2. Phase 2: Laravel Integration
    • Add Carbon bridging.
    • Implement Eloquent casting for models.
  3. Phase 3: Frontend & Validation
    • Add Blade directives.
    • Create validation rules for Jalali dates.
  4. Phase 4: Database Schema (if needed)
    • Decide whether to store dates in Gregorian (recommended) or Jalali format.
    • Add computed columns or application-layer conversions.

Operational Impact

Maintenance

  • Short-Term:
    • Low effort: Simple to integrate for basic use cases.
    • High effort: Custom Laravel integrations (Carbon, Eloquent, Blade) require ongoing upkeep.
  • Long-Term:
    • Risk of bitrot: No updates since 2019; may break with PHP 8.x+.
    • Forking required: If bugs are found, you’ll need to maintain your own fork.
  • Dependencies:
    • None (self-contained class), but Laravel integrations add complexity.

Support

  • Community Support: ❌ None (0 stars, no issues, no maintainer activity).
  • Debugging:
    • Edge cases (e.g., dates near 2038+) may require manual fixes.
    • No Laravel-specific docs → Trial-and-error for integrations.
  • Alternatives:
    • If issues arise, consider:
      • Forking the repo and submitting fixes upstream (unlikely to be merged).
      • Switching to a maintained alternative (e.g., mheydari/jalali if available).

Scaling

  • Performance:
    • Lightweight: Minimal overhead for conversions.
    • No caching needed unless processing high-volume date conversions (e.g., batch jobs).
  • Database Impact:
    • Recommended: Store dates in Gregorian format in the database, convert in the app layer.
    • Avoid: Storing Jalali dates directly (risk of timezone/leap year issues).
  • Concurrency:
    • Stateless: No shared state; safe for multi-threaded environments.

Failure Modes

Failure Scenario Impact Mitigation
Incorrect date conversions Wrong dates
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle