Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dsyrstad opened this issue Jan 5, 2024 · 0 comments

Comments

@dsyrstad
Copy link

dsyrstad commented Jan 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant