示例#1
0
        public HawaiiDateTime AddYears(int value)
        {
            var dt = DateTime.Parse(Value);

            dt = dt.AddYears(value);
            return(HawaiiDateTime.Convert(dt.ToUniversalTime()));
        }
示例#2
0
        public HawaiiDateTime AddSeconds(double value)
        {
            var dt = DateTime.Parse(Value);

            dt = dt.AddSeconds(value);
            return(HawaiiDateTime.Convert(dt.ToUniversalTime()));
        }
示例#3
0
        public HawaiiDateTime AddMonths(int months)
        {
            var dt = DateTime.Parse(Value);

            dt = dt.AddMonths(months);
            return(HawaiiDateTime.Convert(dt.ToUniversalTime()));
        }
示例#4
0
 /// <summary>
 /// TryParse a datetime string to get the hawaii timezone
 /// </summary>
 public static bool TryParse(string dateTime, out HawaiiDateTime hawaiianDateTime)
 {
     try
     {
         hawaiianDateTime = Parse(dateTime);
         return(true);
     }
     catch (Exception ex)
     {
         hawaiianDateTime = default(HawaiiDateTime);
         return(false);
     }
 }
示例#5
0
        public HawaiiDateTime(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 HawaiiDateTime(Year, Month, Day);
            DayOfYear = Date.DayOfYear;
            DayOfWeek = Date.DayOfWeek;
        }
示例#6
0
        public HawaiiDateTime(long ticks)
        {
            var dateTime = new DateTime(ticks)
                           .ToUniversalTime()
                           .ToHawaii();

            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 HawaiiDateTime(Year, Month, Day);
            DayOfYear = Date.DayOfYear;
            DayOfWeek = Date.DayOfWeek;
        }
示例#7
0
        public HawaiiDateTime(TimeSpan timeOfDay)
        {
            var hawaiiNow = Now;

            Year  = hawaiiNow.Year;
            Month = hawaiiNow.Month;
            Day   = hawaiiNow.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 HawaiiDateTime(Year, Month, Day);
            DayOfYear = Date.DayOfYear;
            DayOfWeek = Date.DayOfWeek;
        }