contents   index   previous   next



Clib.localtime()

syntax:

Clib.localtime(timeInt)

where:

timeInt - an integer time value.

 

return:

object - a time object reflecting the value timeInt (as returned by the Clib.time() function).

 

description:

This method returns the value timeInt (as returned by the time() function) as a Time object. Note that the Time object differs from the Date object, although they contain the same data. The Time object is for use with the other date and time functions in the Clib object. It has the following integer properties:

 

.tm_sec
second after the minute (from 0)

.tm_min
minutes after the hour (from 0)

.tm_hour
hour of the day (from 0)

.tm_mday
day of the month (from 1)

.tm_mon
month of the year (from 0)

.tm_year
years since 1900 (from 0)

.tm_wday
days since Sunday (from 0)

.tm_yday
day of the year (from 0)

.tm_isdst
daylight-savings-time flag

 

The following function prints the current date and time on the screen and returns the day of the year, where Jan 1 is the 1st day of the year.

 

see:

Clib.mktime(), Date Object, Date toDateString(), Date toLocaleDateString()

 

example:

// Show today's date

// Return day of the year in USA format 

ShowToday() 

      // get current time structure 

   var tm = Clib.localtime(Clib.time()); 

      // display the date in USA format 

   Clib.printf("Date: %02d/%02d/%02d   ",

               tm.tm_mon+1, 

   tm.tm_mday, tm.tm_year % 100); 

      // hour to run from 12 to 11, not 0 to 23 

   var hour = tm.tm_hour % 12; 

   if ( hour == 0 ) 

      hour = 12; 

      // print current time 

   Clib.printf("Time: % 2d:%02d:%02d\n", hour,

               tm.tm_min,

   tm.tm_sec); 

      // return day of year, Jan. 1 is day 1 

   return( tm.tm_yday + 1 ); 

}

 


Clib.mktime()