Difference between revisions of "Functions"

From PresenceWiki
Jump to: navigation, search
(&currentDate{format, offset})
Line 47: Line 47:
 
Returns: the current date in the format specified by the first parameter.
 
Returns: the current date in the format specified by the first parameter.
  
format: The date format to use to format the current date (e.g. "dd/MM/yyyy"). See [[#Date and Time Patterns=]]
+
format: The date format to use to format the current date (e.g. "dd/MM/yyyy"). See [[#Date and Time Patterns]]
 +
 
 
offset: (Optional) The offset in days (e.g. -1, 1, 2, -5)
 
offset: (Optional) The offset in days (e.g. -1, 1, 2, -5)
  
<pre>&currentDate{"MMM/YYYY"}</pre> Returns Aug/2015 <pre>&currentDate{"dd/MM/YYYY"}</pre> Returns 13/08/2015 or whatever the current date is. <pre>&currentDate{"dd/MM/YYYY",-5}</pre> Returns 08/08/2015 (minus 5 days from the current date) <pre>&currentDate{"dd/MM/YYYY",-3M}</pre> Returns 13/05/2015 (minus 3 months from the current date) <pre>&currentDate{"dd/MM/YYYY",5}</pre> Returns 18/08/2015 (plus 5 days from the current date)  
+
<pre>&currentDate{"MMM/yyyy"}</pre> Returns Aug/2015 <pre>&currentDate{"dd/MM/yyyy"}</pre> Returns 13/08/2015 or whatever the current date is. <pre>&currentDate{"dd/MM/yyyy",-5}</pre> Returns 08/08/2015 (minus 5 days from the current date) <pre>&currentDate{"dd/MM/yyyy",-3M}</pre> Returns 13/05/2015 (minus 3 months from the current date) <pre>&currentDate{"dd/MM/YYYY",5}</pre> Returns 18/08/2015 (plus 5 days from the current date)  
 +
 
 +
===== &formatDate{DATE_VALUE, input format, output format} =====
 +
Returns: a new format for a date passed into the function on parameter 1
 +
 
 +
<pre>&formatDate{"2015-08-13","yyyy-MM-dd","dd/MM/yyyy"}</pre> Returns 13/08/2015 <pre>&formatDate{"2015-08-13","yyyy-MM-dd","E dd MMM YYYY"}</pre> Returns Thu 13 Aug 2015 <pre>&formatDate{"2015-08-13","yyyy-MM-dd","dd/MM/yyyy",5}</pre> Returns 13/08/2015 (adds 5 days to the date on parameter 1) <pre>&formatDate{"2015-08-13","yyyy-MM-dd","EEEE dd MMM YYYY"}</pre> Returns Thursday 13 Aug 2015
  
* &formatDate{"value_or_variable", "input format", "output format"}
 
Returns: a new format for a date passed into the function on parameter 1 the current date in the format specified by the first parameter.
 
 
===Date and Time Patterns===
 
===Date and Time Patterns===
  

Revision as of 09:26, 13 August 2015

Index of Functions

This list aims to be a comprehensive list of default functions available with Presence 3.6.2. Please note that it is a work in progress.

Boolean Functions

&equalsString{VAL1, VAL2}

This function compares String1 and String2. If they are equal it will return the value "true". Otherwise it will return "false".

&equalsString{"ABC","ABC"}
Returns true
&equalsString{"ABC","BC"}
Returns false


&if{VALUE, TRUE_RESULT, FALSE_RESULT}

This function performs a test on a string. If it equals "true" or "1" the value of Parameter 2 will be returned. Otherwise, value of Parameter 3 will be returned.

&if{"true", "I AM TRUE", "I AM FALSE"}
Returns "I AM TRUE"
&if{"0", "I AM TRUE", "I AM FALSE"}
Returns "I AM FALSE"

Data Functions

&onDemand{taskAlias, parameter+}

Calls an On Demand Task that is on the Live Task Queue.

taskAlias: The alias of the Task to be called, the task should be on the Live Tasks Queue #On Demand Processes

parameter+ : The Parameters to be passed (zero or more).

&onDemand{"myTask","id=5", "now=true"}

Calls the Task referenced by the alias "myTask" and sets the following variables:

${id} = 5 ${now} = true

If the task returns a magic ${response} variable that value will be populated in the variable or space you are calling the function from.

&doesColumnExist{"COL_NAME"}

Tests to see if the specified column name exists in the current data table - returns "true" if it does or "false" if not.

Parameter 1: The column name to test


Date Functions

&currentDate{format, offset}

Returns: the current date in the format specified by the first parameter.

format: The date format to use to format the current date (e.g. "dd/MM/yyyy"). See #Date and Time Patterns

offset: (Optional) The offset in days (e.g. -1, 1, 2, -5)

&currentDate{"MMM/yyyy"}
Returns Aug/2015
&currentDate{"dd/MM/yyyy"}
Returns 13/08/2015 or whatever the current date is.
&currentDate{"dd/MM/yyyy",-5}
Returns 08/08/2015 (minus 5 days from the current date)
&currentDate{"dd/MM/yyyy",-3M}
Returns 13/05/2015 (minus 3 months from the current date)
&currentDate{"dd/MM/YYYY",5}
Returns 18/08/2015 (plus 5 days from the current date)
&formatDate{DATE_VALUE, input format, output format}

Returns: a new format for a date passed into the function on parameter 1

&formatDate{"2015-08-13","yyyy-MM-dd","dd/MM/yyyy"}
Returns 13/08/2015
&formatDate{"2015-08-13","yyyy-MM-dd","E dd MMM YYYY"}
Returns Thu 13 Aug 2015
&formatDate{"2015-08-13","yyyy-MM-dd","dd/MM/yyyy",5}
Returns 13/08/2015 (adds 5 days to the date on parameter 1)
&formatDate{"2015-08-13","yyyy-MM-dd","EEEE dd MMM YYYY"}
Returns Thursday 13 Aug 2015

Date and Time Patterns

G Era designator e.g. "AD"

y Year e.g. yyyy="2015"; yy="15"

M Month in year e.g. M="8" (August); MM="08"; MMM="Aug" MMMM="August"

w Week in year e.g. w="33" (13/August/2015)

W Week in month e.g. W="2" (13/August/2015)

D Day in year e.g. D="225" (13/August/2015)

d Day in month e.g d="13" (13/August/2015)

F Day of week in month

E Day in week e.g. E="Thu"

a Am/pm marker

H Hour in day (0-23)

h Hour in day (1-12)

m Minute in hour

s Second in minute

S Millisecond

z Time zone e.g. z="BST"; zzzz="British Summer Time"

Z Time zone (RFC 822 time zone) e.g Z="+0100"

X Time zone (ISO 8601 time zone) e.g X="+01"; XX="+0100"; XXX="+01:00"