c# parsing datetime from string irrespctive of culture

91

c# parsing datetime from string irrespctive of culture -

CultureInfo.GetCultures(CultureTypes.AllCultures).Select(culture => {
    DateTime result;
    return DateTime.TryParse(
        "8 avril 2016 vendredi", 
        culture, 
        DateTimeStyles.None, 
        out result
    ) ? result : default(DateTime?);
})
.Where(d => d != null)
.GroupBy(d => d)
.OrderByDescending(g => g.Count())
.FirstOrDefault()
.Key

Comments

Submit
0 Comments