Home arrow Articles arrow Paradox Programming arrow Paradox Date, Time, and DateTime Data Types: Introduction and Internal Formats
11 October 2008
 
 
Paradox Date, Time, and DateTime Data Types: Introduction and Internal Formats PDF Print E-mail
Contributed by Rick Kelly   
23 June 2001
Get ready for this series on dates by checking out part 1: Introduction and Internal Formats!Paradox® Date, Time, and DateTime Data Types
Introduction and Internal Formats
© 2001 Rick Kelly
www.crooit.com

Download the library containing the routines used in this series.

Preface

Time is represented in Paradox as:
  1. Date - A specific day
  2. Time - Time of day
  3. DateTime - A specific day and time
ObjectPAL® (OPAL) has many methods available for the manipulation of these values, including arithmetical operations. The basis for many OPAL methods revolves around the internal representation of each type. We will take a look at each type and its internal storage format and how this information can be used as the foundation for extending the capability of OPAL calculations and derivations in ways that are not dependent on environmental settings such as those found in the BDE and Windows.

The following definitions will form the basis of the presented OPAL methods in later sections.


Date

In OPAL, you can externally represent Date values in either month/day/year, day-month-year, or day.month.year format as determined by the formatSetDateDefault method (System type), or by custom OPAL formatting statements for other external representations.

Internally, Date values are stored as long integers representing the number of days since January 1 of year 1 which is day 1. The span of dates supported is an incredible May 4, -30799 (-2,147,483,648) to July 11, 18629 (2,147,483,647). Later, we will see how dates prior to January 1, 0001 need to be adjusted for accurate calculations.

For example:

June 21, 2001 is stored as 730,657
December 25, 1950 is stored as 712,216

This internal Date type format will be defined for future reference as:

Definition: liFixedDate = Internal long integer Date type
Calculation: longInt(daAny) where daAny is an OPAL Date type


Time

OPAL Time variables store times in hour-minute-second-millisecond format.

Internally, Time values are stored as long integers representing the number of milliseconds since midnight which is 0. Range of possible values is 0 - 86,359,999 for a total of 86,400,000 milliseconds in each day.

For example:

12:00:00 PM (Noon) is stored as 43,200,000
06:00:00 AM is stored as 2,160,000

This internal Time type format will be defined for future reference as:

Definition: liFixedTime = Internal long integer Time type
Calculation: longInt(tiAny) where tiAny is an OPAL Time type


DateTime

OPAL DateTime variables store data in the form hour-minute-second-millisecond year-month-day format.

Internally, DateTime values are stored as a floating point number representing the number of milliseconds from midnight January 1, 0001.

For example:

June 1, 2001 at 12:00:00 PM (Noon) = 63,127,080,000,000

This internal DateTime type format will be defined for future reference as:

Definition: nuFixedDateTime = Internal Number DateTime type
Calculation: number(dtAny) where dtAny is an OPAL DateTime type


Next: Adjustments to Dates prior to January 1, 0001

References
Common / Shared ObjectPALŽ Routines
< Prev   Next >
 
Top! Top!