- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
void parseDate(String str, ref int day, ref int month, ref int year)
{
String[] strings = str.Split('/');
day = Int32.Parse(strings[0]);
month = Int32.Parse(strings[1]);
year = Int32.Parse(strings[2]);
}
bool validateDate(String s)
{
//let the data be null
if (s == null || s == "")
return true;
try
{
String[] strings = s.Split('/');
if (strings.Length != 3)
return false;
String day = strings[0];
if (Int32.Parse(day) > 31)
{
return false;
}
String month = strings[1];
if (Int32.Parse(month) > 12)
{
return false;
}
String year = strings[2];
if (year.Length != 4)
{
return false;
}
}
catch (SystemException)
{
return false;
}
return true;
}
int compareDates(String s1, String s2)
{
if (s1 == "" && s2 != "")
return -1;
if (s1 == s2)
return 0;
if (s1 != "" && s2 == "")
return 1;
int day1 = 0, month1 = 0, year1 = 0, day2 = 0, month2 = 0, year2 = 0;
parseDate(s1, ref day1, ref month1, ref year1);
parseDate(s2, ref day2, ref month2, ref year2);
if (year1 > year2)
return -1;
if (year1 < year2)
return 1;
if (month1 > month2)
return -1;
if (month2 < month1)
return 1;
if (day1 > day2)
return -1;
if (day2 > day1)
return 1;
return 0;
}