blob: 7aef11b0efe839f8b5b2661b6e3c02f0cf29a9c6 [file] [log] [blame]
using System.Collections.Generic;
using System.Linq;
namespace AppsheetEpplus;
public class AdditionalHolidayDays {
private readonly FunctionArgument _holidayArg;
private readonly List<System.DateTime> _holidayDates = new();
public AdditionalHolidayDays(FunctionArgument holidayArg) {
_holidayArg = holidayArg;
Initialize();
}
public IEnumerable<System.DateTime> AdditionalDates => _holidayDates;
private void Initialize() {
var holidays = _holidayArg.Value as IEnumerable<FunctionArgument>;
if (holidays != null) {
foreach (var holidayDate in from arg in holidays
where ConvertUtil.IsNumeric(arg.Value)
select ConvertUtil.GetValueDouble(arg.Value) into dateSerial
select System.DateTime.FromOADate(dateSerial)) {
_holidayDates.Add(holidayDate);
}
}
var range = _holidayArg.Value as ExcelDataProvider.IRangeInfo;
if (range != null) {
foreach (var holidayDate in from cell in range
where ConvertUtil.IsNumeric(cell.Value)
select ConvertUtil.GetValueDouble(cell.Value) into dateSerial
select System.DateTime.FromOADate(dateSerial)) {
_holidayDates.Add(holidayDate);
}
}
if (ConvertUtil.IsNumeric(_holidayArg.Value)) {
_holidayDates.Add(System.DateTime.FromOADate(ConvertUtil.GetValueDouble(_holidayArg.Value)));
}
}
}