This class library contains abstract fields and functions for the implementation of date and time type fields. The fields allow you to store the date and time information in pure numeric forms as well as the standard ISO forms. The functions allow conversions between each of these forms, as well as performing calculations involving dates and times. The library also contains source code objects to manipulate date & time fields on the Windows platform, as well as source code objects to get the system time and date from the current platform.
The following fields are specifically designed to be inherited from, providing automatic validation and panel representation in a form the implementation platform can interpret.
The date or time is displayed in ISO form which depends on the specific settings of the implementation platform. In Windows the display of an ISO date or time can be changed from the International settings from the Control panel. On an AS/400 the format of an ISO date or time is controlled by system values.
Each of the fields scope an external (ISO) form of the field, and functions to perform the conversion. The OBASE class library has code in its function templates to call the conversion functions to transform each of the fields prior to displaying a panel, and immediately after reading a panel. If you don't use the OBASE functions you will need to call the conversion function yourself.
DATES
For storing a date as six digits in the form of YYMMDD where YY is the year, MM is the month and DD is the day inherit from ISO displayed numeric date 6.
For storing a date as seven digits in the form of CYYMMDD where YY is the year, MM is the month and DD is the day inherit from ISO displayed numeric date 7. The C is an IBM convention for representing a century. It is 0 if the year is between 40 and 99 inclusive and for any other year. If you add 1900 to the CYY part of the date 7 field you get the year with the true century.
For storing a date as eight digits in the form of CCYYMMDD where CCYY is the full year, MM is the month and DD is the day inherit from ISO displayed numeric date 8.
TIMES
For storing a time as six digits in the form of HHMMSS where HH is the hours, MM is the minutes and SS is the seconds inherit from ISO displayed numeric time. This assumes the time in the 24 hour format.
More primitive forms of the above dates and times are also provided in OBDATE and these can also be inherited from. They automatically provide validation but there is no transformation to or from panels.
They are:
DATES
For storing a date as six digits in the form of YYMMDD where YY is the year, MM is the month and DD is the day inherit from Numeric date 6.
For storing a date as seven digits in the form of CYYMMDD where YY is the year, MM is the month and DD is the day inherit from Numeric date 7. The C is an IBM convention for representing a century. It is 0 if the year is between 40 and 99 inclusive and for any other year. If you add 1900 to the CYY part of the date 7 field you get the year with the true century.
For storing a date as eight digits in the form of CCYYMMDD where CCYY is the full year, MM is the month and DD is the day inherit from Numeric date 8.
For storing a date in ISO form inherit from ISO date. The way the date is stored is determined by the database.
TIMES
For storing a time as six digits in the form of HHMMSS where HH is the hours, MM is the minutes and SS is the seconds inherit from Numeric time. This assumes the time in the 24 hour format.
For storing a date in ISO form inherit from ISO Time. The way the date is stored is determined by the database.
An alternative way of defining dates and times is to use a structured field. This method allows the component parts of the date or time to be referenced directly. The fields you can inherit from are:
Structure date
This field includes components for a 4 digit year, a 2 digit month and a 2 digit day.
Structure time
This field includes components for 2 digit hours, minutes and seconds.
The final type of field used for storing dates and times is a timestamp. This is a combination of date, time and microseconds. This type of field is not usually suitable for input on a panel but is useful for recording the exact date and time a row of a table is modified. The field you can inherit from is:
ISO timestamp
For storing date, time and microseconds in one field in the database in ISO form.
You want a... | Inherit from... |
......Date with | |
............Panel formatting & | |
..................YYMMDD on tables | ISO displayed numeric date 6 |
..................CYYMMDD on tables | ISO displayed numeric date 7 |
..................CCYYMMDD on tables | ISO displayed numeric date 8 |
..................ISO date on tables | ISO date |
..................Field components on tables | Structure date |
............No formatting & | |
..................YYMMDD on tables | Numeric date 6 |
..................CYYMMDD on tables | Numeric date 7 |
..................CCYYMMDD on tables | Numeric date 8 |
......Time with | |
............Panel formatting & | |
..................HHMMSS on tables | ISO displayed numeric time |
..................Field components on tables | Structure time |
............No formatting | Numeric time |
......Timestamp | ISO timestamp |