# Additional Methods with Scheduler

#### `getTime` method <a href="#gettime-method" id="gettime-method"></a>

Asynchronously get the current *timestamp in seconds* (floating point) since Captivate started.

```javascript
ServiceHandler.scheduler.getTime(callback);
```

* `callback`: Function taking a single argument that will receive the time value once it is retrieved.

**Example:**

```javascript
ServiceHandler.scheduler.getTime((time) => {
  // do something with time
  console.log(`Captivate has been running for ${time} seconds`);
});
```

#### `updateInputDefinition` method <a href="#updateinputdefinition-method" id="updateinputdefinition-method"></a>

Updates the definition of the named input with new variables and types. This overrides all variable definitions specified in the XML file and is necessary when a new variable name is added to the input or when a variable pattern needs to be changed. This function will also trigger a re-render on all titles connected to this input, so use it sparingly.

```javascript
ServiceHandler.scheduler.updateInputDefinition(inputName, definition);
```

* `inputName`: Input name must match the name from the input definition XML file.
* `definition`: JavaScript object containing the new variable definitions (see below). By default, this definition will completely replace the variables defined previously. That is, new variables will be created if they weren’t defined before, and variables omitted from this definition will be deleted from the input for this project. However, you may send a `method` parameter set to one of the following values to change this behavior:
  * `reset`: All current variables will be deleted, and the supplied variables will constitute the new definition. (This is the default for backwards compatibility, but if there are a lot of variables, this might cause an expensive re-render. Use the `merge` option whenever you can.)
  * `delete`: Supplied variables will be deleted from the input definition.
  * `merge`: Supplied variables will be added to the input definition, possibly replacing previous variables.

For more information on the variable definition, see **Creating Input Behaviors** section of the [XML Definition](https://developers.newbluefx.com/captivate-api/captivate-controller-reference/xml-definition) page for description of definition parameters. They are the same here as in the XML specification with the exception that both attributes and child nodes from the XML are represented in JavaScript by object fields. Specifically notice that `<value>` nodes are here represented by a `values` list.

**Example:**

```javascript
const definition = {
  method: 'reset', // if omitted, `reset` is the default, may also be `delete` or `merge`
  variables: {
    'Home Score': {
      type: 'text',
    },
    'Visitor Score': {
      type: 'text',
    },
    'Shot Clock': {
      type: 'text',
      pattern: '[0-2][0-9].[0-9]',
    },
    'Period Number': {
      type: 'text',
      values: ['1', '2', '2.5', '3', '4', '5'], // 2.5 = halftime, 5 = OT
    },
  },
};

ServiceHandler.scheduler.updateInputDefinition('Simple HTML Scoreboard', definition);
```
