From 07fba53b73e2d86de33e5fd07fc54d1479ca7712 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Wed, 17 May 2017 14:37:36 +0000 Subject: [PATCH] 'To UNIX Timestamp' operation now defaults to UTC instead of your local timezone. --- src/core/config/OperationConfig.js | 7 ++++++- src/core/operations/DateTime.js | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index 708980df..b49309f8 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -2223,7 +2223,7 @@ const OperationConfig = { ] }, "To UNIX Timestamp": { - description: "Parses a datetime string and returns the corresponding UNIX timestamp.

e.g. Mon 1 January 2001 11:00:00 UTC becomes 978346800", + description: "Parses a datetime string in UTC and returns the corresponding UNIX timestamp.

e.g. Mon 1 January 2001 11:00:00 becomes 978346800", run: DateTime.runToUnixTimestamp, inputType: "string", outputType: "number", @@ -2232,6 +2232,11 @@ const OperationConfig = { name: "Units", type: "option", value: DateTime.UNITS + }, + { + name: "Treat as UTC", + type: "boolean", + value: DateTime.TREAT_AS_UTC } ] }, diff --git a/src/core/operations/DateTime.js b/src/core/operations/DateTime.js index 345eb544..523206b2 100755 --- a/src/core/operations/DateTime.js +++ b/src/core/operations/DateTime.js @@ -46,6 +46,12 @@ const DateTime = { }, + /** + * @constant + * @default + */ + TREAT_AS_UTC: true, + /** * To UNIX Timestamp operation. * @@ -55,7 +61,8 @@ const DateTime = { */ runToUnixTimestamp: function(input, args) { let units = args[0], - d = moment(input); + treatAsUTC = args[1], + d = treatAsUTC ? moment.utc(input) : moment(input); if (units === "Seconds (s)") { return d.unix();