Objects>Time
Introduction Installation Beginning Admin Quick Ref FTP Server SMTP Server Database Security
Statements Objects String Parsing Events Queues Samples Special names Error Handling Accessories   Back
Caravan Business Server>Help>Objects>Time
Syntax <caravan>time <ObjectName> </caravan>
Objectname is any variable. e.g time x
Text The date & time values are stored in a special Time object.

The data type 'Time' in the Caravan database also has the same properties and can be accessed in the same manner as the Time object.

The sub components of Time are:
Description Caravan keyword
Year Year or yy
Month Month or mm
Date of the month Date or dd
Day of the week Day
Hour Hour
Minute Minute
Second Second
Time Time <Value>

The current date and time can be accessed by declaring the Time object and accessing its sub components.

The sub components of the Time object can be assigned to temporary variables.

Note:
Time is represented by a 32 bit value in unix time format -- seconds since 1st January, 1970.
Sample Example:
<caravan>
// to show time in dd/mm/yy hour:minute
Time t
      t(dd);"/";t(mm);"/";t(yy);" ";t(hour);":";t(minute)
</caravan>

Example:
<caravan>
// 3 combo boxes, listing the date,month and year.
// Selection of the current date, month and year

      Var dd
      dd(delim)=","
      dd(dates)="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31"
      dd(months)="Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
      dd(Years)="1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004"
      dd(hours)="0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24"


      time t
</caravan>
<Select name="dateFrom" value="ALL">
<caravan>
                  LOOP  d (dd(dates(00)))
                        if t(date)=dd(dates(d(count)))
                              "<OPTION SELECTED>";dd(dates(d(count)));
                        else
                              "<OPTION>";dd(dates(d(count)));
                        endif
                  REPEAT d 100
</caravan>


<Select name="monthFrom">
<caravan>
                  LOOP  d (dd(months(00)))
                        if t(month)=dd(months(d(count)))
                              "<OPTION SELECTED>";dd(months(d(count)));
                        else
                              "<OPTION>";dd(months(d(count)));
                        endif
                  REPEAT d 100
</caravan>


<Select name="YearFrom">
<caravan>

                  LOOP  d (dd(years(00)))
                        if t(Year)=dd(Years(d(count)))
                              "<OPTION SELECTED>";dd(Years(d(count)));
                        else
                              "<OPTION>";dd(Years(d(count)));
                        endif
                  REPEAT d 100
</caravan>



Example:
<caravan>
//Construct a new time
      Time tStart
      tStart(month)="9"
      tStart(date)="8"
      tStart(year)="2004"
      tStart(hour)= "8"
      tStart(minute)="00"
      tStart(second)="00"
      tstart(time) ;//displays the time in numeric value
</caravan>

Example:
<caravan>
// define a time difference of 15 minutes between 2 time objects
      Time tStart
      Time tEnd            
      Time from
      // define the start time
      tStart(month)=from(mm)
      tStart(date)=from(date)
      tStart(year)=from(year)
      tStart(hour)= "8"
      tStart(minute)="00"
      tStart(second)="00"
            
      //define the end time, 15 minutes ahead of start time.
      tEnd(month)=from(mm)
      tEnd(date)=from(date)
      tEnd(year)=from(year)
      tEnd(hour)= "8"
      tEnd(minute)="0"
      tEnd(minute)+="15"
      tEnd(second)="00"
</caravan>
Quick Reference
Properties Time
Year
Month
Day
Date
Hour
Minute
Second
Home       Back