Skip to end of metadata
Go to start of metadata

This feature is new in Ignition version 7.9.7
Click here to check out the other new features
This function is used in Python Scripting.

Description

Returns a new dataset with Date columns as strings formatted according to the dateFormat specified.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.dataset.formatDates(dataset, dateFormat, locale)

  • Parameters

Dataset dataset - The starting dataset to format.

String  dateFormat A valid Java DateFormat string such as "yyyy-MM-dd HH:mm:ss". See system.date.format for more information on the valid characters.

Locale localeThe Locale to use for formatting. The Locale object is actually any of Java's Locales, which can be found here. The java Locale library must be imported, and the Locale must be defined in all caps. See the second example below for an idea of how that works. If no Locale is specified, the default Locale will be used. [optional]

  • Returns

Dataset - A new dataset, containing the formatted dates.

  • Scope

All

Code Examples
Code Snippet
# This example takes the dataset from a table component and formats the dates to look like Fri, Jan 22, 2018.
 
data = event.source.parent.getComponent('Table').data
formattedData = system.dataset.formatDates(data, "EEE, MMM d, yyyy")
Code Snippet
# This example formats the date similarly to the last example, but uses the Italian Locale, which causes the dates to be formatted with the Locale.
 
from java.util import Locale

data = event.source.parent.getComponent('Table').data
locale = Locale.ITALY
formattedDataFr = system.dataset.formatDates(data, "yyyy-MM-dd HH:mm:ss", locale)
  • No labels