-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from eiiches/feature/20210807-add-now-function
add now/0 function
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
jackson-jq/src/main/java/net/thisptr/jackson/jq/internal/functions/NowFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |