29 lines
701 B
C#
29 lines
701 B
C#
namespace FamilyTreeAPI.Helper
|
|
{
|
|
public class Helpers
|
|
{
|
|
public static string? DateToStr(DateTime? date)
|
|
{
|
|
string? result = null;
|
|
if (date.HasValue)
|
|
{
|
|
result = date.Value.ToString("yyyy-MM-dd");
|
|
}
|
|
return result;
|
|
}
|
|
public static DateTime? DateToDateTime(string? date)
|
|
{
|
|
DateTime? result = null;
|
|
if (!string.IsNullOrEmpty(date))
|
|
{
|
|
DateTime dt;
|
|
if (DateTime.TryParse(date, out dt))
|
|
{
|
|
result = dt;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|