搜索插件、代码仓与 APP 分类

插件详情v3.0.1

hijri

在伊斯兰历和公历之间进行日期转换,支持阿拉伯语和英语本地化。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
3.6万
喜欢数
145
Pub 分数
140

安装插件

flutter pub add hijri

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

hijri 包为 Flutter 应用程序提供了伊斯兰历(Hijri)和公历日期之间的无缝转换。它支持阿拉伯语和英语地区设置,非常适合面向穆斯林社区或需要宗教日期计算的应用程序。该包轻量级、易于集成,并可在所有主要平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)上运行。它能够准确处理日期格式化和解析,确保在斋月和开斋节等伊斯兰历法事件中获得可靠结果。

适合场景

  • 伊斯兰活动安排
  • 多语言日历显示
  • 宗教应用开发
  • 金融应用程序中的日期转换
  • 跨日历兼容性

主要特点

  • 伊斯兰历-公历日期转换
  • 阿拉伯语和英语区域设置支持
  • 平台无关的实现
  • 准确的伊斯兰历计算
  • 简单的 API 集成

适合对象

  • 为穆斯林用户提供的应用程序
  • 宗教或文化应用
  • 国际日期处理
  • 需要双日历的移动和网页应用
  • 支持多种语言的开发者

使用建议

  • 需要了解伊斯兰历法规则
  • 仅限日期级别精度
  • 无时区处理
  • 取决于准确的输入日期
  • 可能需要额外的格式化以用于UI显示

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Hijri

Hijri Calendar Converter

Usage
//Suppose current gregorian data/time is: Mon May 29 00:27:33  2018
  var _today = HijriCalendar.now();
  print(_today.hYear); // 1439
  print(_today.hMonth); // 9
  print(_today.hDay); // 14
  print(_today.getDayName()); // 14
  // Get month length in days
  print(_today.lengthOfMonth); // 30 days
  print(_today.toFormat("MMMM dd yyyy")); //Ramadan 14 1439
Change Local
  HijriCalendar.setLocal(locale);
Add New Locale
  HijriCalendar.addLocale(locale, {
    'long': ...,
    'short': ...,
    'days': ...,
    'short_days': ...
  });
  HijriCalendar.setLocal(locale);
From Gregorian to Ummalqura
var h_date = HijriCalendar.fromDate(DateTime(2018, 11, 12));
print(h_date.toString()); //04/03/1440H
print(h_date.getShortMonthName()); //Rab1
print(h_date.getLongMonthName()); //Rabi' al-awwal
print(h_date.lengthOfMonth); // 29 days
Check if date is valid
  //
  var _check_date = HijriCalendar();
  _check_date.hYear = 1439;
  _check_date.hMonth = 11;
  _check_date.hDay = 30;
  print(_check_date.isValid()); // false -> This month is only 29 days
From Ummalqura to Gregorian
  //From Ummalqura to Gregorian
  var g_date = HijriCalendar();
  print(g_date.hijriToGregorian(1415, 7, 27)); //1994-12-29 00:00:00.000
Format
  var _format = HijriCalendar.now();
  print(_format.fullDate()); //Thulatha, Ramadan 14, 1439 h
  print(_format.toFormat("mm dd yy")); //09 14 39
Compare
  //Suppose current hijri data is: Thulatha, Ramadan 14, 1439 h
  print(_today.isAfter(1440, 11, 12)); // false
  print(_today.isBefore(1440, 11, 12)); // true
  print(_today.isAtSameMomentAs(1440, 11, 12)); // false

所属分类

源码仓库

使用此插件的项目