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) 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 version 4 compliant.
Returns:
A new random UUID as a 36 character long string.
Type
string