Ejemplo n.º 1
0
        public EasternDateTime AddYears(int value)
        {
            var dt = DateTime.Parse(Value);

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

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

            dt = dt.AddMonths(months);
            return(EasternDateTime.Convert(dt.ToUniversalTime()));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// TryParse a datetime string to get the eastern timezone
 /// </summary>
 public static bool TryParse(string dateTime, out EasternDateTime easternDateTime)
 {
     try
     {
         easternDateTime = Parse(dateTime);
         return(true);
     }
     catch (Exception ex)
     {
         easternDateTime = default(EasternDateTime);
         return(false);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a EasternDateTime of a specific date and time
        /// </summary>
        public EasternDateTime(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 EasternDateTime(Year, Month, Day);
            DayOfYear = Date.DayOfYear;
            DayOfWeek = Date.DayOfWeek;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Create a EasternDateTime by ticks
        /// </summary>
        public EasternDateTime(long ticks)
        {
            var dateTime = new DateTime(ticks)
                           .ToUniversalTime()
                           .ToEastern();

            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 EasternDateTime(Year, Month, Day);
            DayOfYear = Date.DayOfYear;
            DayOfWeek = Date.DayOfWeek;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a new EasternDateTime of 'Today at this time (hours and minutes)'
        /// </summary>
        public EasternDateTime(TimeSpan timeOfDay)
        {
            var easternNow = Now;

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