Localization: 4.4 International Formats: Dates and Times

Up: GEOS SDK TechDocs | Up | Prev: 4.3 Quotation Marks | Next: 4.5 Filters for Formats
LocalFormatDateTime(), LocalParseDateTime(),
LocalGetDateTimeFormat(), LocalSetDateTimeFormat(),
LocalCustomFormatDateTime(), LocalCustomParseDateTime(), LocalCalcDaysInMonth(), LocalFormatFileDateTime()

LocalFormatDateTime() and LocalParseDateTime() allow display and parsing of date and time strings in a variety of formats. Passed the appropriate data, LocalFormatDateTime() will return a string with the data appropriately formatted. LocalParseDateTime() performs the reverse function, reading a string and attempting to extract information from it. The strings these functions use should be long enough to hold a formatted date or time. The predefined constant DATE_TIME_BUFFER_SIZE is the minimum recommended number of characters for one of these strings.

Localization functions use DateTimeFormat s to keep track of what sort of format is desired. If told to parse "5:28" as hours and minutes, LocalParseDateTime() will (depending on the user's time format preferences) return 5 in the hours place and 28 in the minutes place. If told to parse "5/28" as hours and minutes, LocalParseDateTime() would return an error. There are a variety of DateTimeFormats() to choose from, and you should decide which format to use based on what information you want your application to display or read.

Each DateTimeFormat has a string associated with it that contains formatting information. This string consists of the characters of the format, with place-holding tokens for the fields of the date or time. These tokens are delimited by the special character "|". For example, the date/time format string "|HH|:|mm| |ap|" would correspond to the formatted string "10:37 am". The string for each DateTimeFormat can be accessed or altered with the LocalGetDateTimeFormat() and LocalSetDateTimeFormat() commands. The recommended minimum size of a date/time format string is the constant DATE_TIME_FORMAT_SIZE.

If you don't wish to work through one of the standard DateTimeFormat values, you can construct a string containing some date/time tokens and pass it as an argument to LocalCustomFormatDateTime() , along with the appropriate date and time information. To parse a date/time using a custom format, use LocalCustomParseDateTime() .

The LocalFormatFileDateTime() utility routine works in the same way as LocalFormatDateTime() , except it takes a FileDateAndTime argument. It is normally used to format the information returned by FileGetDateAndTime() or TimerGetFileDateTime() .

The LocalCalcDaysInMonth() utility routine takes a month number and returns the number of days in that month.

A number of constants have been set up to aid in the computation of the size of string necessary to hold a date/time or a date/time format string. These constants are DATE_TIME_BUFFER_SIZE, DATE_TIME_FORMAT_SIZE, MAX_MONTH_LENGTH , MAX_DAY_LENGTH, MAX_YEAR_LENGTH, MAX_WEEKDAY_LENGTH , MAX_SEPARATOR_LENGTH, and TOKEN_LENGTH .


Up: GEOS SDK TechDocs | Up | Prev: 4.3 Quotation Marks | Next: 4.5 Filters for Formats