Skip to content

A simple and minimalisting date utility that helps you work with ethiopian date in dart/flutter. እኛ ራሳችን ለራሳችን ካልሰራን ማን ይሰራልናል። ኣንድ ፈረንጅ መቶ ኣይሰራልን።

License

Notifications You must be signed in to change notification settings

kidusdev/geezdate_dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GEEZ DATE IMAGE

GEEZDATE

A simple and lightweight date utility designed to make working with Ethiopian dates effortless in Dart and Flutter. It provides an easy-to-use interface, allowing developers to quickly handle and manipulate Ethiopian calendar dates without complexity. Perfect for projects that require seamless integration of Ethiopian date formats

Installation

  • using dart
$ dart pub add geezdate
  • using flutter
$ flutter pub add geezdate

Usage

creating instance of GeezDate

// literal GeezDate
final date = GeezDate(2016, 10, 11);

// now
final date = GeezDate.now();

// from DateTime object
final date = GeezDate.fromDateTime(DateTime.now());

// from string must be date-month-year
final date = GeezDate.fromString("11-10-2016");

// from json
final date = GeezDate.fromJson({"year": 2016, "month": 10, "date": 10});

converting

// converting EC to GC
final gc = GeezDate(2016, 10, 11).toGC();

// converting GC to EC
final ec = GeezDate.fromDateTime(DateTime.now());

// converting through extensions
final ec2 = DateTime.now().toEC();

operators

final date = GeezDate(2016, 10, 11);
final anotherDate = GeezDate(2015, 11, 10);

print(date == anotherDate); // false
print(date > anotherDate); // true
print(date < anotherDate); // false
print(date + 1); // GeezDate (year: 2016, month: 10, date: 11, hour: 1, minute: 0, second: 1, shift: Shift.day)
print(date - 1); // GeezDate (year: 2016, month: 10, date: 11, hour: 12, minute: 59, second: 59, shift: Shift.day)
...

formatting

// NB. if you are in VSCODE hover over the `format` function to get the below description
final date = GeezDate(2016, 10, 11);

final formatLanguage = FormatLanguage.am;
final formatted = date.format("ዛሬ ቀኑ .D, .M .d, .Y .E ነው።", lang: formatLanguage);

print(formatted); // ዛሬ ቀኑ ዓርብ, መጋቢት 06, 2016 ዓ.ም ነው።

// Languages
// FormatLanguage.en for english;
// FormatLanguage.am for amharic;
// FormatLanguage.ti for tigrigna;
// FormatLanguage.or for oromifa;

// Formatting Strings
// .d     - date          => 1 - 30
// .D     - day           => እሁድ - ቅዳሜ
// .m     - month index   => 1 - 13
// .M     - month name    => መስከረም - ጳጉሜ
// .y     - year          => 00
// .Y     - year          => 0000
// .E     - calender      => ዓ.ም

adding and subtracting from dates

final date = GeezDate(2016, 3, 11);

// adding time
final futureDate = date.add(months: 1, days: 10);

// subtracting time
final pastDate = date.subtract(months: 2, days: 12);

// adding through extensions
print(date + 3.days); // GeezDate (year: 2016, month: 3, date: 14, hour: 1, minute: 0, second: 0, shift: Shift.day)
print(date + 3.days + 2.months); // GeezDate (year: 2016, month: 5, date: 15, hour: 9, minute: 9, second: 36, shift: Shift.night)
print(date + 2.years); // GeezDate (year: 2018, month: 3, date: 11, hour: 1, minute: 0, second: 0, shift: Shift.day)
print(date + 2.years + 2.months); // GeezDate (year: 2018, month: 5, date: 12, hour: 9, minute: 9, second: 36, shift: Shift.night)
...

checking

final date = GeezDate(2016, 10, 11);
final anotherDate = GeezDate(2015, 11, 10);

// checking date
final isToday = date.isToday; // returns true/false
final isPast = date.isPast; // returns true/false
final isFuture = date.isFuture; // returns true/false
final isThisMonth = date.isThisMonth; // returns true/false
final isThisYear = date.isThisYear; // returns true/false

// comparing dates
final isSameDate = date.isSameDate(anotherDate); // returns true/false
final isSameDay = date.isSameDay(anotherDate); // returns true/false
final isSameMonth = date.isSameMonth(anotherDate); // returns true/false
final isSameYear = date.isSameYear(anotherDate); // returns true/false
final isBetweenTwoDates = date.isBetween(date, anotherDate); // returns true/false
...

outputing date

final date = GeezDate(2016, 10, 11);

print(date.toString());
// GeezDate (year: 2016, month: 10, date: 11, hour: 1, minute: 0, second: 0, shift: Shift.day)

print(date.hashCode);
// 20161011100

Upcoming Features

  • Formatting date in all ethiopian languages
  • difference between two dates
  • working with time (hours, minutes and seconds)
  • parsing different types of date to GeezDate
  • and more

to contribute send pull request github

About

A simple and minimalisting date utility that helps you work with ethiopian date in dart/flutter. እኛ ራሳችን ለራሳችን ካልሰራን ማን ይሰራልናል። ኣንድ ፈረንጅ መቶ ኣይሰራልን።

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages