結論
time_t time(time_t *t);
int gettimeofday(struct timeval *tv, struct timezone *tz);
int clock_gettime(clockid_t clk_id, struct timespec *tp); // when clk_id == CLOCK_REALTIME
これらの関数が返す時刻の値は Epoch からの経過時間とマニュアルに書かれている。
Epoch の定義は https://en.wikipedia.org/wiki/Unix_time によると
The Unix epoch is the time 00:00:00 UTC on 1 January 1970.
なのでタイムゾーンに関わらず UTC からの経過時刻で間違いない。
備考
gettimeofday() の引数 struct timezone *tz
は obsolete なので使わず NULL を指定するべき。
タイムゾーンを取得する C/C++ 標準の関数は c++ - How do I find the current system timezone? - Stack Overflow によるとないらしいが glibc では #include <time.h>
の前に _BSD_SOURCE を定義することで struct tm
に 2 つの拡張フィールドが追加される。
long tm_gmtoff; /* Seconds east of UTC */
const char *tm_zone; /* Timezone abbreviation */
tm_gmtoff は UTC から表される時間のオフセット(秒単位)で、正の値は本初子午線の東を示す。tm_zone はタイムゾーン名の短縮形を示す。