You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A pointer to the UTC time as a **struct****tm** to convert.
34
35
35
36
## Return Value
36
37
37
-
A quantity of type **__time32_t** or **__time64_t** representing the number of seconds elapsed since midnight, January 1, 1970, in Coordinated Universal Time (UTC). If the date is out of range (see the Remarks section) or the input cannot be interpreted as a valid time, the return value is -1.
38
+
A quantity of type **__time32_t** or **__time64_t** representing the number of seconds elapsed since midnight, January 1, 1970, in Coordinated Universal Time (UTC). If the date is out of range (see the Remarks section) or the input can't be interpreted as a valid time, the return value is -1.
38
39
39
40
## Remarks
40
41
41
42
The **_mkgmtime32** and **_mkgmtime64** functions convert a UTC time to a **__time32_t** or **__time64_t** type representing the time in UTC. To convert a local time to UTC time, use **mktime**, **_mktime32**, and **_mktime64** instead.
42
43
43
-
**_mkgmtime** is an inline function that evaluates to **_mkgmtime64**, and **time_t** is equivalent to **__time64_t**. If you need to force the compiler to interpret **time_t** as the old 32-bit **time_t**, you can define **_USE_32BIT_TIME_T**. This is not recommended because your application might fail after January 18, 2038 (the maximum range of a 32-bit **time_t**), and it is not allowed at all on 64-bit platforms.
44
+
**_mkgmtime** is an inline function that evaluates to **_mkgmtime64**, and **time_t** is equivalent to **__time64_t**. If you need to force the compiler to interpret **time_t** as the old 32-bit **time_t**, you can define **_USE_32BIT_TIME_T**. We don't recommend it, because your application might fail after January 18, 2038, the maximum range of a 32-bit **time_t**. It's not allowed at all on 64-bit platforms.
44
45
45
-
The time structure passed in will be changed as follows, in the same way as they are changed with the **_mktime** functions: the **tm_wday** and **tm_yday** fields are set to new values based on the values of **tm_mday** and **tm_year**. When specifying a **tm** structure time, set the **tm_isdst** field to:
46
+
The time structure passed in is changed as follows, in the same way as it's changed by the **_mktime** functions: the **tm_wday** and **tm_yday** fields are set to new values based on the values of **tm_mday** and **tm_year**. Because the time is assumed to be UTC, the **tm_isdst** field is ignored.
46
47
47
-
- Zero (0) to indicate that standard time is in effect.
48
+
The range of the **_mkgmtime32** function is from midnight, January 1, 1970, UTC to 23:59:59 January 18, 2038, UTC. The range of **_mkgmtime64**is from midnight, January 1, 1970, UTC to 23:59:59, December 31, 3000, UTC. An out-of-range date results in a return value of -1. The range of **_mkgmtime** depends on whether **_USE_32BIT_TIME_T** is defined. When it's not defined, which is the default, the range is the same as **_mkgmtime64**. Otherwise, the range is limited to the 32-bit range of **_mkgmtime32**.
48
49
49
-
- A value greater than 0 to indicate that daylight saving time is in effect.
50
+
Both **gmtime** and **localtime** use a common static buffer for the conversion. If you supply this buffer to **_mkgmtime**, the previous contents are destroyed.
50
51
51
-
- A value less than zero to have the C run-time library code compute whether standard time or daylight saving time is in effect.
52
-
53
-
The C run-time library uses the TZ environment variable to determine the correct daylight savings time. If TZ is not set, the operating system is queried to get the correct regional daylight savings time behavior. **tm_isdst** is a required field. If not set, its value is undefined and the return value from **mktime** is unpredictable.
54
-
55
-
The range of the **_mkgmtime32** function is from midnight, January 1, 1970, UTC to 23:59:59 January 18, 2038, UTC. The range of **_mkgmtime64** is from midnight, January 1, 1970, UTC to 23:59:59, December 31, 3000, UTC. An out-of-range date results in a return value of -1. The range of **_mkgmtime** depends on whether **_USE_32BIT_TIME_T** is defined. If not defined (the default) the range is that of **_mkgmtime64**; otherwise, the range is limited to the 32-bit range of **_mkgmtime32**.
56
-
57
-
Note that **gmtime** and **localtime** use a single statically allocated buffer for the conversion. If you supply this buffer to **mkgmtime**, the previous contents are destroyed.
58
-
59
-
## Example
52
+
## Examples
60
53
61
54
```C
62
55
// crt_mkgmtime.c
@@ -93,8 +86,6 @@ int main()
93
86
}
94
87
```
95
88
96
-
### Sample Output
97
-
98
89
```Output
99
90
Seconds since midnight, January 1, 1970
100
91
My time: 1171588492
@@ -105,7 +96,7 @@ Local Time: Thu Feb 15 17:14:52 2007
105
96
Greenwich Mean Time: Fri Feb 16 01:14:52 2007
106
97
```
107
98
108
-
The following example shows how the incomplete structure is filled out with the computed values of the day of the week and the day of the year.
99
+
The following example shows how the incomplete structure is filled out by **_mkgmtime**. It computes values for both the day of the week and of the year.
109
100
110
101
```C
111
102
// crt_mkgmtime2.c
@@ -142,8 +133,6 @@ int main()
142
133
}
143
134
```
144
135
145
-
### Output
146
-
147
136
```Output
148
137
Before calling _mkgmtime, t1 = Sun Feb 12 00:00:00 2003
0 commit comments