time.h supplies C interfaces for calendar time and physical time. Calendar time can be represented compactly as time_t or decomposed into human-oriented fields in struct tm. section 8.5 section 8.8
Comparing two moments
A small elapsed-time measurement uses two timestamps: time_t first = time(0); /* work */ time_t second = time(0); double elapsed = difftime(second, first); The time function obtains the current calendar time, while difftime expresses the difference between two time_t values. TAKEAWAY: use time_t for representing a calendar moment and difftime for comparing such moments. section 8.5
struct tm exposes calendar components such as year, month, day, and second, but its fields use unequal conventions: tm_mon starts at 0, tm_year requires adding 1900, and tm_mday starts at 1. tm_wday, tm_yday, and tm_isdst provide weekday, day-of-year, and daylight-saving information. section 8.5
mktime normalizes the date fields, calculates weekday and day-of-year fields, adjusts a negative daylight-saving flag for the local platform, and returns the corresponding time_t. strftime formats a struct tm using conversion specifications such as %Y, %m, and %d. section 8.5

