这是indexloc提供的服务,不要输入任何密码
Skip to content

Methods using microsecond addition or subtraction do not work correctly on the web #31

@dsyrstad

Description

@dsyrstad

The web's DateTime object does not support microseconds, so calculations like the one done for endOfMonth:

DateTime get endOfMonth => DateTime(year, month + 1).subMicroseconds(1);

don't work correctly. It gets the next month and subtracts one microsecond, which ends up doing nothing on the web.

Example: If d is a DateTime representing 2024-01-05T23:52, then d.endOfMonth results in 2024-02-01T00:00:00, rather than the expected 2024-01-31T23:59:59.999.

Also, using local time by default (by constructing a new DateTIme not in utc), is probably a bad choice. If my original DateTime was in UTC, this will give incorrect results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions