Support for moment-timezone

This commit is contained in:
dxdc 2020-05-28 01:20:10 -05:00
parent 95cc8ea80d
commit fdda29f048
No known key found for this signature in database
GPG Key ID: ED2525C88CF07374
2 changed files with 6 additions and 1 deletions

View File

@ -22,7 +22,7 @@
const clone = require("clone");
const jsonata = require("jsonata");
const moment = require("moment");
const moment = require("moment-timezone");
const safeJSONStringify = require("json-stringify-safe");
const util = require("util");

View File

@ -515,6 +515,11 @@ describe("@node-red/util/util", function() {
var result = util.evaluateJSONataExpression(expr,{});
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() {
var expr = util.prepareJSONataExpression('$flowContext("nonExistant")',{context:function() { return {flow:{get: function(key) { return {'foo':'bar'}[key]}}}}});
var result = util.evaluateJSONataExpression(expr,{payload:"hello"});