flutter_daydart 0.0.3

DayDart #

A new Flutter package project.

https://img.shields.io/github/license/icepy/flutter_daydart.svg https://img.shields.io/github/issues/icepy/flutter_daydart.svg

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 #

DayDart 对象是不可变的,所有的调用都将返回一个新的 DayDart 对象。


解析 #

DayDart 中传入支持的格式。

当前时间 #

直接运行 DayDart 获取当前时间和日期的 DayDart 对象。

DayDart()

原生创建 #

可以像 DateTime 一样的创建 DayDart 对象

DayDart(2019,12,12);

时间字符串 #

传入的一个标准的ISO 8601时间字符串。

DayDart.fromString('2019-02-21');

DateTime 对象 #

传入的一个 DateTime 对象。

DayDart.fromDateTime(new DateTime.now());

复制 #

DayDart 对象是不可变的,因此可以执行 .clone() 来获取一个 DayDart 对象的拷贝。

DayDart().clone();

验证 #

  • return bool

检测当前的 DayDart 对象是否是一个有效的时间。

DayDart().isValid();

获取 #

获取日期

#

  • return int

获取年份。

DayDart().year();

#

  • return int

获取月份

DayDart().month();

#

  • return int

获取日期。

DayDart().date();

星期 #

  • return int

获取星期。

DayDart().day();

#

  • return int

获取小时。

DayDart().hour();

#

  • return int

获取分钟。

DayDart().minute();

#

  • return int

获取秒。

DayDart().second();

毫秒 #

  • return int

获取毫秒。

DayDart().millisecond();

操作 #

我们可以对 DayDart 对象增加如下的操作:

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

增加 #

为时间日期进行增加并返回一个新的 DayDart 对象。

DayDart().add(2, Units.H);

减少 #

为时间日期进行减少并返回一个新的 DayDart 对象。

DayDart().subtract(13, Units.M)

查询 #

Value 系列比对详情如下:

enumOutput
Units.Ybool
Units.Mbool
Units.Dbool
Units.Hbool
Units.MINbool

是否相等 #

  • return bool

检查另外一个 DayDart 对象是否与当前 DayDart 对象的时间相等。

DayDart().isSame(daydart);
  • return bool
DayDart().isSameValue(2019, Units.Y);

是否之前 #

  • return bool

检查另外一个 DayDart 对象是否在当前 DayDart 对象时间之前。

DayDart().isBefore(daydart);
  • return bool
DayDart().isBeforeValue(2019, Units.Y);

是否之后 #

  • return bool

检查另外一个 DayDart 对象是否在当前 DayDart 对象时间之后。

DayDart().isAfter(daydart);
  • return bool
DayDart().isAfterValue(2019, Units.Y);

判断是否为 DayDart #

DayDart.isDayDart(daydart)

显示 #

格式化 DayDart 对象并展示。

格式化 #

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

详情如下:

FormatOutputDescription
YY19两位数的年份
YYYY2019四位数的年份
M1-12月份,从 1 开始
MM01-12月份,两位数
D1-31月份里的一天
DD01-31月份里的一天,两位数
H0-23小时
HH00-23小时,两位数
m0-59分钟
mm00-59分钟,两位数
s0-59
ss00-59秒,两位数
aam pm
AAM PM

DateTime 对象 #

  • return DateTime

返回原生 DateTime 对象

DayDart().toDateTime();

ISO 8601 字符串 #

  • return String

返回 ISO8601 格式的字符串。

DayDart().toISOString();

List #

  • return List

返回包含时间数值的 List。

DayDart().toList();

Map #

  • return Map<String, int>

返回包含时间数值的 Map。

DayDart().toMap();

字符串 #

  • return String
DayDart().toString();

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_daydart: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_daydart/flutter_daydart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
63
Health:
Code health derived from static analysis. [more]
86
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
40
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Aug 18, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/DayDart.dart. (-13.53 points)

Analysis of lib/src/DayDart.dart reported 29 hints, including:

line 43 col 3: Prefer using /// for doc comments.

line 50 col 3: Prefer using /// for doc comments.

line 57 col 3: Prefer using /// for doc comments.

line 64 col 3: Prefer using /// for doc comments.

line 71 col 3: Prefer using /// for doc comments.

Format lib/src/Units.dart.

Run flutter format to format lib/src/Units.dart.

Format lib/src/utils.dart.

Run flutter format to format lib/src/utils.dart.

Maintenance issues and suggestions

The description contains too many non-ASCII characters. (-20 points)

The site uses English as its primary language. The value of the description field in your package's pubspec.yaml field should primarily contain characters used in English.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and flutter_daydart.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test