Jiffy class
Jiffy is a Flutter (Android, IOS and Web) date time package inspired by momentjs for parsing, manipulating, querying and formatting dates
Constructors
- Jiffy.now()
-
Returns a Jiffy instance representing the current date and time.
factory
- Jiffy.parse(String string, {String? pattern, bool isUtc = false})
-
Constructs a new Jiffy instance by parsing a String.
factory
- Jiffy.parseFromDateTime(DateTime dateTime)
-
Constructs a new Jiffy instance from a DateTime object.
factory
- Jiffy.parseFromJiffy(Jiffy jiffy)
-
Constructs a new Jiffy instance from an existing Jiffy object.
factory
-
Jiffy.parseFromList(List<
int> list, {bool isUtc = false}) -
Constructs a Jiffy instance from a list of integers representing a
date and time.
factory
-
Jiffy.parseFromMap(Map<
Unit, int> map, {bool isUtc = false}) -
Constructs a Jiffy instance from a
map
of date and time values.factory - Jiffy.parseFromMicrosecondsSinceEpoch(int microsecondsSinceEpoch, {bool isUtc = false})
-
Constructs a Jiffy instance from a
microsecondsSinceEpoch
of type int.factory - Jiffy.parseFromMillisecondsSinceEpoch(int millisecondsSinceEpoch, {bool isUtc = false})
-
Constructs a Jiffy instance from a
millisecondsSinceEpoch
of type int.factory
Properties
- date → int
-
Returns the date ranging from 1 to 31.
no setter
- dateTime → DateTime
-
Returns a new DateTime instance of the Jiffy object.
no setter
- dayOfWeek → int
-
Returns the day of the week according to the
Locale.startOfWeek()
.no setter - dayOfYear → int
-
Returns the day of the year of this Jiffy instance.
no setter
- daysInMonth → int
-
Returns the number of days in the month.
no setter
- E → String
-
Returns the abbreviated weekday. Example:
Tue
no setter - EEEE → String
-
Returns the weekday. Example:
Tuesday
no setter - H → String
-
Returns 24 hour and minute. Example:
12
no setter - hashCode → int
-
The hash code for this object.
no setteroverride
- Hm → String
-
Returns 24 hour and minute. Example:
12:11
no setter - Hms → String
-
Returns 24 hour, minute and second. Example:
12:11:22
no setter - hour → int
-
Returns the hour ranging from 0 to 23.
no setter
- isLeapYear → bool
-
Returns a boolean value indicating whether the Jiffy instance
provided falls on a leap year.
no setter
- isLocal → bool
-
Returns a boolean value indicating whether this Jiffy instance
represents a local date and time.
no setter
- isUtc → bool
-
Returns a boolean value indicating whether this Jiffy instance
represents a UTC date and time.
no setter
- j → String
-
Returns 12 hour. Example:
12 PM
no setter - jm → String
-
Returns 12 hour and minute. Example:
12:11 PM
no setter - jms → String
-
Returns 12 hour, minute and seconds. Example:
12:11:22 PM
no setter - localeCode → String
-
Returns the locale code for the current locale.
no setter
- localeStartOfWeek → StartOfWeek
-
Returns a StartOfWeek enum value indicating the day on which the week
starts for the current locale.
no setter
- Md → String
-
Returns the day of month and date. Example:
9/23
no setter - MEd → String
-
Returns the day of month, abbreviated weekday and date.
Example:
Tue, 9/23
no setter - microsecond → int
-
Returns the microsecond ranging from 0 to 999.
no setter
- microsecondsSinceEpoch → int
-
Returns the number of microseconds since epoch time
January 1, 1970, 00:00:00 UTC
.no setter - millisecond → int
-
Returns the millisecond ranging from 0 to 999.
no setter
- millisecondsSinceEpoch → int
-
Returns the number of milliseconds since epoch time
January 1, 1970, 00:00:00 UTC
.no setter - minute → int
-
Returns the minute ranging from 0 to 59.
no setter
- MMM → String
-
Returns the abbreviated month. Example:
Sep
no setter - MMMd → String
-
Returns the abbreviated month and date. Example:
Sep 23
no setter - MMMEd → String
-
Returns the abbreviated month, abbreviated weekday and date.
Example:
Tue, Sep 23
no setter - MMMM → String
-
Returns the month. Example:
September
no setter - MMMMd → String
-
Returns the month and date. Example:
September 23
no setter - MMMMEEEEd → String
-
Returns the month, weekday and date. Example:
Tuesday, September 23
no setter - month → int
-
Returns the month of the year ranging from 1 to 12.
no setter
- QQQ → String
-
Returns the abbreviated quarter. Example:
Q3
no setter - QQQQ → String
-
Returns the quarter. Example:
3rd quarter
no setter - quarter → int
-
Returns the quarter on the year ranging from 1 to 4.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- second → int
-
Returns the second ranging from 0 to 59.
no setter
- weekOfYear → int
-
Returns the week of the year based on the current
Locale
's start of week.no setter - year → int
-
Returns the year.
no setter
- yM → String
-
Returns the year and day of month. Example:
9/1997
no setter - yMd → String
-
Returns the year, of month and date. Example:
9/23/1997
no setter - yMEd → String
-
Returns the year, of month, abbreviated weekday and date.
Example:
Tue, 9/23/1997
no setter - yMMM → String
-
Returns the year and abbreviated month. Example:
Sep 1997
no setter - yMMMd → String
-
Returns the year and abbreviated month. Example:
Sep 23, 1997
no setter - yMMMdjm → String
-
Returns the year, abbreviated month, date, hour and minute.
Example:
Sep 23, 1997 12:11 PM
no setter - yMMMEd → String
-
Returns the year, abbreviated month, abbreviated weekday and date.
Example:
Tue, Sep 23, 1997
no setter - yMMMEdjm → String
-
Returns the year, abbreviated month, abbreviated weekday, date, hour
and minute. Example:
Tue, Sep 23, 1997 12:11 PM
no setter - yMMMM → String
-
Returns the year and month. Example:
September 1997
no setter - yMMMMd → String
-
Returns the year, month and date. Example:
September 23, 1997
no setter - yMMMMdjm → String
-
Returns the year, month, date, hour and minute.
Example:
September 23, 1997 12:11 PM
no setter - yMMMMEEEEd → String
-
Returns the year, month, weekday and date.
Example:
Tuesday, September 23, 1997
no setter - yMMMMEEEEdjm → String
-
Returns the year, month, weekday, date, hour and minute.
Example:
Tuesday, September 23, 1997 12:11 PM
no setter - yQQQ → String
-
Returns the year and abbreviated quarter. Example:
Q3 1997
no setter - yQQQQ → String
-
Returns the year and quarter. Example:
3rd quarter 1997
no setter
Methods
-
add(
{int microseconds = 0, int milliseconds = 0, int seconds = 0, int minutes = 0, int hours = 0, int days = 0, int weeks = 0, int months = 0, int years = 0}) → Jiffy - Adds date and time to the current Jiffy instance and returns a new Jiffy instance with the result.
-
addDuration(
Duration duration) → Jiffy -
Adds the provided
duration
to the current Jiffy instance's date and time, and returns a new Jiffy instance with the updated value. -
clone(
) → Jiffy - Returns a new Jiffy instance with the same date and time as the original instance.
-
diff(
Jiffy jiffy, {Unit unit = Unit.microsecond, bool asFloat = false}) → num -
Returns the difference between this Jiffy instance and the given
jiffy
instance as a numeric value. -
endOf(
Unit unit) → Jiffy -
Returns a new Jiffy instance representing the end of the specified
unit
of time -
format(
{String? pattern}) → String -
Returns the formatted date and time string based on the provided
pattern
. If thepattern
is not provided, the method will return the formatted date and time string in the ISO-8601 format. -
from(
Jiffy jiffy, {bool withPrefixAndSuffix = true}) → String -
Returns a string representation of current Jiffy's instance relative
from
jiffy
's date and time, with optionalwithPrefixAndSuffix
flag to include prefix and suffix like "in" or "ago". -
fromNow(
{bool withPrefixAndSuffix = true}) → String -
Returns a string representation of current Jiffy's instance relative
from current date and time, with optional
withPrefixAndSuffix
flag to include prefix and suffix like "in" or "ago". -
isAfter(
Jiffy jiffy, {Unit unit = Unit.microsecond}) → bool -
Returns a boolean value indicating whether this Jiffy instance is
after the given
jiffy
instance. -
isBefore(
Jiffy jiffy, {Unit unit = Unit.microsecond}) → bool -
Returns a boolean value indicating whether this Jiffy instance is
before the given
jiffy
instance. -
isBetween(
Jiffy jiffyFrom, Jiffy jiffyTo, {Unit unit = Unit.microsecond}) → bool -
Returns a boolean value indicating whether this Jiffy instance is
between the two given
jiffyFrom
andjiffyTo
instances. -
isSame(
Jiffy jiffy, {Unit unit = Unit.microsecond}) → bool -
Returns a boolean value indicating whether this Jiffy instance is
the same as the given
jiffy
instance. -
isSameOrAfter(
Jiffy jiffy, {Unit unit = Unit.microsecond}) → bool -
Returns a boolean value indicating whether this Jiffy instance is
the same as or after the given
jiffy
instance. -
isSameOrBefore(
Jiffy jiffy, {Unit unit = Unit.microsecond}) → bool -
Returns a boolean value indicating whether this Jiffy instance is
the same as or before the given
jiffy
instance. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
startOf(
Unit unit) → Jiffy -
Returns a new Jiffy instance representing the start of the specified
unit
of time -
subtract(
{int microseconds = 0, int milliseconds = 0, int seconds = 0, int minutes = 0, int hours = 0, int days = 0, int weeks = 0, int months = 0, int years = 0}) → Jiffy - Subtracts the date and time from the current Jiffy instance and returns a new Jiffy instance with the result.
-
subtractDuration(
Duration duration) → Jiffy -
Subtracts the provided
duration
from the current Jiffy instance's date and time, and returns a new Jiffy instance with the updated value. -
to(
Jiffy jiffy, {bool withPrefixAndSuffix = true}) → String -
Returns a string representation of current Jiffy's instance relative
to
jiffy
's date and time, with optionalwithPrefixAndSuffix
flag to include prefix and suffix like "in" or "ago". -
toLocal(
) → Jiffy - Returns a new instance of Jiffy with the same date and time in local time zone.
-
toNow(
{bool withPrefixAndSuffix = true}) → String -
Returns a string representation of current Jiffy's instance relative
to current date and time, with optional
withPrefixAndSuffix
flag to include prefix and suffix like "in" or "ago". -
toString(
) → String -
A string representation of this object.
inherited
-
toUtc(
) → Jiffy - Returns a new instance of Jiffy with the same date and time in UTC time zone.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override