Update vor Umbau Service
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
@@ -40,5 +41,49 @@ namespace OnDocAPI_NetFramework.Helper
|
||||
|
||||
return lowerCase ? builder.ToString().ToLower() : builder.ToString();
|
||||
}
|
||||
|
||||
public static string NormalizeDateToSystemFormat(string input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
return input;
|
||||
|
||||
var culture = CultureInfo.CurrentCulture;
|
||||
|
||||
string[] knownFormats =
|
||||
{
|
||||
"yyyy-MM-dd",
|
||||
"yyyyMMdd",
|
||||
"dd.MM.yyyy",
|
||||
"d.M.yyyy",
|
||||
"dd/MM/yyyy",
|
||||
"MM/dd/yyyy",
|
||||
"yyyy-MM-ddTHH:mm:ss",
|
||||
"yyyy-MM-dd HH:mm:ss",
|
||||
"dd.MM.yyyy HH:mm:ss",
|
||||
"d.M.yyyy HH:mm:ss"
|
||||
};
|
||||
|
||||
DateTime date;
|
||||
|
||||
// 1. Exakte Formate
|
||||
if (DateTime.TryParseExact(
|
||||
input.Trim(),
|
||||
knownFormats,
|
||||
culture,
|
||||
DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.AssumeLocal,
|
||||
out date))
|
||||
{
|
||||
return date.ToString(culture.DateTimeFormat.ShortDatePattern, culture);
|
||||
}
|
||||
|
||||
// 2. Fallback: freie Erkennung
|
||||
if (DateTime.TryParse(input, culture, DateTimeStyles.AssumeLocal, out date))
|
||||
{
|
||||
return date.ToString(culture.DateTimeFormat.ShortDatePattern, culture);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user