EtDatetime class

An instant in time, such as መጋቢት 20, 2012, 8:18pm.

EtDatetime can represent time values that are at a distance of at most 100,000,000 days from epoch (1970-01-01): -271821-04-20 to 275760-09-13.

Create a EtDatetime object by using one of the constructors or by parsing a correctly formatted string, which complies with a subset of ISO 8601. Note that hours are specified between 0 and 23, as in a 24-hour clock. For example:

var now = new EtDatetime.now();
var covid19Confirmed = new EtDatetime(year: 2012, month: 7, day: 4);
var lockdownBegin = new EtDatetime.fromMillisecondsSinceEpoch(1586215439441);

Once created, the value of an EtDatetime object may not be changed.

You can use properties to get the individual units of an EtDatetime object.

assert(covid19Confirmed.year == 2012);
assert(covid19Confirmed.month == 7);
assert(covid19Confirmed.day == 2);

For convenience and readability, the EtDatetime class provides a constant for each day and month name - for example, መስከረም and ማግሰኞ. You can use these constants to improve code readability:

Day and month indexes begin at 0, and the week starts on Monday (ሰኞ). That is, the constants መስከረም and ሰኞ are both 1.

Comparing EtDatetime objects

The EtDatetime class contains several handy methods, such as isAfter, isBefore, and isAtSameMomentAs, for comparing EtDatetime objects.

assert(lockdownBegin.isAfter(covid19Confirmed) == true);
assert(covid19Confirmed.isBefore(lockdownBegin) == false);

Using EtDatetime with Duration

Use the add and subtract methods with a Duration object to create a new EtDatetime object based on another. For example, to find the date that is sixty days (24 /// 60 hours) after today, write:

var now = new EtDatetime.now();
var sixtyDaysFromNow = now.add(new Duration(days: 60));

To find out how much time is between two EtDatetime objects use difference, which returns a Duration object:

var difference = covid19Confirmed.difference(lockdownBegin);
assert(difference.inDays == 24);

NOTE

There is no UTC or TIme zone feature in this package since it's built only for ethiopia.

Realtime Clock

The EtDatetime class provides realtime clock for Ethiopian with 6 hour offset and can be integrated into flutter application. See sample flutter application made for this purpose.

Inheritance

Constructors

EtDatetime({required int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0})
Constructs an EtDatetime instance.
EtDatetime.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch)
Constructs an EtDatetime instance with the given millisecondsSinceEpoch.
EtDatetime.now()
Constructs an EtDatetime instance with current date and time.

Properties

date Map<String, int>
The Date
no setter
day int
The day of the month 1..30.
no setteroverride
dayGeez String
The day of the month in Ge'ez '፩'..'፴'.
no setteroverride
fixed int
Fixed date—elapsed days since the onset of Monday, January 1, 1970 (Gregorian)
final
hashCode int
The hash code for this object.
no setterinherited
hour int
The hour of the day, expressed as in a 24-hour clock 0..23.
no setteroverride
isLeap bool
Returns true if year is leap year or returns false.
no setter
millisecond int
The millisecond 0...999.
no setteroverride
minute int
The minute 0...59.
no setteroverride
moment int
Milliseconds since UNIX Epoch of this EtDatetime.
final
month int
The month 1..13.
no setteroverride
monthGeez String?
The month name for the current EtDatetime instance.
no setteroverride
props List<Object>
The list of properties that will be used to determine whether two instances are equal.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
second int
The second 0...59.
no setteroverride
stringify bool
If set to true, the toString method will be overridden to output this instance's props.
no setter
time Map<String, int>
The Time
no setter
weekday int
First Day of the Month
no setter
year int
The year.
no setteroverride
yearFirstDay int
First day of the Year
no setter

Methods

add(Duration duration) EtDatetime
Returns a new EtDatetime instance with duration added to current instance.
override
clock() Stream<int>
Stream of moment delayed with 1 second.
compareTo(EtDatetime other) int
Compares this EtDatetime object to other, returning zero if the values are equal.
override
difference(EtDatetime date) Duration
Returns a Duration with the difference between this and other.
isAfter(EtDatetime other) bool
Returns true if current instance occurs after other.
override
isAtSameMomentAs(EtDatetime other) bool
Returns true if current instance occurs at the same moment as other.
override
isBefore(EtDatetime other) bool
Returns true if current instance occurs before the other.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subtract(Duration duration) EtDatetime
Returns a new EtDatetime instance with duration subtracted from current instance.
override
toIso8601String() String
Returns an ISO-8601 full-precision extended format representation.
override
toJson() String
Returns a JSON serialization for this instance.
override
toString() String
Returns a human-readable string for this instance.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

parse(String formattedString) EtDatetime
Constructs a new EtDatetime instance based on formattedString.
tryParse(String formattedString) EtDatetime?
Constructs a new EtDatetime instance based on formattedString.