Skip to content

Commit b69d5e1

Browse files
authored
Merge pull request #2536 from corob-msft/cr-1762
Address issue 1762 in _mkgmtime
2 parents 0ce212d + d3d5956 commit b69d5e1

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

docs/c-runtime-library/reference/mkgmtime-mkgmtime32-mkgmtime64.md

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "_mkgmtime, _mkgmtime32, _mkgmtime64"
3-
ms.date: "11/04/2016"
3+
description: "Describes the _mkgmtime, _mkgmtime32, and _mkgmtime64 C Runtime library functions, and gives examples of how to use them."
4+
ms.date: "12/04/2019"
45
api_name: ["_mkgmtime32", "_mkgmtime64", "_mkgmtime"]
56
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-time-l1-1-0.dll"]
67
api_type: ["DLLExport"]
@@ -29,34 +30,26 @@ __time64_t _mkgmtime64(
2930

3031
### Parameters
3132

32-
*timeptr*<br/>
33+
*timeptr*\
3334
A pointer to the UTC time as a **struct** **tm** to convert.
3435

3536
## Return Value
3637

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.
3839

3940
## Remarks
4041

4142
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.
4243

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.
4445

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.
4647

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**.
4849

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.
5051

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
6053

6154
```C
6255
// crt_mkgmtime.c
@@ -93,8 +86,6 @@ int main()
9386
}
9487
```
9588

96-
### Sample Output
97-
9889
```Output
9990
Seconds since midnight, January 1, 1970
10091
My time: 1171588492
@@ -105,7 +96,7 @@ Local Time: Thu Feb 15 17:14:52 2007
10596
Greenwich Mean Time: Fri Feb 16 01:14:52 2007
10697
```
10798

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.
109100

110101
```C
111102
// crt_mkgmtime2.c
@@ -142,8 +133,6 @@ int main()
142133
}
143134
```
144135

145-
### Output
146-
147136
```Output
148137
Before calling _mkgmtime, t1 = Sun Feb 12 00:00:00 2003
149138
t.tm_yday = 0
@@ -153,11 +142,11 @@ t.tm_yday = 42
153142

154143
## See also
155144

156-
[Time Management](../../c-runtime-library/time-management.md)<br/>
157-
[asctime, _wasctime](asctime-wasctime.md)<br/>
158-
[asctime_s, _wasctime_s](asctime-s-wasctime-s.md)<br/>
159-
[gmtime, _gmtime32, _gmtime64](gmtime-gmtime32-gmtime64.md)<br/>
160-
[gmtime_s, _gmtime32_s, _gmtime64_s](gmtime-s-gmtime32-s-gmtime64-s.md)<br/>
161-
[localtime_s, _localtime32_s, _localtime64_s](localtime-s-localtime32-s-localtime64-s.md)<br/>
162-
[mktime, _mktime32, _mktime64](mktime-mktime32-mktime64.md)<br/>
163-
[time, _time32, _time64](time-time32-time64.md)<br/>
145+
[Time Management](../../c-runtime-library/time-management.md)\
146+
[asctime, _wasctime](asctime-wasctime.md)\
147+
[asctime_s, _wasctime_s](asctime-s-wasctime-s.md)\
148+
[gmtime, _gmtime32, _gmtime64](gmtime-gmtime32-gmtime64.md)\
149+
[gmtime_s, _gmtime32_s, _gmtime64_s](gmtime-s-gmtime32-s-gmtime64-s.md)\
150+
[localtime_s, _localtime32_s, _localtime64_s](localtime-s-localtime32-s-localtime64-s.md)\
151+
[mktime, _mktime32, _mktime64](mktime-mktime32-mktime64.md)\
152+
[time, _time32, _time64](time-time32-time64.md)

0 commit comments

Comments
 (0)