Created
July 3, 2019 10:11
-
-
Save ParmanBabra/ab9a95793f67b3edbd3096f9b335c365 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsOverlapped(string start1, string end1, string start2, string end2) | |
{ | |
CultureInfo enUS = new CultureInfo("en-US"); | |
DateTime dateStart1, dateEnd1, dateStart2, dateEnd2; | |
string dateFormat = "yyyymmdd"; | |
if (!DateTime.TryParseExact(start1, dateFormat, enUS, DateTimeStyles.None, out dateStart1)) | |
throw new ArgumentException(nameof(start1) + "is wrong format"); | |
if (!DateTime.TryParseExact(end1, dateFormat, enUS, DateTimeStyles.None, out dateEnd1)) | |
throw new ArgumentException(nameof(end1) + "is wrong format"); | |
if (!DateTime.TryParseExact(start2, dateFormat, enUS, DateTimeStyles.None, out dateStart2)) | |
throw new ArgumentException(nameof(start2) + "is wrong format"); | |
if (!DateTime.TryParseExact(end2, dateFormat, enUS, DateTimeStyles.None, out dateEnd2)) | |
throw new ArgumentException(nameof(end2) + "is wrong format"); | |
return dateStart1 <= dateEnd2 && dateStart2 <= dateEnd1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment