migrate + ปรับสอบคัดเลือกผู้พิการ (#3)

Co-authored-by: harid <harid_pr61@live.rmutl.com>
This commit is contained in:
Harid Promsri 2025-10-16 15:57:31 +07:00 committed by GitHub
parent b296304697
commit ecd794a070
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 6533 additions and 114 deletions

View file

@ -64,13 +64,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
return valid;
}
public DateTime CheckDateTime(string Date, string Formate)
public DateTime? CheckDateTime(string Date, string Formate)
{
// ตอนนี้ทำไว้ให้รองรับแค่ "dd/MM/yyyy", "yyyy-MM-dd"
Date = Date.Trim();
if (string.IsNullOrWhiteSpace(Date))
return DateTime.MinValue;
return null;
// จะเข้าเฉพาะกรณีที่ string เป็นตัวเลข เช่น "35635", "44561.5"
if (double.TryParse(Date, out double oaDate))
@ -88,7 +88,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
string[] parts = Date.Trim().Replace("-", "/").Split("/");
if (parts.Length != 3)
return DateTime.MinValue;
return null;
int year;
int month;
@ -102,14 +102,14 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
}
else if (!int.TryParse(parts[2], out year))
{
return DateTime.MinValue;
return null;
}
if (!int.TryParse(parts[1], out month))
return DateTime.MinValue;
return null;
if (!int.TryParse(parts[0], out day))
return DateTime.MinValue;
return null;
break;
@ -120,18 +120,18 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
}
else if (!int.TryParse(parts[0], out year))
{
return DateTime.MinValue;
return null;
}
if (!int.TryParse(parts[1], out month))
return DateTime.MinValue;
return null;
if (!int.TryParse(parts[2], out day))
return DateTime.MinValue;
return null;
break;
default:
return DateTime.MinValue;
default:
return null;
}
if (month < 1 || month > 12)
@ -144,13 +144,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
else if (day > maxDay)
day = maxDay;
var normalDate = $"{day}/{(month >= 1 && month <= 9 ? $"0{month}" : month)}/{year}";
var normalDate = $"{(day >= 1 && day <= 9 ? $"0{day}" : day)}/{(month >= 1 && month <= 9 ? $"0{month}" : month)}/{(year > 2500 ? year-543 : year)}";
if (DateTime.TryParseExact(normalDate, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime parsedDate))
{
return parsedDate;
}
return DateTime.MinValue;
return null;
}
}
}