Skip to content

Commit

Permalink
Merge pull request #95 from eiiches/feature/20210807-add-now-function
Browse files Browse the repository at this point in the history
add now/0 function
  • Loading branch information
eiiches authored Aug 7, 2021
2 parents d4c56f2 + f4e1424 commit 5f6fd84
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.thisptr.jackson.jq.internal.functions;

import java.util.List;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.DoubleNode;
import com.google.auto.service.AutoService;

import net.thisptr.jackson.jq.Expression;
import net.thisptr.jackson.jq.Function;
import net.thisptr.jackson.jq.PathOutput;
import net.thisptr.jackson.jq.Scope;
import net.thisptr.jackson.jq.Version;
import net.thisptr.jackson.jq.exception.JsonQueryException;
import net.thisptr.jackson.jq.internal.BuiltinFunction;
import net.thisptr.jackson.jq.path.Path;

@AutoService(Function.class)
@BuiltinFunction("now/0")
public class NowFunction implements Function {

@Override
public void apply(final Scope scope, final List<Expression> args, final JsonNode in, final Path path, final PathOutput output, final Version version) throws JsonQueryException {
output.emit(new DoubleNode(System.currentTimeMillis() / 1000.0), null);
}
}

0 comments on commit 5f6fd84

Please sign in to comment.