Skip to content

Update TimeOnly ToXmlString to include time zone offset#44

Merged
GregoryNikolaishvili merged 3 commits intomainfrom
bugfix/TimeOnlyTimezone
Mar 30, 2026
Merged

Update TimeOnly ToXmlString to include time zone offset#44
GregoryNikolaishvili merged 3 commits intomainfrom
bugfix/TimeOnlyTimezone

Conversation

@GregoryNikolaishvili
Copy link
Copy Markdown
Contributor

@GregoryNikolaishvili GregoryNikolaishvili commented Mar 30, 2026

  • Change ToXmlString(TimeOnly) to output "HH:mm:sszzz" with local offset (DST-safe)
  • Update unit test to match new format with time zone info
  • Bump Verify.Xunit package to v31.12.5
  • Fix XML doc comment to say "HH:mm:sszzz" instead of "HH:mm:ss"
  • Improve test to assert the offset suffix matches the actual local offset

- Change ToXmlString(TimeOnly) to output "HH:mm:sszzz" with local offset
- Update unit test to match new format with time zone info
- Bump Verify.Xunit package to v31.12.5
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates TimeOnly.ToXmlString() output to include a time zone offset, aligns the unit test with the new format, and bumps the Verify.Xunit dependency.

Changes:

  • Change ToXmlString(TimeOnly) to format as HH:mm:sszzz using a DateTimeOffset.
  • Update the corresponding unit test to accept the new offset-bearing format.
  • Bump Verify.Xunit package version to 31.12.5.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/AltaSoft.DomainPrimitives/ToXmlStringExt.cs Updates TimeOnly XML serialization to include a time zone offset.
tests/AltaSoft.DomainPrimitives.XmlDataTypes.Tests/ToXmlStringExtTests.cs Adjusts the TimeOnly formatting assertion for offset output.
Directory.Packages.props Updates Verify.Xunit version used by tests.

Comment on lines 33 to 35
/// <summary>
/// Converts a <see cref="TimeOnly" /> value to its XML string representation in the format "HH:mm:ss".
/// </summary>
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The XML doc comment still states the TimeOnly XML format is "HH:mm:ss", but the implementation now returns "HH:mm:sszzz" (includes a time zone offset). Update the summary (and any referenced format text) so the documentation matches the new behavior.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done in 79a6b3a. Updated the XML doc comment to say "HH:mm:sszzz" and also strengthened the test to verify the offset suffix matches the actual current local offset (not just the format shape).

Comment on lines 23 to 28
public void TimeOnly_ToXmlString_ReturnsExpectedFormat()
{
var t = new TimeOnly(13, 45, 30);
var xml = t.ToXmlString();
Assert.Equal("13:45:30", xml);
Assert.Matches(@"^13:45:30(?:Z|[+-]\d{2}:\d{2})$", xml);
}
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

The test only validates the output shape via regex; it doesn’t confirm the offset is actually the local offset. If the intended behavior is specifically “local offset”, consider asserting the suffix equals the current local offset string (e.g., derived from DateTimeOffset.Now) once the production code derives the offset from “now” rather than from an arbitrary local date/time.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

GregoryNikolaishvili and others added 2 commits March 30, 2026 14:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/altasoft/DomainPrimitives/sessions/5b0d89b2-92b7-4b7f-8c6c-75dfa3befa56

Co-authored-by: GregoryNikolaishvili <25057879+GregoryNikolaishvili@users.noreply.github.com>
@GregoryNikolaishvili GregoryNikolaishvili merged commit c461f1d into main Mar 30, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

4 participants