2.138 .format
This attribute allocates a format to an object.
With the datetime object this attribute defines the display format.
With the .format attribute of the setup object the format variant (number) can be queried.
Definition
-
Data type
string, object [ format ]
string, object [ text ] (datetime)
integer (setup)
-
Access
get, set
get, set (setup)
-
changed event
yes
Bei String ist es die Formatbeschreibung. Details hierzu finden Sie in der “Resource Reference” bei der Layoutressource format.
string |
format description |
identifier |
must be a format resource |
For details please refer to chapter “format” in the “Resource Reference”.
A format resource may only be specified if the attribute .formatfunc has not already been set (see also chapter “Format Functions” in manual “C Interface - Basics”).
This attribute defines the display format of the datetime object.
set
), values of the data type string and text resources can be specified.
Read access (get
) always returns a value of the data type string.
Value range
"" |
short date format (like "widget:d") |
widget:d |
system format: short date format |
widget:dd |
system format: short date format with 4-digit year |
widget:ddd |
system format: long date format |
widget:t |
system format: time format |
<format_string> |
format string for defining the display format |
The system formats depend on the language and region settings of the operating system. They completely determine the display format and cannot be combined with each other or with format strings. For example, no caption can be added to a system format.
Format strings consist of formatting characters that define which parts of a date are displayed and how those parts are displayed.
Table 1-2:
Formatting Character |
Display |
---|---|
d |
day with as many digits as necessary |
dd |
day with 2 digits, possibly with leading 0 |
ddd |
name of the weekday (language-dependent), abbreviated to 3 characters |
dddd |
full name of the weekday (language-dependent) |
h |
hour in 12-hour format with as many digits as necessary |
hh |
hour in 12-hour format with 2 digits, possibly with leading 0 |
H |
hour in 24-hour format with as many digits as necessary |
HH |
hour in 24-hour format with 2 digits, possibly with leading 0 |
m |
minute with as many digits as necessary |
mm |
minute with 2 digits, possibly with leading 0 |
M |
month with as many digits as necessary |
MM |
month with 2 digits, possibly with leading 0 |
MMM |
month name (language-dependent), abbreviated to 3 characters |
MMMM |
full month name (language-dependent) |
s |
second with as many digits as necessary |
ss |
second with 2 digits, possibly with leading 0 |
t |
morning or afternoon indicator (language-dependent, in English AM and PM) with one character; use is not recommended. |
tt |
morning or afternoon indicator (language-dependent, in English AM and PM) with 2 characters |
yy |
year with 2 digits |
yyyy |
year with 4 digits |
Any characters other than the formatting characters mentioned are included in the display. Characters to be displayed may optionally be enclosed in single quotes ('). They must be enclosed in single quotes if they are equivalent to a formatting character. To display a single quotation mark, it must be doubled in the format string ('').
Example
The format string 'Today is 'dddd', 'MMM dd', 'yyyyy produces the following output: Today is Friday, Jul 04, 2014.
Notes
- If the format string is incorrect, the system-dependent standard format is used (corresponds to .format ="").
- The labels and symbols displayed for ddd, dddd, MMM, MMMM, t, and tt are determined by the language and region settings of the system.
- With long display texts, it may happen that no calendar symbol is displayed on the button for opening the calendar.
With the .format attribute of the setup object the format variant (number) can be queried.