/// <summary>
 /// Initializes a new month based on the specified <paramref name="year"/> and <paramref name="month"/>.
 ///
 /// Timestamps for start and end will be calculated using <paramref name="timeZone"/>.
 /// </summary>
 /// <param name="year"></param>
 /// <param name="month"></param>
 /// <param name="timeZone"></param>
 public EssentialsMonth(int year, int month, TimeZoneInfo timeZone)
 {
     Year  = year;
     Month = month;
     Start = new EssentialsTime(year, month, 1, timeZone);
     End   = Start.GetEndOfMonth(timeZone);
 }
        /// <summary>
        /// Initializes a new instance for the month containing the specified <paramref name="timestamp"/>.
        ///
        /// If <paramref name="timestamp"/> doesn't specify a timestamp (eg. only an offset), the timestamp will be converted to <see cref="TimeZoneInfo.Local"/>.
        /// </summary>
        /// <param name="timestamp">A timestamp representing the month to be created.</param>
        public EssentialsMonth(EssentialsTime timestamp)
        {
            if (timestamp == null)
            {
                throw new ArgumentNullException(nameof(timestamp));
            }

            if (timestamp.TimeZone == null)
            {
                timestamp = timestamp.ToTimeZone(TimeZoneInfo.Local);
            }

            Year  = timestamp.Year;
            Month = timestamp.Month;
            Start = timestamp.GetStartOfMonth();
            End   = timestamp.GetEndOfMonth();
        }
        /// <summary>
        /// Returns a <see cref="EssentialsPeriod"/> representing the month of <paramref name="dto"/> and according to <paramref name="timeZone"/>.
        /// </summary>
        /// <param name="dto">The timestamp.</param>
        /// <param name="timeZone">The time zone.</param>
        /// <returns>An instance of <see cref="EssentialsPeriod"/>.</returns>
        public static EssentialsPeriod ThisMonth(DateTimeOffset dto, TimeZoneInfo timeZone)
        {
            // Time zone may not be null
            if (timeZone == null)
            {
                throw new ArgumentNullException(nameof(timeZone));
            }

            // Wrap the input "dto"
            EssentialsTime time = new EssentialsTime(dto);

            // Calculate start and end
            EssentialsTime start = time.GetStartOfMonth(timeZone);
            EssentialsTime end   = time.GetEndOfMonth(timeZone);

            // Wrap the result in a new EssentialsPeriod
            return(new EssentialsPeriod(start, end));
        }