Try OpenEdge Now
skip to main content
Internationalizing Applications
Preparing the Code : Data-processing issues : Dates
 

Dates

There are several cultural components affecting dates that your application must consider when processing input:
*Calendar type
*Date format
*Business week
There are several different calendars (Japanese Emperor, Buddhist, Gregorian) in use around the world. Some countries use more than one calendar at a time, depending on the context. For example, the Japanese business community uses the Gregorian calendar, but the official calendar is the Japanese Emperor calendar, which has as its year one the first year of the current Emperor's rule. Also, there are many different formats for indicating dates within each calendar.
The difference that might have the most far-reaching impact on your application is how calendar dates are presented in different countries. The same date from the Gregorian calendar could be indicated as 16-02-2014, 2/16/2014, or other formats. The day/month order is different, as are the separators. Some locales use character symbols for the month or write it out. Note that your application must be sensitive to differences in dates not only in the case of user data, but also when it receives date information from the operating system, which is configured to support local conventions.
Another difference that might affect your application is the cultural definition of a week. The week's starting point (Sunday or Monday, for example) varies widely. In France, the first day of the week is Monday; in the United States, it is Sunday. Hard coding an extensive database backup routine that takes place on the evening of the fifth day of the week works well in France (day five is Friday), but might not be appreciated in New York where day five is Thursday and still the middle of the work week. Also, if you are writing an application that deals with the business week, consider that not every locale divides the week into the same five workdays and two leisure days. Arab countries do not typically conduct business on Friday. Some countries do not close businesses for a two-day weekend.
If you hard code date formats and dates, your application will have to be rewritten for any locale that expects a different calendar, date format, or business week.
Handle dates using the DATE data type. Store date data as integer data, which requires less storage space and is accessed more quickly than character data. Also, integer data, unlike character data, is independent and does not have to be converted for each market because of variations in characters sets or date formats. Whenever you include a date in a procedure or specify a date in the Data Dictionary, you must use the integer data type.
Also, OpenEdge provides the following methods for you to specify the display format of a date:
*The FORMAT option of the Format phrase allows you to specify a display format for all DATE data
*The Date Format (-d) startup parameter allows you to specify the order to display date information during an OpenEdge session. The internal storage format remains the same. The -d startup parameter is only a client startup parameter
*The DATE-FORMAT SESSION handle attribute allows you to specify the format for displaying dates during the current OpenEdge session
*The Century (-yy) startup parameter allows you to specify the current start date for the OpenEdge two-digit year range of 100 years. See its reference entry in OpenEdge Deployment: Startup Command and Reference.
*The DATE, DAY, MONTH, and YEAR functions allow you to convert data (string and numeric) into the DATE data type
For more information on the startup parameters, see OpenEdge Resources and OpenEdge Deployment: Startup Command and Parameter Reference. For more information on the functions, see OpenEdge Development: ABL Reference.
The following is an example of how to handle dates:

snhndl.p

DEFINE VARIABLE mynum AS DECIMAL NO-UNDO.

SESSION:DATE-FORMAT = "mdy".
DISPLAY SESSION:DATE-FORMAT SPACE(5) TODAY WITH FRAME d1.

SESSION:DATE-FORMAT = "dmy".
DISPLAY SESSION:DATE-FORMAT SPACE(5) TODAY FORMAT "99-99-99"
WITH FRAME d2.

DISPLAY SESSION:DATE-FORMAT SPACE(5) TODAY FORMAT "99.99.99"
WITH FRAME d3.

mynum = 12345.67.
SESSION:NUMERIC-FORMAT = "AMERICAN".
DISPLAY SESSION:NUMERIC-FORMAT mynum WITH FRAME f1 NO-LABELS.

SESSION:NUMERIC-FORMAT = "EUROPEAN".
DISPLAY SESSION:NUMERIC-FORMAT mynum WITH FRAME f2 NO-LABELS.
The h-snhndl.p procedure illustrates the read and write capability of the DATE-FORMAT and NUMERIC-FORMAT SESSION handle attributes. Note OpenEdge always handles data using periods as decimal separators within source code, even when you specify the EUROPEAN display format. The display format affects input and output when the application is executed, not when it is compiled.