migrate + ปรับสอบแข่งขัน (#6)
Co-authored-by: harid <harid_pr61@live.rmutl.com>
This commit is contained in:
parent
9332086ee9
commit
6e9fb4b368
7 changed files with 1839 additions and 110 deletions
|
|
@ -460,13 +460,13 @@ namespace BMA.EHR.Recruit.Service.Services
|
|||
if (!string.IsNullOrWhiteSpace(road)) parts.Add($"ถนน {road}");
|
||||
return string.Join(" ", parts);
|
||||
}
|
||||
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))
|
||||
|
|
@ -484,7 +484,7 @@ namespace BMA.EHR.Recruit.Service.Services
|
|||
string[] parts = Date.Trim().Replace("-", "/").Split("/");
|
||||
|
||||
if (parts.Length != 3)
|
||||
return DateTime.MinValue;
|
||||
return null;
|
||||
|
||||
int year;
|
||||
int month;
|
||||
|
|
@ -498,14 +498,14 @@ namespace BMA.EHR.Recruit.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;
|
||||
|
||||
|
|
@ -516,18 +516,18 @@ namespace BMA.EHR.Recruit.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;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (month < 1 || month > 12)
|
||||
|
|
@ -540,13 +540,13 @@ namespace BMA.EHR.Recruit.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}";
|
||||
if (DateTime.TryParseExact(normalDate, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime parsedDate))
|
||||
{
|
||||
return parsedDate;
|
||||
}
|
||||
|
||||
return DateTime.MinValue;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue