Skip to content

Besufikad17/ecDart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ecDart

Simple re-implementation of Ethiopian and Gregorian calendar in dart based on Abushakir-dart package.

Installation

  1. Clonning the repo

     git clone https://github.com/Besufikad17/ecDart.git
  2. Installing packages

     cd ecDart && pub get
  3. Running tests

    dart test/etc_test.dart && dart test/gc_test.dart && dart test/util_test.dart

Usage

Ethiopian Calendar

  • Ethiopian calendar can be implemented by creating EthiopianCalendar instance.
   import 'package:ecDart/calendar/ethiopian_calendar.dart';

   // creating instance with paramters
   var ec = new EthiopianCalendar(year: 2015, month: 1, day: 1);    
   print(ec.month_name);                                               //  "መስከረም"
   print(ec.isHoliday);                                                //  true
   print(ec.holiday_name);                                             //  "አዲስ አመት"

   // creating instance that contains the current date
   var now = new EthiopianCalendar.now();                             
   print(now.year);                                                    //  2015
   print(now.month_name);                                              //  "ሰኔ"
   print(now.day);                                                     //  3
   print(now.day_name);                                                // "ቅዳሜ"
  • EthiopianCalendar instance contains method called toGC() which is used to convert a given Ethiopian date to Gregorian.
  import 'package:ecDart/calendar/ethiopian_calendar.dart';
  
  // creating instance that contains the current date
  var now = new EthiopianCalendar.now();         

  // converting the current date to gregorian                    
  var now_gc = now.toGC();                                          
  print(now_gc.year);                                                 //  2023
  print(now_gc.month_name);                                           //  "June"
  print(now_gc.day);                                                  //  10
  print(now_gc.day_name);                                             // "Saturday"
  • EthiopianCalendar instance contains methods to get the next month, previous month, next year and previous year in the form of Ethiopian date.
   import 'package:ecDart/calendar/ethiopian_calendar.dart';

   // creating instance that contains the current date
   var now = new EthiopianCalendar.now();                             
   
   // creating the next Ethiopian month  
   var next_month = now.nextMonth();
   print(next_month.year);                                            //  2015
   print(next_month.month_name);                                      //  "ኃምሌ"
   print(next_month.day);                                             //  3

   // creating the previous Ethiopian year
   var previous_year = now.previousYear();
   print(previous_year.year);                                         //  2014
   print(previous_year.month_name);                                   //  "ሰኔ"
   print(previous_year.day);                                          //  3

Gregorian Calendar

  • Gregorian calendar can be implemented by creating GregorianCalendar instance.
   import 'package:ecDart/calendar/gregorian_calendar.dart';

   // creating instance with paramters
   var gc = new GregorianCalendar(year: 2023, month: 6, day: 8);
   print(gc.year);                                                     // 2023
   print(gc.month_name);                                               // "June"
   print(gc.day_name);                                                 // "Thursday"

   // creating instance that contains the current date
   var now = new GregorianCalendar.now();
   print(now.year);                                                    // 2023
   print(now.month_name);                                              // "June"
   print(now.day_name);                                                // "Saturday"
  • GregorianCalendar instance contains method called toEC() which is used to convert a given Gregorian date to Ethiopian.
  import 'package:ecDart/calendar/gregorian_calendar.dart';
  
  // creating instance that contains the current date
  var now = new GregorianCalendar.now();

  // converting the current date to gregorian
  var ec = now.toEC();
  print(ec.year);                                                       // 2015
  print(ec.month_name);                                                 // "ሰኔ"
  print(ec.day_name);                                                   // "ቅዳሜ"
  • GregorianCalendar instance contains methods to get the next month, previous month, next year and previous year in the form of Gregorian date.
   import 'package:ecDart/calendar/gregorian_calendar.dart';

   // creating instance that contains the current date
   var now = new GregorianCalendar.now();                             
   
   // creating the next Gregorian month  
   var next_month = now.nextMonth();
   print(next_month.year);                                               //  2023
   print(next_month.month_name);                                         //  "July"
   print(next_month.day);                                                //  10

   // creating the previous Gregorian year
   var previous_year = now.previousYear();
   print(previous_year.year);                                            //  2022
   print(previous_year.month_name);                                      //  "June"
   print(previous_year.day);                                             //  10

Utilities

  • ecDart contains utility functions for calculating month and day of movable and non movabele holidays.
   import 'package:ecDart/utils/helpers/util.dart';

   // getting all holidays of a given Ethiopian year 
   var holidays = getHolidays(2015);

   // getting holiday name of specific Ethiopian date
   var holiday = getHoliday("የካቲት", 23, 2015);
   print(holiday);                                                        // "አደዋ" (non moviable holiday)

   var fasika = getHoliday("ሚያዝያ", 8, 2015);
   print(fasika);                                                        // "ትንሳኤ" (moviable holiday)

Holidays model

   [
      {
         "name": "name of the holiday",
         "month": "month name of the holiday",
         "day": "day of the holiday"
      }
   ]

Contributing

  • Create an issue or pick one of the issues
  • Clone the repo and start working on the issue
  • Create a pull request

For additional questions and suggestions you can reach me in my socials.

About

Simple reimplementation of ETC and GC in dart.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages