mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Support for moment-timezone
This commit is contained in:
parent
95cc8ea80d
commit
fdda29f048
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
const clone = require("clone");
|
const clone = require("clone");
|
||||||
const jsonata = require("jsonata");
|
const jsonata = require("jsonata");
|
||||||
const moment = require("moment");
|
const moment = require("moment-timezone");
|
||||||
const safeJSONStringify = require("json-stringify-safe");
|
const safeJSONStringify = require("json-stringify-safe");
|
||||||
const util = require("util");
|
const util = require("util");
|
||||||
|
|
||||||
|
@ -515,6 +515,11 @@ describe("@node-red/util/util", function() {
|
|||||||
var result = util.evaluateJSONataExpression(expr,{});
|
var result = util.evaluateJSONataExpression(expr,{});
|
||||||
result.should.eql('2020-07-03');
|
result.should.eql('2020-07-03');
|
||||||
});
|
});
|
||||||
|
it('accesses moment-timezone from an expression', function() {
|
||||||
|
var expr = util.prepareJSONataExpression('$moment("2013-11-18 11:55Z").tz("Asia/Taipei").format()',{});
|
||||||
|
var result = util.evaluateJSONataExpression(expr,{});
|
||||||
|
result.should.eql('2013-11-18T19:55:00+08:00');
|
||||||
|
});
|
||||||
it('handles non-existant flow context variable', function() {
|
it('handles non-existant flow context variable', function() {
|
||||||
var expr = util.prepareJSONataExpression('$flowContext("nonExistant")',{context:function() { return {flow:{get: function(key) { return {'foo':'bar'}[key]}}}}});
|
var expr = util.prepareJSONataExpression('$flowContext("nonExistant")',{context:function() { return {flow:{get: function(key) { return {'foo':'bar'}[key]}}}}});
|
||||||
var result = util.evaluateJSONataExpression(expr,{payload:"hello"});
|
var result = util.evaluateJSONataExpression(expr,{payload:"hello"});
|
||||||
|
Loading…
Reference in New Issue
Block a user