/// <summary> /// Gets start and end dates for months falling in the given period. /// </summary> /// <param name="startDate">Period's start</param> /// <param name="endDate">Period's end</param> /// <returns>Two-dimensional array of DateTime. First dimension is months (there will be as many /// items as there are months in the period). In the second dimension, first element is month's /// start date, second - month's end date.</returns> public static DateTime[,] GetMonthDates(DateTime startDate, DateTime endDate) { DateTime[,] monthDates = new DateTime[GetMonthDifferenceBetweenDates(startDate, endDate) + 1, 2]; DateTime date = startDate; int monthIndex = 0; while (monthIndex < monthDates.GetLength(0)) { DateTime monthStart = new DateTime(date.Year, date.Month, 1); DateTime monthEnd = monthStart.AddMonths(1).AddDays(-1); monthDates[monthIndex, 0] = monthStart; monthDates[monthIndex, 1] = monthEnd; date = date.AddMonths(1); monthIndex++; } return monthDates; }
public void Rfc2425_Example_4_Multiple_Values() { const string input = "1996-10-22T14:00:00Z,1996-08-11T12:34:56Z"; DateTime[] expected = new DateTime[] { new DateTime(1996, 10, 22, 14, 00, 00, DateTimeKind.Utc), new DateTime(1996, 08, 11, 12, 34, 56, DateTimeKind.Utc), }; VCardSimpleValue sv = new VCardSimpleValue(Name, input); var actual = sv.GetListValues(); Assert.AreEqual(expected.GetLength(0), actual.Count, "Number of items"); DateTimeAssert.AreEqual(expected[0], actual[0].GetDateTime()); DateTimeAssert.AreEqual(expected[1], actual[1].GetDateTime()); }
public Variant(DateTime[] value) { this.Value = value; this.Type = VariantType.DateTime; this.ArrayDimensions = new int[value.Rank]; for (int i = 0; i < value.Rank; i++) { this.ArrayDimensions[i] = value.GetLength(i); } }