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

issue-46477 Fix issue about checking last char in datetime string. #46614

Conversation

lateapexearlyspeed
Copy link
Contributor

Fix #46477


Assert.Throws<FormatException>(() => DateTime.Parse("2020-5-7T09:37:00.0000000-07:00c"));
Assert.Throws<FormatException>(() => DateTime.Parse("2020-5-7T09:37:00.0000000-07:00c", new MyFormatter()));
Assert.Throws<FormatException>(() => DateTime.Parse("2020-5-7T09:37:00.0000000-07:00c", new MyFormatter(), DateTimeStyles.NoCurrentDateDefault));
Copy link
Member

@danmoseley danmoseley Jan 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should continue to work (per the strange treatment of # and \0), so you might want to add a test to prove they were not broken by your change:
2020-5-7T09:37:00.0000000+00:00\0
#2020-5-7T09:37:00.0000000+00:00#
#2020-5-7T09:37:00.0000000+00:00#\0
I only see tests for these without the timezone part.
These should still fail and aren't tested
2020-5-7T09:37:00.0000000+00:00#
2020-5-7T09:37:00.0000000+00:00#\0

I think your fix is good though - thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second @danmosemsft for adding more test cases for valid formats. Also, please ensure adding cases when there is nothing at the end too. something like 2020-5-7T09:37:00.0000000-07:00

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danmosemsft @tarekgh Fixed, please review, thanks.

@tarekgh
Copy link
Member

tarekgh commented Jan 8, 2021

@lateapexearlyspeed did you have a chance to address the feedback on this PR?

@lateapexearlyspeed
Copy link
Contributor Author

@tarekgh Sorry I am little busy these days, will fix those comment these days.

@tarekgh
Copy link
Member

tarekgh commented Jan 8, 2021

@lateapexearlyspeed no problem and thanks again for helping with this one.

@tarekgh
Copy link
Member

tarekgh commented Jan 11, 2021

The failure in this PR is unrelated and tracked by the linked issue #32805

Copy link
Member

@tarekgh tarekgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lateapexearlyspeed for getting this fixed.

@tarekgh tarekgh merged commit 4848f51 into dotnet:master Jan 11, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Feb 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DateTime.Parse ISO 8601 allowing extra arbitrary character at the end of the date
5 participants