Note

All code samples below refer to the skuid object.

In the v2 API, this object is not directly accessible when working within a browser console—or when referring to another Skuid page runtime.

If you are experiencing issues, use the skuid.runtime API to target the appropriate page context.

skuid.time

Functions

skuid.time.formatDate(formatString, jsDate)

Formats a JavaScript Date object (jsDate) into a string value, according to a designated date format.

formatString can include any of the following date format pattern characters, as well as any desired separator characters.

The formatting algorithm is jQuery’s $.datepicker.formatDate(), whose format characters are based on Java’s SimpleDateFormat.

DATE FORMAT PATTERN CHARACTERS:

  • d - day of month (no leading zero)
  • dd - day of month (two digit)
  • o - day of the year (no leading zeros)
  • oo - day of the year (three digit)
  • D - day name short
  • DD - day name long
  • m - month of year (no leading zero)
  • mm - month of year (two digit)
  • M - month name short
  • MM - month name long
  • y - year (two digit)
  • yy - year (four digit)
Arguments:
  • formatString (string) – A String containing one or more format pattern characters and any other desired separator characters, e.g. “m/d/yy”, “DD, MM d, yy”
  • jsDate (date) – A JavaScript Date object to format
Returns:

The Date formatted according to the desired format, e.g. “11/23/1961”, “Thursday, November 23, 1961”

Return type:

String

skuid.time.formatTime(formatString, jsDate)

Formats a JavaScript Date object (jsDate) into a string value, according to a designated time format.

formatString can include any of the following time format pattern characters, as well as any desired separator characters.

The format characters are based on Java’s SimpleDateFormat.

TIME FORMAT PATTERN CHARACTERS:

  • a - Am/pm marker, localized according to running user’s locale
  • s - second(s) in minute
  • m - minute in hour
  • H - hour in day (0-23)
  • k - hour in day (1-24)
  • h - hour in am/pm (1-12)
  • K - hour in am/pm (0-11)

Note

mm, hh, HH, kk, KK will result in leading zeros being prepended if the result is less than 10.

Arguments:
  • formatString (string) – A String containing one or more time format pattern characters and any other desired separator characters, e.g. “HH:mm:ss”, “h:mm a”
  • jsDate (date) – A JavaScript Date object to format
Returns:

The Date formatted according to the desired time format, e.g. “18:45:02”, “6:45 pm”

Return type:

String

skuid.time.getLocalDateTime(jsDate)

Use this function to offset your date by the amount that the Salesforce user timezone setting and the user’s device timezone differ. When you use this function, your date will now be “wrong” if you output it into the console. This is because after applying this function, the timezone will not change, but the actual date and time will be offset. In most cases, this function will return the exact same date that was input. To reverse the result of this function, use the skuid.time.getRealJSDateTimeFromLocal( jsDate ) function.

Arguments:
  • jsDate (date) – A JavaScript Date object
Returns:

The offset JavaScript date value

Return type:

Date

skuid.time.getRealJSDateTimeFromLocal(jsDate)

Use this function to reverse the effects of the skuid.time.getLocalDateTime( jsDate ) function.

Arguments:
  • jsDate (date) – A JavaScript Date object
Returns:

The offset JavaScript date value

Return type:

Date

skuid.time.getSFDate(jsDate)

Takes a JavaScript Date Object and converts it to a Salesforce Date string

Arguments:
  • jsDate (date) – A JavaScript Date object
Returns:

The corresponding Salesforce date string

Return type:

String

skuid.time.getSFDateTime(jsDate)

Takes a JavaScript Date object and converts it to a Salesforce DateTime string

Arguments:
  • jsDate (date) – A JavaScript Date object
Returns:

The corresponding Salesforce DateTime string

Return type:

String

skuid.time.makeFormattedDate(sfDate)

Takes a Salesforce Date string and formats it in the locale of the running Salesforce user

Arguments:
  • sfDate (string) – A Salesforce date string
Returns:

A date formatted using the current client’s locale

Return type:

String

skuid.time.makeFormattedDateFromJS(jsDate)

Takes a JavaScript Date object and formats it in the locale of the running Salesforce user

Arguments:
  • jsDate (date) – A JavaScript Date object
Returns:

A date formatted using the current client’s locale

Return type:

String

skuid.time.parseSFDate(sfDate)

Takes a Salesforce Date string and converts it to a JavaScript Date object

Arguments:
  • sfDate (string) – A Salesforce date string
Returns:

The corresponding JavaScript Date object

Return type:

Date

skuid.time.parseSFDateTime(sfDateTime)

Takes a Salesforce DateTime string and converts it to a JavaScript Date object

Arguments:
  • sfDate (string) – A Salesforce date string
Returns:

The corresponding JavaScript Date object

Return type:

Date

skuid.time.setUserTimeZone(timeZoneKey)

Adjusts the Skuid UI to render Dates, Datetimes, and Calendars in the specified Time Zone.

Arguments:
Returns:

Promise, resolved once the UI has been re-rendered to display content in the desired Time Zone.

Return type:

Promise

Properties

skuid.time.amPm

An array containing the AM and PM markers—localized according to the running user’s language setting or the designated language for the page—in lowercase. For example, if the running user’s language is “en-US”, this array will be ["am","pm"].

Skuid only ships with AM and PM markers in English - but you can add translations for any other languages you need by navigating to Setup > Custom Labels in Salesforce Setup, and searching for the Custom Label included in the Skuid namespace called AM PM Markers.
skuid.time.dayNames

An array of full-length day name Strings, localized according to the running user’s language setting or the designated language for the page. For example, if the running user’s language is “en-US”, this array will be ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].

Skuid ships with localized full-length day names for English, Spanish, French, and Swedish - but you can add translations for any other languages you need by navigating to Setup > Custom Labels in Salesforce Setup, and searching for the Custom Label included in the Skuid namespace called Day Names Long.
skuid.time.dayNamesMin

An array of 2-character day name Strings, localized according to the running user’s language setting or the designated language for the page. For example, if the running user’s language is “en-US”, this array will be ["Su","Mo","Tu","We","Th","Fr","Sa"].

Skuid ships with localized 2-character day names for English, Spanish, French, and Swedish - but you can add translations for any other languages you need by navigating to Setup > Custom Labels in Salesforce Setup, and searching for the Custom Label included in the Skuid namespace called Day Names Min.
skuid.time.dayNamesShort

An array of 3-character day name Strings, localized according to the running user’s language setting or the designated language for the page. For example, if the running user’s language is “en-US”, this array will be ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].

Skuid ships with localized 3-character day names for English, Spanish, French, and Swedish - but you can add translations for any other languages you need by navigating to Setup > Custom Labels in Salesforce Setup, and searching for the Custom Label included in the Skuid namespace called Day Names Short.
skuid.time.monthNames

An array of month name Strings, localized according to the running user’s language setting or the designated language for the page. For example, if the running user’s language is “en-US”, this array will be ["January","February", ... , "December"].

Skuid ships with localized month names for English, Spanish, French, and Swedish - but you can add translations for any other languages you need by navigating to Setup > Custom Labels in Salesforce Setup, and searching for the Custom Label included in the Skuid namespace called Month Names Long.
skuid.time.monthNamesShort

An array of abbreviated month name Strings, localized according to the running user’s language setting or the designated language for the page. For example, if the running user’s language is “en-US”, this array will be ["Jan","Feb", ... , "Dec"].

Skuid ships with localized abbreviated month names for English, Spanish, French, and Swedish - but you can add translations for any other languages you need by navigating to Setup > Custom Labels in Salesforce Setup, and searching for the Custom Label included in the Skuid namespace called Month Names Short.