Skip to content

DateTime.difference() documentation could be clearer; why not have operator-? #36347

@jamesderlin

Description

@jamesderlin

The documentation to DateTime.difference could be clearer about how the difference is computed. That is, instead of :

Returns a [Duration] with the difference between [this] and [other].

I think it'd be better as:

Returns a [Duration] with the difference subtracting [other] from [this].

Or instead of relying on readers to deduce it from the example code, explicitly state:

The returned [Duration] will be negative if [other] occurs after [this].

Even better would be to provide an operator - that allows one DateTime to be subtracted from the other without ambiguity.

(Dart VM version: 2.1.0 (Tue Nov 13 18:22:02 2018 +0100) on "linux_x64")

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-coretype-documentationA request to add or improve documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions