idi-custom-nodered
Version:
Custom Node-RED nodes and utilities - IDI Timestamp node for adding timestamps to messages
55 lines (51 loc) • 2.05 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('idi-timestamp',{
category: 'IDI Custom',
color: '#a6bbcf',
defaults: {
name: {value:""},
format: {value:"iso"},
property: {value:"payload"}
},
inputs:1,
outputs:1,
icon: "clock.svg",
label: function() {
return this.name || "IDI Timestamp";
}
});
</script>
<script type="text/html" data-template-name="idi-timestamp">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-format"><i class="fa fa-clock-o"></i> Format</label>
<select id="node-input-format">
<option value="iso">ISO String</option>
<option value="unix">Unix Timestamp</option>
<option value="milliseconds">Milliseconds</option>
</select>
</div>
<div class="form-row">
<label for="node-input-property"><i class="fa fa-ellipsis-h"></i> Property</label>
<input type="text" id="node-input-property" placeholder="payload">
</div>
</script>
<script type="text/html" data-help-name="idi-timestamp">
<p>A node that adds a timestamp to the message.</p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">string | number</span></dt>
<dd>The timestamp in the selected format.</dd>
</dl>
<h3>Details</h3>
<p>This node adds a timestamp to the message in one of three formats:</p>
<ul>
<li><b>ISO String:</b> Standard ISO 8601 format (e.g., 2023-12-25T10:30:00.000Z)</li>
<li><b>Unix Timestamp:</b> Seconds since epoch (e.g., 1703505000)</li>
<li><b>Milliseconds:</b> Milliseconds since epoch (e.g., 1703505000000)</li>
</ul>
<p>The timestamp can be set on any message property, defaulting to <code>msg.payload</code>.</p>
</script>