A new Flutter package project.

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.

API

The DayDart object is immutable, and all calls will return a new DayDart object.


parsing

Pass in the supported format in DayDart.

The current time

Run DayDart directly to get the DayDart object for the current time and date.

DayDart()Copy the code

Native to create

DayDart objects can be created just like DateTime objects

DayDart,12,12 (2019);Copy the code

Time string

Pass in a standard ISO 8601 time string.

DayDart.fromString('2019-02-21');Copy the code

A DateTime object

A DateTime object passed in.

DayDart.fromDateTime(new DateTime.now());Copy the code

copy

The DayDart object is immutable, so you can execute.clone() to get a copy of the DayDart object.

DayDart().clone();Copy the code

validation

  • return bool

Checks whether the current DayDart object is a valid time.

DayDart().isValid();Copy the code

To obtain

Get the date

years

  • return int

Gets the year.

DayDart().year();Copy the code

month

  • return int

To get in

DayDart().month();Copy the code

day

  • return int

Get the date.

DayDart().date();Copy the code

week

  • return int

Get the week.

DayDart().day();Copy the code

when

  • return int

Get hours.

DayDart().hour();Copy the code

points

  • return int

Get minutes.

DayDart().minute();Copy the code

seconds

  • return int

For a second.

DayDart().second();Copy the code

ms

  • return int

Get milliseconds.

DayDart().millisecond();Copy the code

operation

We can add the following operations to the DayDart object:

DayDart().add(2, Units.H).subtract(13, Units.M);Copy the code

increase

Add for the date and time and return a new DayDart object.

DayDart().add(2, Units.H);Copy the code

To reduce

Decrement for the date and time and return a new DayDart object.

DayDart().subtract(13, Units.M)Copy the code

The query

Whether or not before

  • return bool

Check whether another DayDart object precedes the current DayDart object

DayDart().isBefore(daydart);Copy the code

If after

  • return bool

Check whether another DayDart object is after the current DayDart object time

DayDart().isAfter(daydart);Copy the code

Check whether it is DayDart

DayDart.isDayDart(daydart)Copy the code

According to

Format and display the DayDart object.

formatting

  • return String
DayDart().format(fm: 'YYYY-MM-DD HH:mm:ss');Copy the code

Details as follows:

Format Output Description
YY 19 Two digit years
YYYY 2019 Four digit years
M 1-12 Month, starting at 1
MM 01-12 Month, double digits
D 1-31 A day in the month
DD 01-31 A day in The month, double digits
H 0-23 hours
HH 00-23 Hours, double digits
m 0-59 minutes
mm 00-59 Minutes, double digits
s 0-59 seconds
ss 00-59 Seconds, double digits
a am pm
A AM PM

A DateTime object

  • return DateTime

Returns a native DateTime object

DayDart().toDateTime();Copy the code

ISO 8601 The value is a character string

  • return String

The value is a string in ISO8601 format.

DayDart().toISOString();Copy the code

List

  • return List

Returns a List containing the time value.

DayDart().toList();Copy the code

Map

  • return Map<String, int>

Returns a Map containing a time value.

DayDart().toMap();Copy the code

string

  • return String
DayDart().toString();Copy the code