O'Reilly logo

REALBasic: TDG, 2nd Edition by Matt Neuburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dates

A date actually means a date-time, to the nearest second. Dates are maintained by the system as an unsigned integer, which is sufficient to assign a unique number to every second from midnight of 1 January 1904 to some time in 2040. REALbasic maintains the date as a double, which extends the range from the year 1 to a much later date (I’m not sure exactly what the limit is, but it seems to be some time in the year 30,000). To provide access to date values in terms more congenial to human beings, dates are implemented in REALbasic as a class, the Date class.

Date Class Properties

A Date instance has Year, Month, Day, Hour, Minute, and Second properties, all integers, which manipulate the instance’s underlying date-time value in terms of human notions of a date’s components.

So, for example, to form a Date instance denoting 10 August 1954 at 3:00 A.M.:

dim d as date
d = new date
d.year = 1954
d.month = 8
d.day = 10
d.hour = 3
d.minute = 0
d.second = 0

A new Date instance is automatically assigned the current date-time value from the system clock. This provides a way to learn the current date-time. However, the new instance is not actually set to any value until you access one of its properties. You might thus access a property only in order to set the instance (in which case you might well throw away the result). So, for example:

dim d as date, i as integer
d = new date
i = d.year// don't really care, just initializing date

The actual underlying date-time value of a Date instance ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required