Date Time Functions

Date Time Functions

Date/Time functions

Fuuz Context

Where this applies in Fuuz: Date/time utilities are commonly used in Fuuz to timestamp transactions, align timezones across plants, and format values for downstream systems (e.g., SAP, Oracle, or machine HMIs). All functions execute with a single evaluation timestamp per message.

  • Timezones: Use the picture/offset parameters of $fromMillis() when normalizing to plant-local time (e.g., "-0500" for US Eastern).
  • Idempotency: Capture $millis() into a key to de-duplicate replays across the Fuuz data platform.
  • Formatting: When integrating with legacy systems, use picture strings to emit RFC-compatible timestamps expected by those systems.

$now()

Signature: $now([picture [, timezone]])

Generates a UTC timestamp in ISO 8601 compatible format and returns it as a string. All invocations of $now() within an evaluation of an expression will all return the same timestamp value.

If the optional picture and timezone parameters are supplied, then the current timestamp is formatted as described by the [$fromMillis()](#frommillis) function.

Examples

  • $now() => "2017-05-15T15:12:59.152Z"

$millis()

Signature: $millis()

Returns the number of milliseconds since the Unix *Epoch* (1 January, 1970 UTC) as a number. All invocations of $millis() within an evaluation of an expression will all return the same value.

Examples

  • $millis() => 1502700297574

$fromMillis()

Signature: $fromMillis(number [, picture [, timezone]])

Convert the number representing milliseconds since the Unix *Epoch* (1 January, 1970 UTC) to a formatted string representation of the timestamp as specified by the picture string.

If the optional picture parameter is omitted, then the timestamp is formatted in the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.

If the optional picture string is supplied, then the timestamp is formatted occording to the representation specified in that string.

The behaviour of this function is consistent with the two-argument version of the XPath/XQuery function [fn:format-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-format-dateTime) as defined in the XPath F&O 3.1 specification. The picture string parameter defines how the timestamp is formatted and has the [same syntax](https://www.w3.org/TR/xpath-functions-31/#date-picture-string) as fn:format-dateTime.

If the optional timezone string is supplied, then the formatted timestamp will be in that timezone. The timezone string should be in the

format "±HHMM", where ± is either the plus or minus sign and HHMM is the offset in hours and minutes from UTC. Positive offset for timezones

east of UTC, negative offset for timezones west of UTC.

Examples

  • $fromMillis(1510067557121) => "2017-11-07T15:12:37.121Z"
  • $fromMillis(1510067557121, '[M01]/[D01]/[Y0001] [h#1]:[m01][P]') => "11/07/2017 3:12pm"
  • $fromMillis(1510067557121, '[H01]:[m01]:[s01] [z]', '-0500') => "10:12:37 GMT-05:00"

$toMillis()

Signature: $toMillis(timestamp [, picture])

Convert a timestamp string to the number of milliseconds since the Unix *Epoch* (1 January, 1970 UTC) as a number.

If the optional picture string is not specified, then the format of the timestamp is assumed to be [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html). An error is thrown if the string is not in the correct format.

If the picture string is specified, then the format is assumed to be described by this picture string using the [same syntax](https://www.w3.org/TR/xpath-functions-31/#date-picture-string) as the XPath/XQuery function [fn:format-dateTime](https://www.w3.org/TR/xpath-functions-31/#func-format-dateTime), defined in the XPath F&O 3.1 specification.

Examples

  • $toMillis("2017-11-07T15:07:54.972Z") => 1510067274972

    • Related Articles

    • Date Time Processing

      Date/Time processing The 'evaluation time’ - $now() There are two functions that return the 'current' date/time timestamp: 1. [$now()](date-time-functions#now) returns the timestamp in an ISO 8601 formatted string. 2. ...
    • Screen Designer Element Types

      There are four categories of Element Types: Layout, Input, Display, and Interaction. In the properties tab on the right-hand side, you can see the element types organized by category. i.e. if you look under the category Layout the first element ...
    • Boolean Functions

      Boolean functions $boolean() Signature: $boolean(arg) Casts the argument to a Boolean using the following rules: | Argument type | Result | | ------------- | ------ | | Boolean | unchanged | | string: empty | false| | string: non-empty | true | | ...
    • Aggregation Functions

      Numeric aggregation functions $sum() Signature: $sum(array) Returns the arithmetic sum of an array of numbers. It is an error if the input array contains an item which isn't a number. Example $sum([5,1,3,7,4]) => 20 $max() Signature: $max(array) ...
    • Numeric Functions

      Numeric functions $number() Signature: $number(arg) Casts the arg parameter to a number using the following casting rules - Numbers are unchanged - Strings that contain a sequence of characters that represent a legal JSON number are converted to that ...