background image
C H A P T E R 2 0
Localizing Newton Applications
Using the Localization Features of the Newton
20-11
Functions that Use the Locale Setting To Determine Format
20
These functions are quite simple. You pass in a system clock value or a string, and
the function uses the date and time format information in the current locale bundle
to produce a string or a system clock value. Here are the functions of this type:
DateNTime(
time
)
HourMinute(
time
)
ShortDate(
time
)
StringToDate(
dateString
)
StringToTime(
timeString
)
For example:
DateNTime(Time());
Depending on the locale, this might return the string:
"04/17/1996 10:53am"
See the Newton Programmer's Reference for more information on these functions.
Functions that Take Format Specifications
20
These functions take a time value and a string format specification and return a
string formatted accordingly:
LongDateStr(
time, dateStrSpec
)
ShortDateStr(
time, dateStrSpec
)
TimeStr(
time, timeStrSpec
)
You can pass three kinds of format specifications:
You can use one of the pre-defined format specifications in
ROM_dateTimeStrSpecs
You can use the
GetDateStringSpec
function to create a new format
specification
You can use the
kIncludeAllElements
constant, which tells the functions
to use the format in the active locale
In all cases, the active locale bundle determines certain features of date and time
strings, specifically the order of elements and the separators used.
Using Formats from ROM_dateTimeStrSpecs
20
For commonly used format specifications, the system defines formats that can be
passed directly to the functions that accept format specifications. These formats are
stored in
ROM_dateTimeStrSpecs.
See Table 17-5 (page 17-12) in Newton
Programmer's Reference
for the list of available formats.
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна