abstarct_date 0.0.4+1 copy "abstarct_date: ^0.0.4+1" to clipboard
abstarct_date: ^0.0.4+1 copied to clipboard

discontinuedreplaced by: abstract_date
outdated

Abstract date is a fluent date system for working with different date types from around the world.

Showcase #

// registering the date systems that we want to use
    Date.addType<ShamsiDate>(ShamsiDate());
    Date.addType<GregorianDate>(GregorianDate());

// Creating a new date
    var date = Date<ShamsiDate>(1379,6,26);

// Converting dates
    var converted = date.as<GregorianDate>();
    date = converted.as<Shamsi>();

// Type checking
    if(date.isTypeOf<ShamsiDate>()){
      print('its shamsi!');
    }
    
// Other utility methods
    var tomorrow = date.add(Duration(days: 1));
    
    Duration d = date.difference(tomorrow);
  
    var realTomorrow = date.copy(
      day: date.day + 1,
    );

Date adapters #

Implementing a new Date adapter #

class NewDateSystem extends DateAdapter with DateFormatter {
  ...
}

If you don't add the DateFormatter mixin, some methods on date will throw an exception:

  1. formatter
  2. monthName
  3. weekDayName
  4. formatted*
  5. formatBuilder*

*: these might not throw exception if you don't use named parts.

###Adding Adapters: Before using Date you should register the types you want to use.

    Date.addType<ShamsiDate>(ShamsiDate());
    Date.addType<GregorianDate>(GregorianDate());

Renaming Adapters #

If you don't like the name of a certain adapter, just extend it and register with the new class:

class Hijri extends IslamicDate {}
...
Date.addType<Hijri>(Hijri());
1
likes
0
pub points
0%
popularity

Publisher

verified publisheraligator.ir

Abstract date is a fluent date system for working with different date types from around the world.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

hijri, libcalendar

More

Packages that depend on abstarct_date