Skip to content

Commit

Permalink
Merge branch 'bug-timestamp'
Browse files Browse the repository at this point in the history
  • Loading branch information
n1474335 committed May 17, 2017
2 parents 0e72d78 + 07fba53 commit 83623d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/core/config/OperationConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2224,7 +2224,7 @@ const OperationConfig = {
]
},
"To UNIX Timestamp": {
description: "Parses a datetime string and returns the corresponding UNIX timestamp.<br><br>e.g. <code>Mon 1 January 2001 11:00:00 UTC</code> becomes <code>978346800</code>",
description: "Parses a datetime string in UTC and returns the corresponding UNIX timestamp.<br><br>e.g. <code>Mon 1 January 2001 11:00:00</code> becomes <code>978346800</code>",
run: DateTime.runToUnixTimestamp,
inputType: "string",
outputType: "number",
Expand All @@ -2233,6 +2233,11 @@ const OperationConfig = {
name: "Units",
type: "option",
value: DateTime.UNITS
},
{
name: "Treat as UTC",
type: "boolean",
value: DateTime.TREAT_AS_UTC
}
]
},
Expand Down
9 changes: 8 additions & 1 deletion src/core/operations/DateTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ const DateTime = {
},


/**
* @constant
* @default
*/
TREAT_AS_UTC: true,

/**
* To UNIX Timestamp operation.
*
Expand All @@ -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();
Expand Down

0 comments on commit 83623d2

Please sign in to comment.