Skip to content

DateTime addDays #53729

Open
Open
@Magnuti

Description

@Magnuti

This is a feature request for a method that can add whole days without being affected by daylight savings.

The DateTime add(Duration duration) method adds seconds. Several issues have been created where developers are confused about the behaviour of the method #37449.

image

The DateTime API is well documented, but the question on how to add days without being affected by daylight savings is not well documented. This is also causing issues in third party packages like jiffy jama5262/jiffy#81

Could we either

  • Update the documentation to specify how to add whole days, for example like this DateTime newDate = DateTime(date.year, date.month, date.day + days); (I don't even know if this is the correct way to do it, some StackOverflow posts mentions that solution)
  • Get a new method, for example DateTime addDays(int days) which is not affected by daylight savings

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-documentationPrefer using 'type-documentation' and a specific area label.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions