C#判断日期是否合法

static bool ValidateDate(int y, int m, int d)
{
    int[] a = { 31, (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    return m >= 1 && m <= 12 && d >= 1 && d <= a[m - 1];
}

转自:http://outofmemory.cn/code-snippet/4892/C-decide-nian-yueri-shifou-hefa
posted @ 2019-09-09 10:21  夜月之光  阅读(797)  评论(0编辑  收藏  举报