General Date Format Package
A Flutter package for flexible and generalized date formatting, extending the capabilities of the
general_datetime
package. It provides an intuitive and powerful way to format dates across various
calendar systems (like Jalali and Gregorian) and locales.
Features
- Locale-aware formatting (e.g., Persian, English, Arabic).
- Support for multiple calendar systems (e.g., Jalali, Gregorian, etc.).
- Simple, consistent syntax similar to intl.DateFormat.
- Supports standard formatting symbols (yyyy, MM, dd, HH, etc.).
- Extendable and suitable for both DateTime and custom date models like JalaliDateTime.
Installation
To use this plugin, you can add it to your Flutter project in one of two ways:
1. Add to pubspec.yaml
Include the following dependency in your pubspec.yaml
file:
dependencies:
general_date_format: <latest_version>
2. Add directly from the terminal
Run the following command to add the plugin directly to your project:
flutter pub add general_date_format
Usage
Here's an example of how to use the package to format a date:
import 'package:general_date_format/general_date_format.dart';
void main() {
final jalali = JalaliDateTime.now();
final formatted = GeneralDateFormat.format(jalali, 'yyyy/MM/dd');
print(formatted); // Example: 1402/02/11
}
Formatting Options
You can use various formatting patterns, such as:
'yyyy-MM-dd'
for a full date.'HH:mm:ss'
for time.- And other custom patterns based on your needs.
Check the documentation for more advanced usage and available formats.
Documentation
Full documentation can be found at
Related Packages
general_datetime
: Generalized abstraction over different calendar systems.intl
: Provides internationalization and localization support.
Issues
Feel free to open issues and submit pull requests. For any issues or feature requests, please check the issues page.
License
This project is licensed under the BSD 3-Clause License. See the LICENSE file for more details.
Libraries
- general_date_format
- This file is startup of general_date_format library you can use the package consider the example