- Core Concepts
- Epoch is January 1, 1970 UTC, starting time
- Time since epoch excludes leap seconds on POSIX-compliant systems
- Functions may not handle dates before epoch or far in future
- Time Representation
- Time returned by gmtime() and localtime() is 9-integer struct_time
- UTC (Coordinated Universal Time) is used for time calculations
- DST (Daylight Saving Time) adjusts timezone by one hour
- Key Functions
- time() returns time in seconds since epoch as floating-point
- strftime() converts time to string using various format directives
- asctime() formats time as string with specified format
- clock_gettime() and clock_settime() manage system clocks
- Timezone Support
- TZ environment variable controls time conversion rules
- Supports both non-DST and DST timezones
- Zoneinfo database available on many Unix systems
- Daylight saving time rules vary by location
- Precision
- Unix systems typically tick only 50-100 times per second
- Time() and sleep() provide better precision than Unix equivalents
- Precision loss may occur due to floating-point type