buddhist_datetime_dateformat 1.0.6
buddhist_datetime_dateformat: ^1.0.6

Flutter Android iOS web

A dart package that help developer get DateTime's year in Buddhist calendar format, also support DateFormatter

example/main.dart

import 'package:flutter/material.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
import 'package:buddhist_datetime_dateformat/buddhist_datetime_dateformat.dart';

void main() {
  Intl.defaultLocale = "th";
  initializeDateFormatting();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Nextflow Flutter Widget Today',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter 3 นาที: วันเดือนปีไทยๆ'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    
    var now = DateTime.now();
    var onlyBuddhistYear = now.yearInBuddhistCalendar;

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

    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Container(
          padding: EdgeInsets.all(10),
          child: Text('$dateInBuddhistCalendarFormat --- $onlyBuddhistYear'),
        ));
  }
}
12
likes
100
pub points
86%
popularity

A dart package that help developer get DateTime's year in Buddhist calendar format, also support DateFormatter

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

teerasej@gmail.com

License

Apache 2.0 (LICENSE)

Dependencies

flutter, intl

More

Packages that depend on buddhist_datetime_dateformat