/// <summary> /// Initializes a new instance for the year 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 year to be created.</param> public EssentialsYear(EssentialsTime timestamp) { if (timestamp == null) { throw new ArgumentNullException(nameof(timestamp)); } if (timestamp.TimeZone == null) { timestamp = timestamp.ToTimeZone(TimeZoneInfo.Local); } Year = timestamp.Year; Start = new EssentialsTime(timestamp.Year, 1, 1, timestamp.TimeZone); End = new EssentialsTime(timestamp.Year, 12, 31, timestamp.TimeZone).GetEndOfDay(); }
/// <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(); }