c# - Unexpected DateTime Range Scenario -


i hate dates. i'm maintaining project , came across extension method bit naive, should trick in 99% of cases. checking date range:

public static bool isinrange(this datetime datetocheck, datetime startdate, datetime enddate) {     if (startdate <= enddate)     {         return datetocheck >= startdate && datetocheck <= enddate;     }      return false; } 

so have situation baffling me. return statement in if scope returning true when datetocheck after enddate. see following screen grab debugging values:

enter image description here

i considered fact may have different datetimekind, added following statement ensure both local:

datetime.specifykind(datetocheck, datetimekind.local)   

i unable reproduce in console application.

so guess question is, heck!?

if check datetocheck variable closely, year 1917 smaller 2017(enddate year 2017). so, it's working expected far can see.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -