FLUTTER ECOSYSTEM

teerasej/dart-flutter-buddhist-datetime-dateformat

一組用於 Dart 和 Flutter 專案中需要使用佛教曆法格式 DateTime 的擴充功能

dart-flutter-佛教-日期時間-日期格式 專案封面
Stars
6
Forks
14
最近推送(UTC)
2022年1月26日
專案狀態
未封存
Teerasej Jiraphatchandej GitHub avatar
GITHUB User

Teerasej Jiraphatchandej ↗

AI Technology Influencer, Developer, Speaker, and Consultant. Love Travel around the world

Next flow Thailand官方網站 ↗
語言Dart

技術主題

此儲存庫發佈的套件

使用的依賴

依賴清單 3 項
  • flutter{"sdk":"flutter"}
  • intl^0.16.1
  • flutter_test開發依賴{"sdk":"flutter"}

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 README

Buddhist Calendar DateTime and DateFormatter for Dart and Flutter

If this helps you out of problem, please give it a like in pub.dev or a star on github. :smile:

ภาษาไทยอ่านวิธีใช้ที่นี่นะครับ

2020-06-05_17-31-47

These are extension that you can get DateTime and DateFormat in Buddhist calendar's format.

I implemented these extensions for use in Thai language project. But you can contribute to add more support for other countries who also use Buddhist calendar in the apps.

Getting Started

1. Setup

Install package via pubspec.yaml

dependencies:
  intl: ^0.16.1  
  buddhist_datetime_dateformat: ^1.0.1

2. Initialization

Then go to your main.dart. Let's import and write some Initialization code.

// need this for `Intl.defaultLocale = "th";`
import 'package:intl/intl.dart';
// need this for initializeDateFormatting()
import 'package:intl/date_symbol_data_local.dart';

// This lets magic happen!
import 'package:buddhist_datetime_dateformat/buddhist_datetime_dateformat.dart';

void main() {

  // set your default locale here. It will be applied to DateFormat autmomatically.
  Intl.defaultLocale = "th";
  initializeDateFormatting();

  runApp(MyApp());
}

3. Use it

  • You will found .yearInBuddhistCalendar property in DateTime's instance. This will return converted year value into Buddhist era.
  • Also .formatInBuddhistCalendarThai(datetime) method in DateFormat which return correct format for Thai language if you pass DateTime's instance into it.
var now = DateTime.now();
var onlyBuddhistYear = now.yearInBuddhistCalendar;

var formatter = DateFormat.yMMMMEEEEd();
var dateInBuddhistCalendarFormat = formatter.formatInBuddhistCalendarThai(now);

Open for contribution

If you want to contribute, there are several countries that also use Buddhist calendar:

  • Thailand
  • Cambodia
  • Laos
  • MyanMar
  • Sri Lanka
  • Malaysia
  • Singapore

Reference: https:en.wikipedia.org/wiki/Buddhist_calendar

I don't know other langauge need a prefix for Buddhist year like in Thailand (พ.ศ.). If yes, so you can help me correct their format by update the code with your customization. Just make pull request.