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 • .tm_min • .tm_hour • .tm_mday • .tm_mon • .tm_year • .tm_wday • .tm_yday • .tm_isdst
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 ); } |