public PacificDateTime AddYears(int value)
        {
            var dt = DateTime.Parse(Value);

            dt = dt.AddYears(value);
            return(PacificDateTime.Convert(dt.ToUniversalTime()));
        }
        public PacificDateTime AddSeconds(double value)
        {
            var dt = DateTime.Parse(Value);

            dt = dt.AddSeconds(value);
            return(PacificDateTime.Convert(dt.ToUniversalTime()));
        }
        public PacificDateTime AddMonths(int months)
        {
            var dt = DateTime.Parse(Value);

            dt = dt.AddMonths(months);
            return(PacificDateTime.Convert(dt.ToUniversalTime()));
        }
 /// <summary>
 /// TryParse a datetime string to get the pacific timezone
 /// </summary>
 public static bool TryParse(string dateTime, out PacificDateTime pacificDateTime)
 {
     try
     {
         pacificDateTime = Parse(dateTime);
         return(true);
     }
     catch (Exception ex)
     {
         pacificDateTime = default(PacificDateTime);
         return(false);
     }
 }
        public PacificDateTime(int year, int month, int day, int hour, int minute, int second)
        {
            Year   = year;
            Month  = month;
            Day    = day;
            Hour   = hour;
            Minute = minute;
            Second = second;

            var dateTimeParse =
                DateTime.Parse(string.Concat(Year, "-", Month.ToString("00"), "-", Day.ToString("00"), "T", Hour.ToString("00"), ":", Minute.ToString("00"), ":", Second.ToString("00"), "Z"))
                .ToUniversalTime();

            Offset = dateTimeParse.IsInDaylightSavingsTime() ? DaylightOffset : StandardOffset;

            Date      = new PacificDateTime(Year, Month, Day);
            DayOfYear = Date.DayOfYear;
            DayOfWeek = Date.DayOfWeek;
        }
        public PacificDateTime(long ticks)
        {
            var dateTime = new DateTime(ticks)
                           .ToUniversalTime()
                           .ToPacific();

            Year        = dateTime.Year;
            Month       = dateTime.Month;
            Day         = dateTime.Day;
            Hour        = dateTime.Hour;
            Minute      = dateTime.Minute;
            Second      = dateTime.Second;
            Millisecond = dateTime.Millisecond;

            Offset = dateTime.IsInDaylightSavingsTime() ? DaylightOffset : StandardOffset;

            Date      = new PacificDateTime(Year, Month, Day);
            DayOfYear = Date.DayOfYear;
            DayOfWeek = Date.DayOfWeek;
        }
        public PacificDateTime(TimeSpan timeOfDay)
        {
            var pacificNow = DateTime.UtcNow.ToPacific();

            Year  = pacificNow.Year;
            Month = pacificNow.Month;
            Day   = pacificNow.Day;

            Hour        = timeOfDay.Hours;
            Minute      = timeOfDay.Minutes;
            Second      = timeOfDay.Seconds;
            Millisecond = timeOfDay.Milliseconds;

            var dateTimeParse =
                DateTime.Parse(string.Concat(Year, "-", Month.ToString("00"), "-", Day.ToString("00"), "T", Hour.ToString("00"), ":", Minute.ToString("00"), ":", Second.ToString("00"), ".", Millisecond.ToString("00"), "Z"))
                .ToUniversalTime();

            Offset = dateTimeParse.IsInDaylightSavingsTime() ? DaylightOffset : StandardOffset;

            Date      = new PacificDateTime(Year, Month, Day);
            DayOfYear = Date.DayOfYear;
            DayOfWeek = Date.DayOfWeek;
        }