jalali Table Calendar

  Calendar

if you have any issue or any suggestion you could contact a Calendar , DatePicker and Date Converter For Persian Date(Jalali/Shamsi date) with holidays

Modified and Completed Version of jalali_calendar package

Usage

Import this line in Flutter pubspec.yaml

jalali_table_calendar: ^1.0.2

To Use Calendar Or DatePicker , Import this line to your dart file

import 'package:jalali_table_calendar/jalali_table_calendar.dart';

To Use date Converter , Import this line to your dart file

import 'package:persian_date/persian_date.dart';

After import library, to show the calendar you can use jalaliCalendar or jalaliCalendarPicker() method , on the constructor context is important

This sample make a Calendar Widget

jalaliCalendar(
    context: context,
    // add the events for each day
    events: {
        DateTime(2021,4,15):['sample event',66546],
        DateTime(2021,4,14):[6,5,465,1,66546],
        DateTime(2021,4,18):[6,5,465,1,66546],
        DateTime(2021,4,19):[6,5,465,1,66546],
         },
    //make marker for every day that have some events
    marker: (date,events){
        return Positioned(
            top: -4,
            left: 0,
            child: Container(
            decoration: BoxDecoration(
            color: Theme.of(context).textSelectionColor,
            shape: BoxShape.circle),
            padding: const EdgeInsets.all(6.0),
              child: Text(events.length.toString()),
                ),
             );
            },
    onDaySelected: (date) {
        print(date);
         }),

This sample return the selected date as Jalali(شمسی)

if you want to return the selected date to Gregorian, on the constructor set the convertToGregorian to true

Future _selectDate() async {
    String picked = await jalaliCalendarPicker(context: context); // نمایش خروجی به صورت شمسی
   //  await jalaliCalendarPicker(context: context,convertToGregorian: true); // نمایش خروجی به صورت میلادی
    if (picked != null) setState(() => _value =picked.toString());
    print(_value);
  }

This sample return the selected date as Gregorian(میلادی)

Future _selectDate() async {
    String picked = await jalaliCalendarPicker(context: context,convertToGregorian: true); // نمایش خروجی به صورت میلادی
    if (picked != null) setState(() => _value =picked.toString());
    print(_value);
  }

Those parameters using To Show the TimePicker

Parameteroperation
showTimePickerTo show TimePicker set it true
hore24FormatTo return time in 24 hours format set it true
initialTimeTo set initial time use it with TimeOfDay

To use datePicker you can follow this sample

To show DatePicker those parameters is required

minYear // min date this required  for the start year in Jalali
maxYear // max  date this required  for the last year in jalali
confirm and cancel // widget for show text
_format // for returning date like String _format = 'yyyy-mm-dd';
onChanged // return date when the user changes the date
onConfirm //  return date when the user click confirm

For set, default date use those parameters

initialYear => for year
initialMonth => for month
initialDay => for day

Full datePicker Sample

    DatePicker.showDatePicker(
      context,
      minYear: 1300,
      maxYear: 1450,
      confirm: Text(
        'Confirm',
        style: TextStyle(color: Colors.red),
      ),
      cancel: Text(
        'Cancel',
        style: TextStyle(color: Colors.cyan),
      ),
      dateFormat: _format,
      onChanged: (year, month, day) {
        if (!showTitleActions) {
          _changeDatetime(year, month, day);
        }
      },
      onConfirm: (year, month, day) {
        _changeDatetime(year, month, day);
        _valuePiker = " Full date : $_datetime  \n year : $year \n  Month  :   $month \n  day :  $day";
      }
    )

 void _changeDatetime(int year, int month, int day) {
    setState(() {
      _datetime = '$year-$month-$day';
    });
  }

To use date Converter you can follow this sample

first import this library to your code

import 'package:persian_date/persian_date.dart';

Full Date Converter Sample

PersianDate pDate = PersianDate(gregorian: "1989-01-29");
    print("Now ${pDate.getDate}");

    PersianDate persianDate = PersianDate();
    print("Now ${persianDate.now}");
    print(persianDate.hour);
    print("year ${persianDate.year}");
    print("isHoliday ${persianDate.isHoliday}");
    print("isHoliday ${persianDate.weekdayname}");
    print(persianDate.monthname); // نام ماه
      print(persianDate.month); // ماه
      print(persianDate.day); // روز
      print(persianDate.hour);// ساعت
      print(persianDate.minute);// دقیقه
      print(persianDate.second);// ثانیه
      print(persianDate.millisecond); // میلی ثانیه
      print(persianDate.microsecond);//


print("Parse Gregorian To Jalali ${persianDate.gregorianToJalali("2019-02-20T00:19:54.000Z","yyyy-m-d hh:nn")}");
print("Parse Jalali To Gregorian ${persianDate.jalaliToGregorian("1368-05-30 19:54", "yyyy-m-d hh:nn")}");

those formats are supported in date converter

   `"2012-02-27 13:27:00"`
    `"2012-02-27 13:27:00.123456z"`
    `"2012-02-27 13:27:00,123456z"`
    `"20120227 13:27:00"`
    `"20120227T132700"`
    `"20120227"`
    `"+20120227"`
    `"2012-02-27T14Z"`
    `"2012-02-27T14+00:00"`
    `"-123450101 00:00:00 Z"`: in the year -12345.
    `"2002-02-27T14:00:00-0500"`: Same as `"2002-02-27T19:00:00Z"`
FormatoperationFormatoperation
yyyyreturn year with Four numberhhhours with two number
yyreturn year with two numberhhours with one number
mmreturn month with two numberHHhours with two number in 24
mreturn month with one numberHhours with one number in 24
MMthe month name with full letternnminut with two number
Mthe month name with short formnminut with one number
ddthe day with two numberssSecond with two number
dthe day with one numbersSecond with one number
wweek numberSSshow milliSecond
DDthe day name with full letterSshow milliSecond
Dthe day name with short formuuushow microsecond
amShow time in shortushow microsecond
AMShow full time..

Download jalali Table Calendar package source code on GitHub