regulardate(
SUPERDATE
)

The regulardate( function extracts a regular date (number of days from January 1, 4713 B.C.) from a superdate.


Parameters

This function has one parameter:

superdate – is a number that combines the date and time into a single value. See the superdate( function.


Description

The regulardate( function extracts a regular date (number of days from January 1, 4713 B.C.) from a superdate. SuperDates combine the date and time into a single number…the number of seconds since January 1, 1904. SuperDates make it easy to calculate time inter- vals across multiple days. However, SuperDates take up more storage than regular dates, and are not as easy to work with. In addition, SuperDates are limited to dates after 1904 AD.

In its heyday, the Santa Fe Super Chief train would travel between Chicago and Los Angeles in 39 and 1/2 hours. This example uses SuperDates to calculate the arrival time and day when the user enters the departure time.

local Arrival,Departure,xTime
xTime="7:30 pm"
gettext "Departure Time",xTime
Departure=superdate(today(),time(xTime))
Arrival=Departure+superdate(0,time("39:30:00"))
message "Arrives "+datepattern(regulardate(Arrival),"DayOfWeek")+
    " at "+timepattern(regulartime(Arrival),"hh:mm am/pm")

If the train leaves at 7:30 pm on Monday, the message will be Arrives Wednesday at 11:00 am. As you can see, SuperDate arithmetic is very easy, just add or subtract. There’s no need to worry about crossing midnight, because that simply is the start of a new day.


See Also


History

VersionStatusNotes
10.0No ChangeCarried over from Panorama 6.0