一. 时间和日期例程
时间获取函数,计算自协调世界时开始的积累时间:
#include<time.h>
time_t time(time_t *calptr); //时间值既可由参数calptr携带,也为返回值
int clock_gettime(clockid_t clock_id, struct timespec *tsp);
以下函数获取当前时间(年:月:日):
#include<time.h>
struct tm *gmtime(const time_t *calptr); //获取当前系统时间,返回指向tm的指针
struct tm *localtime(const time_t *calptr);
size_t strftime(char *restrict buf, size_t maxsize, const char *restrict format, const struct tm *restrict tmptr); //把时间结构转换为字符串,存入到buf中
char *strptime(const char *restrict buf, const char *restrict format, struct tm *restrict tmptr); //把字符串转换分解为时间