Esempio n. 1
0
        public CentralDateTime AddYears(int value)
        {
            var dt = DateTime.Parse(Value);

            dt = dt.AddYears(value);
            return(CentralDateTime.Convert(dt.ToUniversalTime()));
        }
Esempio n. 2
0
        public CentralDateTime AddSeconds(double value)
        {
            var dt = DateTime.Parse(Value);

            dt = dt.AddSeconds(value);
            return(CentralDateTime.Convert(dt.ToUniversalTime()));
        }
Esempio n. 3
0
        public CentralDateTime AddMonths(int months)
        {
            var dt = DateTime.Parse(Value);

            dt = dt.AddMonths(months);
            return(CentralDateTime.Convert(dt.ToUniversalTime()));
        }
Esempio n. 4
0
 /// <summary>
 /// TryParse a datetime string to get the central timezone
 /// </summary>
 public static bool TryParse(string dateTime, out CentralDateTime centralDateTime)
 {
     try
     {
         centralDateTime = Parse(dateTime);
         return(true);
     }
     catch (Exception ex)
     {
         centralDateTime = default(CentralDateTime);
         return(false);
     }
 }
Esempio n. 5
0
        public CentralDateTime(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, "-", Day, "T", Hour.ToString("00"), ":", Minute.ToString("00"), ":", Second.ToString("00"), "Z"))
                .ToUniversalTime();

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

            Date      = new CentralDateTime(Year, Month, Day);
            DayOfYear = Date.DayOfYear;
            DayOfWeek = Date.DayOfWeek;
        }
Esempio n. 6
0
        /// <summary>
        /// Create a CentralDateTime by ticks
        /// </summary>
        public CentralDateTime(long ticks)
        {
            var dateTime = new DateTime(ticks)
                           .ToUniversalTime()
                           .ToCentral();

            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 CentralDateTime(Year, Month, Day);
            DayOfYear = Date.DayOfYear;
            DayOfWeek = Date.DayOfWeek;
        }
Esempio n. 7
0
        public CentralDateTime(TimeSpan timeOfDay)
        {
            var centralNow = Now;

            Year  = centralNow.Year;
            Month = centralNow.Month;
            Day   = centralNow.Day;

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

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

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

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