gettimeofday
2015-09-12 14:21
417 查看
函数原型
函数描述
gettimeofday与settimeofday分别可以用来获取和设置时间,时区信息。
tv参数的结构: 头文件<sys/time.h>
struct timeval
{
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
} timeval的字段类型通常为long类型
tz参数的结构: struct timezone
{
int tz_minuteswest;/* minutes west of Greenwich */
int tz_dsttime; /* type of DST correction */
};
如果tv或者tz为NULL,对应的信息并不会被设置返回。
另外tz参数在linux是被废弃的,引用linux man中的一段话:
#include <sys/time.h> int gettimeofday(struct timeval *tv, struct timezone *tz); int settimeofday(const struct timeval *tv, const struct timezone *tz); 返回值 : 正确返回0 失败返回-1,并且设置对应的errno的值
函数描述
gettimeofday与settimeofday分别可以用来获取和设置时间,时区信息。
tv参数的结构: 头文件<sys/time.h>
struct timeval
{
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
} timeval的字段类型通常为long类型
tz参数的结构: struct timezone
{
int tz_minuteswest;/* minutes west of Greenwich */
int tz_dsttime; /* type of DST correction */
};
如果tv或者tz为NULL,对应的信息并不会被设置返回。
另外tz参数在linux是被废弃的,引用linux man中的一段话:
The use of the timezone structure is obsolete; the tz argument should normally be specified as NULL. The tz_dsttime field has never been used under Linux; it has not been and will not be supported by libc or glibc. Each and every occurrence of this field in the kernel source (other than the declaration) is a bug.
相关文章推荐
- Android 4.4 Kitkat Phone工作流程浅析(八)__Phone状态分析
- Ztree之复选框功能(三)
- Linux目录
- linux c 检测网络状态
- hdoj 2404 Permutation Recovery 【水题(规律)】
- 堆和栈的区别
- Android基础之json数据的几种解析方法
- IOS开发者常用的10个Xcode插件
- HttpRequest信息内容介绍
- php后管理分类导航菜单
- Android 4.4 Kitkat Phone工作流程浅析(九)__状态通知流程分析
- Android xml资源文件中@、@android:type、@*、?、@+含义和区别
- Android 4.4 Kitkat Phone工作流程浅析(十)__"通话显示"查询流程
- Latex 文本编辑技巧
- Streaming iPod Audio Tracks From Disk With Core Audio
- Latex 文本编辑技巧
- strpos查找字符串的注意事项
- Intent常用使用汇总
- Web前端开发面试题系列一
- 关于ConcurrentHashMap的size的思考