aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.FileSystem/Network/CopyResponse.cs
blob: e22ce65421ffbb9933aa8e29d707e669db209197 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.FileSystem.Network
{
    public class CopyResponse
    {
    }
}
Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Globalization;
using System.Linq;

namespace MaterialDesignThemes.Wpf
{
	internal static class DateTimeEx
	{
		internal static DateTimeFormatInfo GetDateFormat(this CultureInfo culture)
		{
			if (culture == null) throw new ArgumentNullException(nameof(culture));

			if (culture.Calendar is GregorianCalendar)
			{
				return culture.DateTimeFormat;
			}
			
			GregorianCalendar foundCal = null;
			DateTimeFormatInfo dtfi = null;
			foreach (var cal in culture.OptionalCalendars.OfType<GregorianCalendar>())
			{
				// Return the first Gregorian calendar with CalendarType == Localized 
				// Otherwise return the first Gregorian calendar
				if (foundCal == null)
				{
					foundCal = cal;
				}

				if (cal.CalendarType != GregorianCalendarTypes.Localized) continue;

				foundCal = cal;
				break;
			}


			if (foundCal == null)
			{
				// if there are no GregorianCalendars in the OptionalCalendars list, use the invariant dtfi 
				dtfi = ((CultureInfo)CultureInfo.InvariantCulture.Clone()).DateTimeFormat;
				dtfi.Calendar = new GregorianCalendar();
			}
			else
			{
				dtfi = ((CultureInfo)culture.Clone()).DateTimeFormat;
				dtfi.Calendar = foundCal;
			}

			return dtfi;
		}
	}
}