System.Globalization.Calendar.AddSeconds C# (CSharp) Method

AddSeconds() public method

public AddSeconds ( DateTime time, int seconds ) : DateTime
time DateTime
seconds int
return DateTime
        public virtual DateTime AddSeconds(DateTime time, int seconds) {
            return Add(time, seconds, MillisPerSecond);
        }

Usage Example

Beispiel #1
0
        private static IEnumerable<DateTime> GetOccurrences(DateInterval interval, DatePeriod period, Calendar calendar, DateTime start, DateTime end, bool skipWeekends = true)
        {
            var difference = DateSpan.GetDifference(interval, start, end)/period.Quantifier;

            if (start.Kind == DateTimeKind.Utc)
            {
                start = start.ToLocalTime();
            }

            for (var i = 0; i < difference; i++)
            {
                switch (period.Frequency)
                {
                    case DatePeriodFrequency.Seconds:
                        var seconds = calendar.AddSeconds(start, period.Quantifier * i);
                        yield return DeferOccurrenceFallingOnWeekend(calendar, seconds, skipWeekends);
                        break;
                    case DatePeriodFrequency.Minutes:
                        var minutes = calendar.AddMinutes(start, period.Quantifier * i);
                        yield return DeferOccurrenceFallingOnWeekend(calendar, minutes, skipWeekends);
                        break;
                    case DatePeriodFrequency.Hours:
                        var hours = calendar.AddHours(start, period.Quantifier * i);
                        yield return DeferOccurrenceFallingOnWeekend(calendar, hours, skipWeekends);
                        break;
                    case DatePeriodFrequency.Days:
                        var days = calendar.AddDays(start, period.Quantifier*i);
                        yield return DeferOccurrenceFallingOnWeekend(calendar, days, skipWeekends);
                        break;
                    case DatePeriodFrequency.Weeks:
                        var weeks = calendar.AddWeeks(start, period.Quantifier*i);
                        yield return DeferOccurrenceFallingOnWeekend(calendar, weeks, skipWeekends);
                        break;
                    case DatePeriodFrequency.Months:
                        var months = calendar.AddMonths(start, period.Quantifier*i);
                        yield return DeferOccurrenceFallingOnWeekend(calendar, months, skipWeekends);
                        break;
                    case DatePeriodFrequency.Years:
                        var years = calendar.AddYears(start, period.Quantifier*i);
                        yield return DeferOccurrenceFallingOnWeekend(calendar, years, skipWeekends);
                        break;
                    default:
                        throw new ArgumentException("Frequency");
                }
            }
        }
All Usage Examples Of System.Globalization.Calendar::AddSeconds