Skip to content

Commit

Permalink
fix: handle string datetime in interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
djbarnwal committed Apr 28, 2024
1 parent 1c31566 commit b54b9d2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/vega-interpreter/src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const apply = (m, args, cast) => {
return obj[m].apply(obj, slice.call(args, 1));
};

const datetime = (y, m, d, H, M, S, ms) =>
new Date(y, m || 0, d != null ? d : 1, H || 0, M || 0, S || 0, ms || 0);
const datetime = (...args) => {
if (typeof args[0] === 'string') {
return new Date(args[0]);
}
const [y, m = 0, d = 1, H = 0, M = 0, S = 0, ms = 0] = args;
return new Date(y, m, d, H, M, S, ms);
};

export default {
// math functions
Expand Down

0 comments on commit b54b9d2

Please sign in to comment.