Uh oh!
There was an error while loading. Please reload this page.
Csharp: Fix typo in LeapYear qhelp - #20436
Conversation
Corrects "add/substract" to "add/subtract" in the UnsafeYearConstruction.qhelp file to improve clarity.
| <p>In this example, we are incrementing/decrementing the current date by one year when creating a new <code>System.DateTime</code> object. This may work most of the time, but on any given February 29th, the resulting value will be invalid.</p> | ||
| <sample src="UnsafeYearConstructionBad.cs" /> | ||
| <p>To fix this bug, we add/substract years to the current date by calling <code>AddYears</code> method on it.</p> | ||
| <p>To fix this bug, we add/subtract years to the current date by calling <code>AddYears</code> method on it.</p> |
There was a problem hiding this comment.
The typo has been correctly fixed from 'substract' to 'subtract'.
QHelp previews: csharp/ql/src/Likely Bugs/LeapYear/UnsafeYearConstruction.qhelpUnsafe year argument for 'DateTime' constructorWhen creating a On a leap year, such code may throw an RecommendationCreating a ExampleIn this example, we are incrementing/decrementing the current date by one year when creating a new usingSystem;publicclassUnsafeYearConstructionBad{publicUnsafeYearConstructionBad(){DateTimeStart;DateTimeEnd;varnow=DateTime.UtcNow;// the base-date +/- n years may not be a valid date.Start=newDateTime(now.Year-1,now.Month,now.Day,0,0,0,DateTimeKind.Utc);End=newDateTime(now.Year+1,now.Month,now.Day,0,0,1,DateTimeKind.Utc);}}To fix this bug, we add/subtract years to the current date by calling usingSystem;publicclassUnsafeYearConstructionGood{publicUnsafeYearConstructionGood(){DateTimeStart;DateTimeEnd;varnow=DateTime.UtcNow;Start=now.AddYears(-1).Date;End=now.AddYears(-1).Date.AddSeconds(1);}}References |
Uh oh!
There was an error while loading. Please reload this page.
This PR corrects a typo in the UnsafeYearConstruction.qhelp file where "add/substract" is changed to "add/subtract".