# format(value, format-string)

Format(value,format_string) converts attributes to strings and lets you choose exactly how you prefer the data to appear. format() is useful for export and for preparing data for other programs and Web services.

For numbers, the first argument is the number of decimal places to which the number should be rounded. An optional third argument allows you to specify a total width for the formatted string.

For example, if $MyNum is 3.1415927, then

> `format($MyNum,2,7)` is " 3.14"

> `format($MyNum,2)` is 3.14

> `format($MyNum,0)` is 3

If value is a date, the format string is the same as the format used by Tinderbox's date export codes.

L: local time, in long format, using the system format settings (example: Tuesday, April 29, 2003.)

l: local time, in short format, using the system format settings (example: 4-29-03)

d: day of the month (example: 29)

D: formats date 01-31, with leading zero

m: number of month (example: 4)

M: abbreviation of month (example: Apr)

MM: name of month (example:April) w: abbreviation of weekday (example: Tue)

M0: formats month numerically 01-12, with leading 0

W: name of weekday (example: Tuesday)

y: year (example: 2003)

t: time, in local format (example: 2:32 pm)

h: hour of the day on a 24-hour clock (example: 13:39)

H: hour of the day on a 12-hour clock (example: 1:39)

mm: minute of the hour (example:05 for five minutes after the hour)

s: second

p: AM or PM

*: date/time in RFC 822 format (example: Thu, 18 Feb 2004 19:12:00 0500)

=: date in ISO 8601 format (example: 2004-02-18)

U: date as Unix epoch (seconds since 1 January 1970)

For example:

> `format($Created,"L")`

formats the note's creation date a "long local date" such as "Sunday, March 23, 2007 1:26pm".

If value is a list or set, the format string is the delimiter that is to be used to separate discrete list elements

> `format($KeyAttributes,",")`

converts key attributes to a comma-separated list.

Optionally, you may supply four quoted string arguments besides value to format the set as an HTML list:

> format(value,list-prefix,item-prefix,item-suffix,list-suffix)

For example

> `format($MyList,"<ul>","<li>","</li>","</ul>")`

If value is a number, then the arguments are numeric and interpreted as follows:

format(value,precision, width)

In quoted string arguments here (as elsewhere), \" is converted to a quotation mark, \n to a carriage return, and \t to a tab.