]> gerrit.simantics Code Review - simantics/platform.git/blob
c4488f3499c1b98aae2ed0310928b591a311bfb5
[simantics/platform.git] /
1 package org.simantics.spreadsheet.graph.formula;
2
3 import java.time.LocalDate;
4 import java.time.Month;
5 import java.time.temporal.ChronoUnit;
6 import java.time.temporal.Temporal;
7
8 import org.simantics.spreadsheet.graph.CellFormulaFunction;
9 import org.simantics.spreadsheet.graph.CellValueVisitor;
10 import org.simantics.spreadsheet.graph.parser.ast.AstArgList;
11
12 public class TodayFormulaFunction implements CellFormulaFunction<Long> {
13
14     private Temporal baseline = LocalDate.of(1899, Month.DECEMBER, 30);
15
16     @Override
17     public Long evaluate(CellValueVisitor visitor, AstArgList args) {
18         return Long.valueOf(ChronoUnit.DAYS.between(baseline, LocalDate.now()));
19     }
20
21 }