Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using OfficeOpenXml.FormulaParsing.ExpressionGraph;
|
---|
6 |
|
---|
7 | namespace OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime
|
---|
8 | {
|
---|
9 | public class Eomonth : ExcelFunction
|
---|
10 | {
|
---|
11 | public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
|
---|
12 | {
|
---|
13 | ValidateArguments(arguments, 2);
|
---|
14 | var date = System.DateTime.FromOADate(ArgToDecimal(arguments, 0));
|
---|
15 | var monthsToAdd = ArgToInt(arguments, 1);
|
---|
16 | var resultDate = new System.DateTime(date.Year, date.Month, 1).AddMonths(monthsToAdd + 1).AddDays(-1);
|
---|
17 | return CreateResult(resultDate.ToOADate(), DataType.Date);
|
---|
18 | }
|
---|
19 | }
|
---|
20 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.