dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

DateTimeOffset.Subtraction Remarks Example Contains Minor Discrepancy

Open vsfeedback opened this issue 2 years ago • 0 comments

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice] DateTimeOffset.Subtraction Remarks section example has a minor discrepancy.

Original

difference = firstDate - thirdDate;
Console.WriteLine("({0}) - ({1}): {2} days, {3}:{4:d2}",
                  firstDate.ToString(),
                  secondDate.ToString(),
                  difference.Days,
                  difference.Hours,
                  difference.Minutes);
// The example produces the following output:
//    (3/25/2008 6:00:00 PM -07:00) - (3/25/2008 6:00:00 PM -05:00): 0 days, 2:00
//    (3/25/2008 6:00:00 PM -07:00) - (3/25/2008 6:00:00 PM -05:00): 26 days, 9:00

When calculating the difference the second time, the output uses secondDate where it should use thirdDate.

Updated

difference = firstDate - thirdDate;
Console.WriteLine("({0}) - ({1}): {2} days, {3}:{4:d2}",
                  firstDate.ToString(),
                  thirdDate.ToString(),
                  difference.Days,
                  difference.Hours,
                  difference.Minutes);
// The example produces the following output:
//    (3/25/2008 6:00:00 PM -07:00) - (3/25/2008 6:00:00 PM -05:00): 0 days, 2:00
//    (3/25/2008 6:00:00 PM -07:00) - (2/28/2008 9:00:00 PM -07:00): 26 days, 9:00

Original Comments

Feedback Bot on 1/3/2024, 05:51 PM:

(private comment, text removed)


Original Solutions

(no solutions)

vsfeedback avatar Jan 10 '24 17:01 vsfeedback