dotnet / dotnet/dotnet-api-docs
DateTimeOffset.Subtraction Remarks Example Contains Minor Discrepancy
- Lingua principale
- C#
- Stelle
- 950
- Fork
- 1.7k
- Merge medio
- 2g 19h
- PR unite (30g)
- 52
Descrizione
_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/DateTimeOffsetSubtraction-Remarks-Examp/10552416)._
---
[severity:It bothers me. A fix would be nice]
[DateTimeOffset.Subtraction](https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.op_subtraction?view=net-8.0#system-datetimeoffset-op-subtraction(system-datetimeoffset-system-datetimeoffset)) 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)
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Individua l'esempio della sezione Remarks dell'API DateTimeOffset.Subtraction nel repository dotnet-api-docs. Confronta il secondo calcolo e il relativo output previsto con l'esempio corretto dell'issue, quindi verifica che la documentazione renderizzata mostri la data di riferimento e l'output corrispondenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100