Exemple #1
0
 public DateTimeEx SetDay(int day)
 {
     _dateTime = DateTimeOffsetHelper.CreateDateTime(
         _dateTime.Year, _dateTime.Month, day,
         _dateTime.Hour, _dateTime.Minute, _dateTime.Second,
         _dateTime.Millisecond, _timeZone);
     return(this);
 }
Exemple #2
0
 public DateTimeEx SetMillis(int millis)
 {
     _dateTime = DateTimeOffsetHelper.CreateDateTime(
         _dateTime.Year, _dateTime.Month, _dateTime.Day,
         _dateTime.Hour, _dateTime.Minute, _dateTime.Second,
         millis, _timeZone);
     return(this);
 }
Exemple #3
0
 public DateTimeEx SetYear(int year)
 {
     _dateTime = DateTimeOffsetHelper.CreateDateTime(
         year, _dateTime.Month, _dateTime.Day,
         _dateTime.Hour, _dateTime.Minute, _dateTime.Second,
         _dateTime.Millisecond, _timeZone);
     return(this);
 }
Exemple #4
0
        public static DateTimeOffset GetWithMaximumDay(this DateTimeOffset dateTime, TimeZoneInfo timeZone = null)
        {
            var daysInMonth = Calendar.GetDaysInMonth(dateTime.Year, dateTime.Month);

            if (timeZone == null)
            {
                return(new DateTimeOffset(
                           dateTime.Year, dateTime.Month, daysInMonth, dateTime.Hour, dateTime.Minute,
                           dateTime.Second, dateTime.Millisecond, dateTime.Offset));
            }

            return(DateTimeOffsetHelper.CreateDateTime(
                       dateTime.Year, dateTime.Month, daysInMonth, dateTime.Hour, dateTime.Minute,
                       dateTime.Second, dateTime.Millisecond, timeZone));
        }
Exemple #5
0
 public DateTimeEx Set(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0)
 {
     _dateTime = DateTimeOffsetHelper.CreateDateTime(
         year, month, day, hour, minute, second, millisecond, _timeZone);
     return(this);
 }