public static Date fromStr(string s, bool check)
{
try
{
// YYYY-MM-DD
int year = num(s, 0) * 1000 + num(s, 1) * 100 + num(s, 2) * 10 + num(s, 3);
int month = num(s, 5) * 10 + num(s, 6) - 1;
int day = num(s, 8) * 10 + num(s, 9);
// check separator symbols
if (s[4] != '-' || s[7] != '-' || s.Length != 10)
{
throw new System.Exception();
}
return(new Date(year, month, day));
}
catch (System.Exception)
{
if (!check)
{
return(null);
}
throw ParseErr.make("Date", s).val;
}
}