Skip to content

Fix TimeSpan example: incorrect output and logic bug#51535

Merged
meaghanlewis merged 4 commits intomainfrom
copilot/fix-timespan-example-issue
Feb 6, 2026
Merged

Fix TimeSpan example: incorrect output and logic bug#51535
meaghanlewis merged 4 commits intomainfrom
copilot/fix-timespan-example-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

The TimeSpan structure example showed incorrect output indicating a store closing at 21:30 was closed at 21:00, confusing readers about the example's behavior.

Changes

  • VB expected output: Corrected 21:00:00 and 18:31:00 from False to True (store hours are 8:00-21:30)
  • C# logic bug: Fixed bitwise AND & to logical AND && in time comparison
  • VB project file: Added Project.vbproj to enable building and testing the Visual Basic snippet
// Before
return time >= open & time <= close;

// After  
return time >= open && time <= close;

The bitwise operator happened to work for boolean values but was semantically incorrect.

Original prompt

This section details on the original issue you should resolve

<issue_title>Small issue or unclear part in TimeSpan example</issue_title>
<issue_description>In the second code snippet of the TimeSpan structure section, the example output says the store is closed at 21:00 when the store closing time is 21:30 and there is no indication of the local timezone being different from the store timezone.

Suggested solution is one or both of the following:

  • Print local timezone or offset in output to indicate whether it is different from the timezone or offset of the store
  • If the timezone is supposed to be the same in the example, change the "Store is open at 21:00:00: False" line to True because the store closing time is defined as 21:30

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Comments on the Issue (you are @copilot in this section)

@dotnet-bot This issue has been closed as part of the issue backlog grooming process outlined in #22351.

That automated process may have closed some issues that should be addressed. If you think this is one of them, reopen it with a comment explaining why. Tag the @dotnet/docs team for visibility.</comment_new>
<comment_new>@BillWagner
Thanks @TheRealMaxion I'll reopen.</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@dotnet-policy-service dotnet-policy-service bot added okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. labels Feb 5, 2026
Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix time conflict in TimeSpan example output Fix TimeSpan example: incorrect output and logic bug Feb 5, 2026
Copilot AI requested a review from meaghanlewis February 5, 2026 22:26
@meaghanlewis
Copy link
Contributor

@copilot please add a .vbproj (Visual Basic project file) in the samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.choosingdates/vb/ directory.

Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 5, 2026

@copilot please add a .vbproj (Visual Basic project file) in the samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.choosingdates/vb/ directory.

Added Project.vbproj file in commit b955181. The VB project now builds successfully.

@meaghanlewis meaghanlewis marked this pull request as ready for review February 5, 2026 23:08
@meaghanlewis meaghanlewis requested review from a team and BillWagner as code owners February 5, 2026 23:08
Copilot AI review requested due to automatic review settings February 5, 2026 23:08
@meaghanlewis meaghanlewis enabled auto-merge (squash) February 5, 2026 23:09
Copy link
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

This PR fixes a TimeSpan structure example that had incorrect expected output and a logic bug. The example demonstrates using TimeSpan to represent store opening hours (8:00-21:30).

Changes:

  • Corrected Visual Basic expected output comments to show True for 21:00:00 and 18:31:00, which are within store hours
  • Fixed C# code to use logical AND (&&) instead of bitwise AND (&) for boolean comparison
  • Added Project.vbproj file to enable building and testing the Visual Basic snippet

Reviewed changes

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

File Description
samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.choosingdates/vb/datetimereplacement1.vb Corrected expected output comments for 21:00 and 18:31 from False to True
samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.choosingdates/vb/Project.vbproj Added project file for building VB snippet, consistent with C# equivalent
samples/snippets/csharp/VS_Snippets_CLR/conceptual.choosingdates/cs/datetimereplacement1.cs Fixed bitwise AND operator to logical AND for proper boolean short-circuit evaluation

Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This LGTM as well.

…ngdates/vb/Project.vbproj

Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
@meaghanlewis meaghanlewis merged commit e60f575 into main Feb 6, 2026
11 checks passed
@meaghanlewis meaghanlewis deleted the copilot/fix-timespan-example-issue branch February 6, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Small issue or unclear part in TimeSpan example

5 participants