public static GetCurrentDateTime ( ) : System.DateTime | ||
Résultat | System.DateTime |
/// <summary> /// Convert unix timestamp to date /// </summary> /// <param name="unixTimestap">unix to convert</param> /// <returns>datetime</returns> public static DateTime FromUnixTimestamp(this long unixTimestap) { try { return((new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(unixTimestap.TryParseDouble(0))); } catch (Exception e) { Debug.WriteLine(e); return(BaseDateTimeExtensions.GetCurrentDateTime()); } }
/// <summary> /// <para>Convert string date to datetime</para> /// <para>Return BaseDateTimeExtensions.GetCurrentDateTime() on error</para> /// </summary> /// <param name="strValue">string to convert</param> /// <returns>datetime</returns> public static DateTime TryParseDate(this string strValue) { return(strValue.TryParseDate(BaseDateTimeExtensions.GetCurrentDateTime(), BaseDateTimeExtensions.GetCurrentCulture(), BaseDateTimeExtensions.GetDefaultToDateDateTimeStyles())); }
/// <summary> /// <para>Convert string date to datetime</para> /// <para>Return BaseDateTimeExtensions.GetCurrentDateTime() on error</para> /// </summary> /// <param name="strValue">string to convert</param> /// <param name="culture">date culture</param> /// <param name="dateTimeStyle">datetime style</param> /// <returns>datetime</returns> public static DateTime TryParseDate(this string strValue, CultureInfo culture, DateTimeStyles dateTimeStyle) { return(strValue.TryParseDate(BaseDateTimeExtensions.GetCurrentDateTime(), culture, dateTimeStyle)); }
/// <summary> /// Convert nullable date to datetime /// </summary> /// <param name="nullableDate">nullable date to convert</param> /// <returns>datetime</returns> public static DateTime TryParseDate(this DateTime?nullableDate) { return(nullableDate.TryParseDate(BaseDateTimeExtensions.GetCurrentDateTime())); }