Taarikh provides a field formatter and widget for Drupal's date module, allowing users to input and display dates in the Hijri calendar. It also offers developer tools for custom form elements and supports defining custom calendar types.
Taarikh is a field formatter and widget module to display and input Hijri dates for the fields defined by Drupal core's datetime
module.
This module also provides element types that you, as a developer, can use in your own forms.
When do I need this module?
You need this module for any of the following use cases:
- You need to allow users to enter dates in Hijri or another calendar.
- You need to display dates in Hijri or another calendar.
- You need to define your own calendar types.
Requirements
- Taarikh 2.x: Drupal
^11.2 || ^12 - Taarikh 1.x: Drupal
^10.3 || ^11(if your site is running Drupal 10, stay on the 1.x branch)
Installation
Install the module using Composer:
composer require drupal/taarikh:^2.0Composer will automatically download the required hussainweb/date-converter and hussainweb/taarikh-picker
packages. Because hussainweb/taarikh-picker is published as a drupal-library package on Packagist, it
automatically downloads into your site's libraries/ directory. No custom package repositories or legacy jQuery plugins are
required.
Upgrading from 1.x to 2.x
In Taarikh 1.x, the date picker widget depended on Keith Wood's third-party jQuery Calendars plugin (
kbwood/jquery.
calendars). Because that library was not published on Packagist, installation required adding a custom package
repository in the project's root composer.json and explicitly requiring the library.
In Taarikh 2.0, the widget uses Taarikh Picker, a modern, accessible,
zero-dependency JavaScript date picker. Because hussainweb/taarikh-picker is published on Packagist with the
drupal-
librarypackage type, it downloads automatically as a standard dependency without requiring manual repository configuration.
Upgrade Steps
-
Update Taarikh to 2.x:
composer require drupal/taarikh:^2.0 -
Remove the legacy jQuery Calendars dependency:
composer remove kbwood/jquery.calendars -
Clean up your root
composer.json:Remove the custom repository definition for
kbwood/jquery.calendarsfrom therepositoriesarray in
your rootcomposer.json:{ "type": "package", "package": { "name": "kbwood/jquery.calendars", "type": "drupal-library", "version": "2.1.0", "dist": { "url": "http://keith-wood.name/zip/jquery.calendars.package-2.1.0.zip", "type": "zip" } } } -
(Optional) Remove Drupal 12 jQuery compatibility shims:
If you had previously installed
drupal/jquery_downgradesolely to support jQuery Calendars on Drupal 12, you can
remove it:composer remove drupal/jquery_downgrade -
Rebuild cache:
drush cache:rebuild
Usage
This module does not provide a new field type, just widgets and formatters. This means that you are free to switch the widgets
and/or formatters for each field separately without losing any data. The data is stored in the database as a regular Gregorian date.
This also means that you typically would want to set both widget and formatters. If you just change the widget for a content type,
the user will be able to enter the date using the Hijri calendar, but it will be displayed using the Gregorian calendar when viewing the
content. To view it using the Hijri calendar, you also need to change the formatter.
Using the formatter
Go to the Manage display tab of any content type or entity type. For all date fields, you can now change the
formatter to Taarikh date and time. You can select the algorithm and the format from the settings.
Using the widget
Go to the Manage form display tab of any content type or entity type. For all date fields, you can now change the
widget to Taarikh date and time.
Local Development
We use DDEV to work on this module. Development setup is automated via the ./setup_dev.sh script, which sets up DDEV
with PHP 8.5, SQLite, and supports specifying the target Drupal version (11 or 12):
./setup_dev.sh 12This will set up a DDEV site at https://taarikh.ddev.site.
Ask your assistant about Taarikh
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- datetime Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.