Base datetime extensions default data
        /// <summary>
        /// Convert date to an especific timezone
        /// </summary>
        /// <param name="date">date to convert</param>
        /// <param name="currentTimeZoneName">current date timezone name</param>
        /// <param name="destinationTimeZoneName">destination date timezone name</param>
        /// <returns>date on especific timezone</returns>
        public static DateTime ToTimezoneDate(this DateTime date, string currentTimeZoneName, string destinationTimeZoneName)
        {
            var currentTimezone     = BaseDateTimeExtensions.GetTimezoneInfo(currentTimeZoneName);
            var destinationTimezone = BaseDateTimeExtensions.GetTimezoneInfo(destinationTimeZoneName);

            return(date.ToTimezoneDate(currentTimezone, destinationTimezone));
        }
 /// <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>
 /// <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>
 /// <para>Get the week number of a date</para>
 /// <para>Use BaseDateTimeExtensions.GetDefaultCalendarRule() as default calendar rule</para>
 /// <para>Use BaseDateTimeExtensions.GetDefaultFirstWeekDay() as first week day</para>
 /// </summary>
 /// <param name="date">Date to get week number</param>
 /// <returns>Week number or -1 when error</returns>
 public static int GetWeekNumber(this DateTime date)
 {
     return(date.GetWeekNumber(BaseDateTimeExtensions.GetDefaultCalendarRule(),
                               BaseDateTimeExtensions.GetDefaultFirstWeekDay()));
 }
 /// <summary>
 /// <para>Get the week number of a date</para>
 /// <para>Use BaseDateTimeExtensions.GetDefaultCalendarRule() as default calendar rule</para>
 /// </summary>
 /// <param name="date">Date to get week number</param>
 /// <param name="firstWeekDay">First day of week</param>
 /// <returns>Week number or -1 when error</returns>
 public static int GetWeekNumber(this DateTime date, DayOfWeek firstWeekDay)
 {
     return(date.GetWeekNumber(BaseDateTimeExtensions.GetDefaultCalendarRule(), firstWeekDay));
 }
 /// <summary>
 /// <para>Get the week number of a date</para>
 /// <para>Use BaseDateTimeExtensions.GetDefaultFirstWeekDay() as  first week day</para>
 /// </summary>
 /// <param name="date">Date to get week number</param>
 /// <param name="weekRule">Rule to calculate week number</param>
 /// <returns>Week number or -1 when error</returns>
 public static int GetWeekNumber(this DateTime date, CalendarWeekRule weekRule)
 {
     return(date.GetWeekNumber(weekRule, BaseDateTimeExtensions.GetDefaultFirstWeekDay()));
 }
        /// <summary>
        /// Convert date to an especific timezone
        /// </summary>
        /// <param name="date">date to convert</param>
        /// <param name="destinationTimeZoneName">destination date timezone name</param>
        /// <returns>date on especific timezone</returns>
        public static DateTime ToTimezoneDate(this DateTime date, string destinationTimeZoneName)
        {
            var destinationTimezone = BaseDateTimeExtensions.GetTimezoneInfo(destinationTimeZoneName);

            return(date.ToTimezoneDate(BaseDateTimeExtensions.GetDefaultTimezoneInfo(), destinationTimezone));
        }
 /// <summary>
 /// Convert date to an especific timezone
 /// </summary>
 /// <param name="date">date to convert</param>
 /// <param name="destinationTimeZoneInfo">destination date timezone info</param>
 /// <returns>date on especific timezone</returns>
 public static DateTime ToTimezoneDate(this DateTime date, TimeZoneInfo destinationTimeZoneInfo)
 {
     return(date.ToTimezoneDate(BaseDateTimeExtensions.GetDefaultTimezoneInfo(), destinationTimeZoneInfo));
 }
        /// <summary>
        /// Convert date to unix timestamp
        /// </summary>
        /// <param name="date">date to convert</param>
        /// <returns>unix timestamp</returns>
        public static long ToUnixTimestamp(this DateTime date)
        {
            var timezoneInfo = BaseDateTimeExtensions.GetDefaultTimezoneInfo();

            return(date.ToUnixTimestamp(timezoneInfo));
        }
        /// <summary>
        /// Convert date to unix timestamp
        /// </summary>
        /// <param name="date">date to convert</param>
        /// <param name="timezoneName">current date timezone name</param>
        /// <returns>unix timestamp</returns>
        public static long ToUnixTimestamp(this DateTime date, string timezoneName)
        {
            var timezoneInfo = BaseDateTimeExtensions.GetTimezoneInfo(timezoneName);

            return(date.ToUnixTimestamp(timezoneInfo));
        }
        /// <summary>
        /// Convert date to UtcDate
        /// </summary>
        /// <param name="date">date to convert</param>
        /// <returns>utc date</returns>
        public static DateTime ToUtc(this DateTime date)
        {
            var timezoneInfo = BaseDateTimeExtensions.GetDefaultTimezoneInfo();

            return(date.ToUtc(timezoneInfo));
        }
        /// <summary>
        /// Convert date to UtcDate
        /// </summary>
        /// <param name="date">date to convert</param>
        /// <param name="timezoneName">current date timezone name</param>
        /// <returns>utc date</returns>
        public static DateTime ToUtc(this DateTime date, string timezoneName)
        {
            var timezoneInfo = BaseDateTimeExtensions.GetTimezoneInfo(timezoneName);

            return(date.ToUtc(timezoneInfo));
        }
 /// <summary>
 /// Test if string value is a valid date value
 /// </summary>
 /// <param name="strValue">string value</param>
 /// <returns>true/false</returns>
 public static bool IsValidDate(this string strValue)
 {
     return(strValue.IsValidDate(
                BaseDateTimeExtensions.GetCurrentCulture(),
                BaseDateTimeExtensions.GetDefaultToDateDateTimeStyles()));
 }
 /// <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()));
 }