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

fix: Support nanosecond precision as far as possible with DateTimeOffset #2578

Closed
wants to merge 1 commit into from

Conversation

jskeet
Copy link
Collaborator

@jskeet jskeet commented Oct 27, 2023

This fixes #2575, for both parsing and formatting. It does mean that x.CreateTimestamp = x.CreateTimestamp potentially loses information (2023-10-27T10:32:45.123456789Z would become 2023-10-27T10:32:45.123456700Z) but that's the best we can do.

This doesn't change the DateTime handling at all; it's still brokenly-culture-sensitive, and only formats to millisecond precision. The generated DateTime properties are now obsolete though, so it's probably best to leave them as they are.

@jskeet jskeet added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 27, 2023
@jskeet jskeet requested a review from a team as a code owner October 27, 2023 10:35
@jskeet
Copy link
Collaborator Author

jskeet commented Oct 27, 2023

I've marked this as "do not merge" because we need to get confirmation that this is what we want to happen, rather than changing the service implementation.

Copy link
Contributor

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

Yep, this looks good.

_ => ThrowFormatException()
};

// If we receive "2023-
Copy link
Contributor

Choose a reason for hiding this comment

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

Incomplete comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

public void GetDateTimeOffsetFromString_Invalid(string input) =>
Assert.Throws<FormatException>(() => Utilities.GetDateTimeOffsetFromString(input));

// Not on formatting for tick-of-second for the theory data in the following tests:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Not on formatting for tick-of-second for the theory data in the following tests:
// Note on formatting for tick-of-second for the theory data in the following tests:

This fixes googleapis#2575, for both parsing and formatting. It does mean
that `x.CreateTimestamp = x.CreateTimestamp` potentially loses
information (2023-10-27T10:32:45.123456789Z would become
2023-10-27T10:32:45.123456700Z) but that's the best we can do.

This doesn't change the DateTime handling at all; it's still
brokenly-culture-sensitive, and only formats to millisecond
precision. The generated DateTime properties are now obsolete
though, so it's probably best to leave them as they are.
@DayLightDancer
Copy link

Hi,
When you expect this PR to be merged?

@jskeet
Copy link
Collaborator Author

jskeet commented Nov 2, 2023

@DayLightDancer: We're still confirming exactly what the position is. Given #2580, I'm actually looking at a bigger change (moving this implementation to some new methods).

I wouldn't personally expect this to be fixed within the next week - there's a fair amount to coordinate, even when we've confirmed the situation. I would suggest just parsing the raw-suffixed property for now.

@jskeet
Copy link
Collaborator Author

jskeet commented Nov 8, 2023

We'll be using #2595 to address this instead.

@jskeet jskeet closed this Nov 8, 2023
@jskeet
Copy link
Collaborator Author

jskeet commented Nov 8, 2023

(Don't worry @DayLightDancer , it's still very much going ahead - just in a slightly different form.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Indicates a pull request not ready for merge, due to either quality or timing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem while accessing the new XXXDateTimeOffset fields
3 participants