timeDiff

Drupal. timeDiff

Methods

(static) format(diff, optionsopt) → {timeDiff}

Source:
Formats a time interval between two timestamps.
Parameters:
Name Type Attributes Description
diff number A UNIX timestamps difference in seconds.
options object <optional>
An optional object with additional options.
Properties
Name Type Attributes Default Description
granularity number <optional>
2 An integer value that signals how many different units to display in the string. Defaults to 2.
strict boolean <optional>
false A boolean value indicating whether or not, a negative diff should be rendered as "0 seconds". If the time difference is negative (i.e. the timestamp is in the past) and this option is false (default) the result string will be the formatted time difference. If the option is true the result string will be "0 seconds".
Returns:
A time difference type object.
Type
timeDiff

(static) refreshInterval(value, refresh, granularity) → {number}

Source:
Computes the refresh interval. There are cases when the refresh occurs even when it is not needed. For example if the refresh interval is '10 seconds', the granularity is 2 and the time difference is '1 hour 32 minutes', there's no need to refresh every 10 seconds but every 1 minute. This function optimizes the refresh interval to higher values, if the structure of the time difference doesn't require refreshing more often.
Parameters:
Name Type Description
value timeDiffValue The time difference object.
refresh number The configured refresh interval in seconds.
granularity number The time difference granularity.
Returns:
The computed refresh interval in seconds.
Type
number

(static) show(timeElement)

Source:
Fills a HTML5 time element text with a computed time difference string.
Parameters:
Name Type Description
timeElement Element The time DOM element.