Namespace: util

parasql.util

Miscellaneous utility functions.

Methods

(static) formatDate(num, fmtStr) → {string}

The fmtStr parameter may include the following characters:
YYYY - four digit year
YY - two digit year
MM - two digit month (with leading zero as needed)
DD - two digit day (with leading zero as needed)
 
HH - two digit hours - 24 hour format
hh - two digit hours - 12 hour format
AM - two letters - either AM or PM
mm - two digit minutes
ss - two digit seconds
ms - three digit milliseconds - 000 to 999
 
DOW - three letter day of week - e.g. Sun, Mon
MONTH - long month name - e.g. January, February
Parameters:
Name Type Description
num number A number representing the primitive value of a Date object e.g. new Date().valueOf()
fmtStr string A date format string
Returns:
The date formatted into a string as specified by fmtStr
Type
string
Example
parasql.util.formatDate(@value(MyTable.MyDateField), 'YYYY/MM/DD')

(static) formatNumber(num, fmtStr) → {string}

Parameters:
Name Type Description
num number
fmtStr string A valid format string
Returns:
The number formatted into a string as specified by fmtStr
Type
string

(static) getMachineId() → {string}

Returns a pseudo machine id that should be stable across a given browser/machine combination.
Since:
  • v124
Returns:
A 36 character string in UUID format.
Type
string

(static) newRandomKeyAsHex(lengthInBits) → {string}

Uses strong crypto to generate a new random key represented in Hex string format. 128 bits yields 32 chars, 256 bits yields 64 chars.
Parameters:
Name Type Description
lengthInBits number The length of the key in bits.
Since:
  • v78
Returns:
Returns the new random key as a hex string.
Type
string

(static) newRandomUUID() → {string}

Generates a new random UUID. The UUID is RFC4122 v4 compliant and uses a cryptographically secure random number generator.
Returns:
A new random UUID as a 36 character long string.
Type
string

(static) round(num, decimalPlacesopt) → {number}

Rounds positive and negative numbers correctly to the specified number of decimal places.
Parameters:
Name Type Attributes Default Description
num number The number to round.
decimalPlaces number <optional>
0 The number of decimal places to round to.
Since:
  • v122
Returns:
Type
number