0 purchases
daydart
English | Chinese
DayDart #
Time-handling library with day.js API.
Getting Started #
This project is a starting point for a Dart
package,
a library module containing code that can be shared easily across
multiple Flutter or Dart projects.
For help getting started with Flutter, view our
online documentation, which offers tutorials,
samples, guidance on mobile development, and a full API reference.
Install #
Run this command under your project
dart pub add daydart
# or
flutter pub add daydart
copied to clipboard
API #
The DayDart object is immutable, and all calls will return a new DayDart object.
Parsing
Now Time
String
DateTime
Timestamp
Clone
Valid
Get
Year
Month
Quarter
Day
Days
DayOfYear
Weeks
Week
Hour
Minute
Second
Millisecond
Operation
Add
Subtract
Query
isBefore
isSame
isAfter
isSameOrBefore
isSameOrAfter
isBetween
isDayDart
isLeapYear
Display
Format
To DateTime
To List
To Map
To IOS 8601 String
To String
Parsing #
Passing in the supported format in DayDart.
Now Time
Calling DayDart() with no arguments returns a new DayDart object containing the current date and time
DayDart now = DayDart()
copied to clipboard
String
Parses the given string in ISO 8601 format and returns an instance of the DayDart object.
DayDart('2018-04-04')
copied to clipboard
DateTime
A DateTime object passed in.
DayDart(DateTime.now());
copied to clipboard
Timestamp
Create DayDart with an integer value of milliseconds
DayDart(1623484401193);
copied to clipboard
Clone
All DayDart objects are immutable. Dayart#clone can still create a clone of the current object if needed.
DayDart a = DayDart()
DayDart b = a.clone()
copied to clipboard
Calling DayDart() on the DayDart object also clones it.
DayDart a = DayDart()
DayDart b = DayDart(a)
copied to clipboard
Valid
Returns a Boolean indicating whether the DayDart object contains an expiration date.
DayDart().isValid()
copied to clipboard
Get #
Year
Gets or sets the year.
DayDart().year();
DayDart().year(2000);
copied to clipboard
Month
Gets or sets the month.
Accept numbers from 1 to 12. If it exceeds that range, it will continue until the end of the year.
DayDart().month();
DayDart().month(1);
copied to clipboard
Quarter
Gets or sets the quarter.
DayDart('2010-04-01').quarter() // 2
DayDart('2010-04-01').quarter(2)
copied to clipboard
Day
Gets or sets the date of the month.
Accept numbers from 1 to 31. If this range is exceeded, it will last until the day.
DayDart().day()
DayDart().day(1)
copied to clipboard
Days
Gets the total number of days of the month
DayDart().days()
copied to clipboard
DayOfYear
Total number of days from date to year
DayDart().dayOfYear()
copied to clipboard
Weeks
Gets the total number of weeks from the date to the beginning of the year
DayDart().weeks()
copied to clipboard
Week
For week
DayDart().week()
copied to clipboard
Hour
Gets or sets the hour.
Accept the numbers from 0 to 59. If this range is exceeded, it will last until the day.
DayDart().hour()
DayDart().hour(12)
copied to clipboard
Minute
Gets or sets the minutes.
Accept the numbers from 0 to 59. If this range is exceeded, it will last until hours
DayDart().minute()
DayDart().minute(12)
copied to clipboard
Second
Gets or sets the seconds.
Accept the numbers from 0 to 59. If this range is exceeded, it will last up to minutes.
DayDart().second()
DayDart().second(12)
copied to clipboard
Millisecond
Gets or sets milliseconds.
Accepts numbers from 0 to 999. If this range is exceeded, it will last up to seconds.
DayDart().millisecond()
DayDart().millisecond(12)
copied to clipboard
Operation #
Once you have a DayDart object, you might want to manipulate it in some way.
DayDart supports method links like this:
DayDart('2019-01-25')..add(1, DayUnits.D)..subtract(1, DayUnits.y)..year(2009)..toString()
copied to clipboard
List of all available units
uni
desc
D
day (1-31)
M
month(1-12)
y
year
h
hour
m
minutes
s
seconds
ms
millisecond
Add
Returns a cloned DayDart object, adding the specified time.
DayDart().add(7, DayUnits.D)
copied to clipboard
Subtract
Returns the cloned 'DayDart' object, subtracting the specified time.
DayDart().subtract(7, DayUnits.D)
copied to clipboard
Query #
List of all available units
unit
desc
D
day
M
month
y
year
h
hour
m
minutes
s
seconds
ms
millisecond
isBefore
This indicates whether the DayDart object is before another supplied date-time.
DayDart().isBefore(DayDart('2011-01-01')) // default milliseconds
copied to clipboard
If you want to limit granularity to units rather than milliseconds, pass it as a second argument.
DayDart().isBefore('2011-01-01', DayUnits.y)
copied to clipboard
isSame
This indicates whether the DayDart object is the same as the date-time provided by another.
DayDart().isSame(DayDart('2011-01-01')) // default milliseconds
copied to clipboard
If you want to limit granularity to units rather than milliseconds, pass it as a second argument.
DayDart().isSame('2011-01-01', DayUnits.y)
copied to clipboard
isAfter
This indicates whether the DayDart object is after another supplied date-time.
DayDart().isAfter(DayDart('2011-01-01')) // default milliseconds
copied to clipboard
If you want to limit granularity to units rather than milliseconds, pass it as a second argument.。
DayDart().isAfter('2011-01-01', DayUnits.y)
copied to clipboard
isSameOrBefore
This indicates whether the DayDart object is the same or before another provided date-time.
DayDart().isSameOrBefore(DayDart('2011-01-01')) // default milliseconds
copied to clipboard
If you want to limit granularity to units rather than milliseconds, pass it as a second argument.
DayDart().isSameOrBefore('2011-01-01', DayUnits.y)
copied to clipboard
isSameOrAfter
This indicates whether the DayDart object is the same or after another supplied date-time.
DayDart().isSameOrAfter(DayDart('2011-01-01')) // default milliseconds
copied to clipboard
If you want to limit granularity to units rather than milliseconds, pass it as a second argument.
DayDart().isSameOrAfter('2011-01-01', DayUnits.y)
copied to clipboard
isBetween
This indicates whether the DayDart object is between the other two supplied date-times.
DayDart('2010-10-20').isBetween('2010-10-19', DayDart('2010-10-25'))// default milliseconds
copied to clipboard
If you want to limit granularity to units rather than milliseconds, pass it as a third parameter.
DayDart().isBetween('2010-10-19', '2010-10-25', DayUnits.y)
copied to clipboard
isDayDart
This indicates whether the variable is a DayDart object.
DayDart.isDayDart(DayDart()) // true
DayDart.isDayDart(DateTime.now()) // false
copied to clipboard
You can also use the is operator:
DayDart() is DayDart // true
copied to clipboard
isLeapYear
This indicates whether the year of the DayDart object is a leap year.
DayDart('2000-01-01').isLeapYear() // true
copied to clipboard
Display #
Format
Gets the formatted date based on the passed token string.
To escape characters, enclose them in square brackets (for example, 'MM').
DayDart().format()
DayDart('2019-01-25').format('dd/MM/yyyy') // '25/01/2019'
copied to clipboard
A list of all available parse tags
arg
desc
d
DAY
E
ABBR_WEEKDAY
EEEE
WEEKDAY
LLL
ABBR_STANDALONE_MONTH
LLLL
STANDALONE_MONTH
M
NUM_MONTH
Md
NUM_MONTH_DAY
MEd
NUM_MONTH_WEEKDAY_DAY
MMM
ABBR_MONTH
MMMd
ABBR_MONTH_DAY
MMMEd
ABBR_MONTH_WEEKDAY_DAY
MMMM
MONTH
MMMMd
MONTH_DAY
MMMMEEEEd
MONTH_WEEKDAY_DAY
QQQ
ABBR_QUARTER
QQQQ
QUARTER
y
YEAR
yM
YEAR_NUM_MONTH
yMd
YEAR_NUM_MONTH_DAY
yMEd
YEAR_NUM_MONTH_WEEKDAY_DAY
yMMM
YEAR_ABBR_MONTH
yMMMd
YEAR_ABBR_MONTH_DAY
yMMMEd
YEAR_ABBR_MONTH_WEEKDAY_DAY
yMMMM
YEAR_MONTH
yMMMMd
YEAR_MONTH_DAY
yMMMMEEEEd
YEAR_MONTH_WEEKDAY_DAY
yQQQ
YEAR_ABBR_QUARTER
yQQQQ
YEAR_QUARTER
H
HOUR24
Hm
HOUR24_MINUTE
Hms
HOUR24_MINUTE_SECOND
j
HOUR
jm
HOUR_MINUTE
jms
HOUR_MINUTE_SECOND
m
MINUTE
ms
MINUTE_SECOND
s
SECOND
To DateTime
To get a copy of the local date object parsed from the 'dayDart' object, use dayDart #toDate.
DayDart('2019-01-25').toDate()
copied to clipboard
To List
DayDart('2019-01-25').toList() // [ 2019, 0, 25, 0, 0, 0, 0 ]
copied to clipboard
To Map
Returns Map with date property.
DayDart('2019-01-25').toMap()
/*
{
years: 2019,
months: 0,
date: 25,
hours: 0,
minutes: 0,
seconds: 0,
milliseconds: 0
}
*/
copied to clipboard
To IOS 8601 String
Formatted as an ISO 8601 string.
DayDart('2019-01-25').toISOString() // 2019-01-25T00:00:00.000
copied to clipboard
To String
Returns a string representation of the date.
DayDart('2019-01-25').toString() // 2019-01-25 00:00:00.000
copied to clipboard
Stargazers over time #
This project will be updated continuously. Your valuable comments are welcome.
Issues
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.