当前位置:网站首页>C standard library - < time h>
C standard library - < time h>
2022-04-23 02:04:00 【Huang Jiajun】
brief introduction
time.h The header file defines four variable types 、 Two macros and various functions of operation date and time .
Library variables
Here's the header file time.h Variable types defined in :
Serial number | Variable & describe |
---|---|
1 | size_t Is an unsigned integer type , It is sizeof Keyword results . |
2 | clock_t This is a type suitable for storage processor time . |
3 | time_t is This is a type suitable for storing calendar time . |
4 | struct tm This is a structure for saving time and date . |
tm The definition of structure is as follows :
struct tm { int tm_sec; /* second , Range from 0 To 59 */ int tm_min; /* branch , Range from 0 To 59 */ int tm_hour; /* Hours , Range from 0 To 23 */ int tm_mday; /* The day of the month , Range from 1 To 31 */ int tm_mon; /* month , Range from 0 To 11 */ int tm_year; /* since 1900 The number of years since */ int tm_wday; /* The day of the week , Range from 0 To 6 */ int tm_yday; /* The day of the year , Range from 0 To 365 */ int tm_isdst; /* Daylight saving time */ };
Library macro
Here's the header file time.h Macro defined in :
Serial number | macro & describe |
---|---|
1 | NULL This macro is the value of a null pointer constant . |
2 | CLOCKS_PER_SEC This macro represents the number of processor clocks per second . |
Library function
Here's the header file time.h The function defined in :
Serial number | function & describe |
---|---|
1 | char *asctime(const struct tm *timeptr) Returns a pointer to a string , It represents the structure timeptr The date and time of . |
2 | clock_t clock(void) Return to the beginning of program execution ( It's usually the beginning of a program ), The time used by the processor clock . |
3 | char *ctime(const time_t *timer) Returns a string representing the local time , Local time is based on parameters timer. |
4 | double difftime(time_t time1, time_t time2) return time1 and time2 The number of seconds between (time1-time2). |
5 | struct tm *gmtime(const time_t *timer) timer The value of is decomposed into tm structure , And use coordinated universal time (UTC) Also known as Greenwich mean time (GMT) Express . |
6 | struct tm *localtime(const time_t *timer) timer The value of is decomposed into tm structure , And expressed in local time zone . |
7 | time_t mktime(struct tm *timeptr) hold timeptr The structure pointed to is converted to a structure based on the local time zone time_t value . |
8 | size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr) according to format Formatting rules defined in , Format structure timeptr Time represented , And store it in str in . |
9 | time_t time(time_t *timer) Calculate the current calendar time , And code it into time_t Format . |
版权声明
本文为[Huang Jiajun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220842089600.html
边栏推荐
- What is BGP server and what are its advantages?
- 用TensorFlow实现线性回归(包括过程中出现的问题及解决方法)
- Introduction to micro build low code zero Foundation (lesson 2)
- How to write the resume of Software Test Engineer so that HR can see it?
- Is CICC fortune a company with CICC? Is it safe
- PID refinement
- Performance introduction of the first new version of cdr2022
- Shardingsphere read write separation
- 什么是api接口?
- 006_redis_jedis快速入门
猜你喜欢
Is it better to use a physical machine or a virtual machine to build a website?
Shardingsphere sub database and sub table
What businesses use physical servers?
Easyswool environment configuration
Is the availability of proxy IP equal to the efficiency of proxy IP?
Campus transfer second-hand market source code
007_Redis_Jedis连接池
011_RedisTemplate操作Hash
The leader / teacher asks to fill in the EXCEL form document. How to edit the word / Excel file on the mobile phone and fill in the Excel / word electronic document?
ESP32蓝牙Bluetooth Controller API介绍
随机推荐
009_Redis_RedisTemplate入门
Campus transfer second-hand market source code
How to choose a good dial-up server?
How to set computer IP?
Is CICC fortune a state-owned enterprise and is it safe to open an account
EBS:PO_EMPLOYEE_HIERARCHIES_ALL
2022.4.22-----leetcode.396
从开源爱好者到 Apache 董事,一共分几步?
Find the largest number of two-dimensional arrays
Error in face detection and signature of Tencent cloud interface
How to configure iptables to realize local port forwarding
[leetcode daily question] 396 Rotation function
关于局域网浅谈
Some tips for using proxy IP.
Thinkphp内核开发盲盒商城源码v2.0 对接易支付/阿里云短信/七牛云存储
MySQL active / standby configuration binary log problem
Halo open source project learning (I): project launch
C语言中如何“指名道姓”的进行初始化
Leetcode46 Full Permutation
The leader / teacher asks to fill in the EXCEL form document. How to edit the word / Excel file on the mobile phone and fill in the Excel / word electronic document?