C H A P T E R 2 0
Localizing Newton Applications
Using the Localization Features of the Newton
To use one of these values, access the appropriate slot by dereferencing
with a dot operator, as in the following example:
Using these predefined format specifications also saves the trouble of defining them
at compile time and initializing slots with the compile-time variables at run time.
Format specifications available from the
listed in "System-Defined Format Specifications" (page 17-11) in Newton
A date or time format specification is an array, the elements of which are
themselves two-element arrays. The first element in each two-element array is a
constant specifying the item to display. The second element is a constant specifying
the format in which to display that item.
The complete set of constants is listed in "Constants to Create Your Own
Specification" (page 17-13) in Newton Programmer's Reference.
For example, the two-element array
specifies that the day in a date string is to be displayed in abbreviated format, such
as "Wed". On the other hand, the two-element array
specifies that the day of the week is to be displayed in long
format, such as "Wednesday".
The following code example uses system-supplied constants to build an array of
pairs specifying the output of a date string. This array is
supplied as the argument to the
function, which returns the
format specification passed to the
function returns a string with the current time (returned by the
formatted as specified by the format specification:
// at compile time, define my array of
// element and format pairs
[kElementYear, kFormatNumeric],// year
[kElementDay, kFormatNumeric],// day of month
[kElementMonth, kFormatLong],// name of month
[kElementDayOfWeek, kFormatLong]// day of week
// create the formatSpec
// this spec returns a string such as "February 1, 1994"