Mega Code Archive

 
Categories / C# / Date Time
 

Gets the days in year

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cmoss.Util {     public class DateFunctions     {         /// <summary>         /// Gets the days in year.         /// </summary>         /// <param name="date">The date.</param>         /// <returns></returns>         public static int GetDaysInYear(DateTime date)         {             if (date.Equals(DateTime.MinValue))             {                 return -1;             }             DateTime thisYear = new DateTime(date.Year, 1, 1);             DateTime nextYear = new DateTime(date.Year + 1, 1, 1);             return (nextYear - thisYear).Days;         }     } }