[TOC] [Prev] [Next] [Bottom]



Format Attribute

A new attribute, FORMAT, is optional with many meta tags. It specifies how the output of the tag should be formatted.

All tags with an optional FORMAT attribute accept a format string of the form FORMAT=class:format, as detailed following.

CASE: Case Reformatting

Text can be converted as follows:

  • to uppercase with case:upper (for example, HEllo --> HELLO)
  • to lowercase with case:lower (for example, HEllo --> hello)
  • to wordcase with case:word (for example, HEllo --> Hello).

Words are defined as a sequence of non-whitespace characters delimited by whitespace.

NUM: Numeric Formatting

Numbers with at least one whole digit and optional fractional digits can be reformatted.

The format is specified by a comma-delimited list of values in this order:

FORMAT=num: grouping,
grouping separator,
fractional digits,
fraction separator,
positive prefix,
positive suffix,
negative prefix,
negative suffix

All eight items must be present, either with a specified value or nothing. For example, if you do not want any formatting for fractional digits there would be nothing between the commas, (,,).

You must address each of the eight items in the number formatting string, even if it is just to let Tango know not to do anything with one or more of the eight numerical formatting items in the list.

Each list item may be a maximum of 15 characters long. Spaces and case are significant.

The list items are described as follows:

  • grouping defines how you want your numbers grouped, for example, in groups of three. There are two ways to apply your grouping. They are:
    • A hyphen-delimited list of digits from the least-significant place (beginning from the right).
    • An asterisk (*) means repeat using the last specification; no number means the output remainder is untouched.

Examples:

3-* 1,234,567,890,123

This example repeats a grouping of "3".

3-1-2 1234567,89,0,123

This example groups six digits, beginning from the right, into three separate groups, one of three ("3") digits, one of one ("1"), and one of two ("2").

  • grouping separator defines the character that separates the groupings. In the previous example, it is a comma. It may be multiple characters.
  • fractional digits to show:
    • If a number is specified, that many digits are displayed; the value is truncated or 0-padded as appropriate.
    • If no number is specified, then the number of fractional digits passed in is displayed untouched.
  • fraction separator, may be multiple digits, and it is displayed even if no fractional digits are present. This is similar to a decimal place separator.
  • positive prefix determines the prefix used if the number is positive (for example, +).
  • positive suffix determines the suffix used if the number is positive.
  • negative prefix determines the prefix used if the number is negative (for example, -).
  • negative suffix determines the prefix used if the number is negative.

Do not include spaces unless they are intended. Commas, single quotes, and double quotes can be included by backslash-escaping (for example, \, or \"), or enclosing them in single or double quotes (for example, "," or `''). Anything following a backslash is taken literally.

Here are some examples of numeric formats. -1234.56 is formatted as:

Format

Format String

Example

Swiss Monetary

num:3-*,\,,2,.,SFrs.,,SFrs.,C

SFrs.1,234.56C

US Accounting

num:3-*,\,,2,.,$ ,,($ ,)

$(1,234.56)

French language numerals

num:3-*, ,3,\,,,,'- ',

- 1 234,560

credit sheet

num:,,,.,Balance: , credit,Balance: , debit

Balance: 1234.56 debit

Synonyms

There are synonyms provided for commonly used format strings.

Example synonyms are listed in the table following with formatted string, -1234567.890.

Format *

Equivalent Format

Sample Output

num:CA-accounting

num:US-accounting

num:3-*,\,,2,.,$ ,,($ ,),

($ 1,234,567.89)

num:comma-float

num:3-*,\,,,.,,,-,

-1,234,567.890

num:comma-integer

num:3-*,\,,0,,,,-,

-1,234,567

num:simple-float

num:,,,.,,,-,

-1234567.890

num:simple-integer

num:,,0,,,,-,

-1234567

*US = United States and CA=Canada.

TEL: Telephone Numbers

This formatting accepts as input text a sequence of digits, spaces, or punctuation marks, and outputs the digits in one of the following requested formats:

Format*

Sample Output

Input Restrictions

tel:US-short

tel:CA-short

819-1173

7-11 digits required

tel:US-long

tel:CA-long

(905) 819-1173

10-11 digits required

tel:US-intl

tel:CA-intl

+1 905 819-1173

10-11 digits required

tel:US-hyphen

tel:CA-hyphen

1-905-819-1173

10-11 digits required

*US = United States and CA=Canada.

DATETIME

The FORMAT attribute accepts the "%-" specifiers used by the dateFormat configuration variables, with the addition of a datetime: prefix. For example, datetime:%Y-%m-%d would specify an ODBC-style date (December 1st, 1998 would be formatted as "1998-12-01").

For more information, see "dateFormat, timeFormat, timestampFormat".

Tango attempts to guess what the date/time entered actually is. First, the dateFormat, timeFormat, and timestampFormat configuration variables are used to test the input string for a perfect match, and failing these, the procedures as used by the <@ISDATE> family of tags are tested. If the input cannot be determined, a warning is logged and reformatting does not take place.

Tags that accepted a format attribute in previous versions of Tango--<@CURRENTTIME>, <@CURRENTIMESTAMP>, and <@CURRENTDATE>--can be used with the new FORMAT attribute or with their old formatting.

There is only one datetime-class synonym: datetime:http.

datetime:http = datetime:%A, %d-%b-%Y %H:%M:%S GMT.

For more information, see "<@TOGMT>".

For example, if the string 1998-09-29 12:34:56 were formatted with datetime:http, the output format would be "Monday, 29-Sep-1998 12:34:56 GMT".


!Note: datetime:http formatting does not make any adjustments to the time value to correct to GMT time. It simply outputs the input timestamp in the HTTP format. To convert a local time to GMT, use <@TOGMT>.




[TOC] [Prev] [Next] [Bottom]



docs@pervasive.com

Copyright © 1998, Pervasive Software Inc. All rights reserved.