Source
try { var start_time = args.start_time.replace(/"/g, ""); var end_time = args.end_time.replace(/"/g, ""); // Strip microseconds and parse the datetime var startTimeObj = new Date(start_time.split(".")[0]); var endTimeObj = new Date(end_time.split(".")[0]); // Calculate the difference in minutes var timeDiff = (endTimeObj - startTimeObj) / 1000; // difference in seconds var mins = Math.round((timeDiff / 60) * 100) / 100; // round to 2 decimal places ec = { 'Time': { Difference: Number(mins), Start: start_time, End: end_time } } return { Type: entryTypes.note, Contents: Number(mins), ContentsFormat: formats.json, HumanReadable: `Calculated Time Difference: ${mins} minutes.`, ReadableContentsFormat: formats.markdown, EntryContext: ec }; } catch (ex) { return { ContentsFormat: formats.markdown, Type: entryTypes.error, Contents: "Error occurred while parsing output from command. Exception info:\n" + ex.toString() }; }
README
Calculate the time difference, in minutes
Script Data
| Name | Description |
|---|---|
| Script Type | javascript |
| Tags | Utilities |
Used In
This script is used in the following playbooks and scripts.
- Impossible Traveler
- Wait Until Datetime
Inputs
| Argument Name | Description |
|---|---|
| start_time | The time at which travel started. |
| end_time | The time at which travel ended. |
Outputs
| Path | Description | Type |
|---|---|---|
| Time.Difference | Calculated time difference in minutes. | Unknown |
| Time.Start | Start time. | Unknown |
| Time.End | End time. | Unknown |