time — Supports manipulation of date and time in various formats.
The time class.c
Implemented in the C language.
The time class supports manipulation of date and time in various formats.
“Time Zero”: in general, a certain time point is identified by a computer as the number of seconds (or ticks – one tick is 1/60th of a second) from a certain “time zero” or “ epoch time”, which varies from system to system. In many UNIX version this corresponds to 00:00:00 GMT (Greenwich Mean Time) of January 1, 1970. On Mac OS time zero is midnight of January 1st, 1904. Biferno adopts the convention of using 00:00:00 of January 1, 1970 as the time zero for the time class. The above technique to represent an instant in time, i.e. a date including the time with second precision, is called timestamping.
Operations on dates and times are also supported. The individual elements of an object of the time class can be incremented or decremented, and dates and times can be added or subtracted. This example shows how to compute tomorrow’s date:
tomorrow = time() tomorrow.day++ // Increment the current day by 1
An alternative is:
tomorrow = time() tomorrow.hour += 24 // Add 24 hours to the current time
To add two objects of the time class means to add the respective timestamps. If the value resulting from an operation is outside of the allowed range, the value is automatically adjusted, as in:
tomorrow = time("31/1/2001")
tomorrow.day++
// the tomorrow variable contains the value: 1/2/2001