//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Globalization;

#if !WASM
namespace CommonHelpers {
#else
namespace CommonHelpers.WASM {
#endif

//**************************************************************************************************
public static partial class HDateTime {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static DateTime Parse(string src)
   { return HValueParser.Parse<DateTime>(src,new object[0]); }
public static DateTime Parse(string src,DateTime def)
   { return HValueParser.Parse<DateTime>(src,new object[0],def); }

public static DateTime Parse(string src,IFormatProvider provider)
   { return HValueParser.Parse<DateTime>(src,new object[]{provider}); }
public static DateTime Parse(string src,IFormatProvider provider,DateTime def)
   { return HValueParser.Parse<DateTime>(src,new object[]{provider},def); }

public static DateTime Parse(string src,IFormatProvider provider,DateTimeStyles styles)
   { return HValueParser.Parse<DateTime>(src,new object[]{provider,styles}); }
public static DateTime Parse( string src, IFormatProvider provider,
                              DateTimeStyles styles, DateTime def )
   { return HValueParser.Parse<DateTime>(src,new object[]{provider,styles},def); }

//--------------------------------------------------------------------------------------------------

public static DateTime ParseInvariant(string src)
{
   return HValueParser.Parse<DateTime>(src,new object[]{DateTimeFormatInfo.InvariantInfo});
}

public static DateTime ParseInvariant(string src,DateTime def)
{
   return HValueParser.Parse<DateTime>(src,new object[]{DateTimeFormatInfo.InvariantInfo},def);
}

//==================================================================================================

public static DateTime ParseExact(string src,string format)
   { return ParseExactEx(src,format,null); }
public static DateTime ParseExact(string src,string format,DateTime def)
   { return ParseExactEx(src,format,null,def); }

public static DateTime ParseExact(string src,string format,IFormatProvider provider)
   { return ParseExactEx(src,format,new object[]{provider}); }
public static DateTime ParseExact( string src, string format,
                                   IFormatProvider provider, DateTime def )
   { return ParseExactEx(src,format,new object[]{provider},def); }

public static DateTime ParseExact( string src, string format,
                                   IFormatProvider provider, DateTimeStyles styles )
{
   return ParseExactEx(src,format,new object[]{provider,styles});
}

public static DateTime ParseExact( string src, string format, IFormatProvider provider,
                                   DateTimeStyles styles, DateTime def )
{
   return
      ParseExactEx(src,format,new object[]{provider,styles},def);
}

//--------------------------------------------------------------------------------------------------

public static DateTime ParseExactInvariant(string src,string format)
{
   return ParseExactEx(
      src, format, new object[]{DateTimeFormatInfo.InvariantInfo} );
}

public static DateTime ParseExactInvariant(string src,string format,DateTime def)
{
   return ParseExactEx(
      src, format, new object[]{DateTimeFormatInfo.InvariantInfo}, def );
}

//==================================================================================================

static DateTime ParseExactEx(string src,string format,object[] additionalParams)
{
   return ParseExactEx(src,format,additionalParams,null);
}

static DateTime ParseExactEx( string src, string format, object[] additionalParams,
                              DateTime? def )
{
   DateTime result;
   HParseValueException e;
   if (!TryParseExactEx(src,format,additionalParams,def,out result,out e))
      throw e;
   return result;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HDateTime
//**************************************************************************************************

} // CommonHelpers (.WASM)
