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
* Address MicrosoftDocs/cpp-docs/issues/484 TZNAME_MAX obsolete
* Add comments to the sample
* Update tzname-max.md
- Clarify how to find the equivalent information.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/get-tzname.md
+51-10Lines changed: 51 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "_get_tzname | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "11/04/2016"
4
+
ms.date: "10/22/2018"
5
5
ms.technology: ["cpp-standard-libraries"]
6
6
ms.topic: "reference"
7
7
apiname: ["_get_tzname"]
@@ -44,6 +44,14 @@ The size of the *timeZoneName* character string in bytes.
44
44
*index*<br/>
45
45
The index of one of the two time zone names to retrieve.
46
46
47
+
|*index*|Contents of *timeZoneName*|*timeZoneName* default value|
48
+
|-|-|-|
49
+
|0|Time zone name|"PST"|
50
+
|1|Daylight standard time zone name|"PDT"|
51
+
|> 1 or < 0|**errno** set to **EINVAL**|not modified|
52
+
53
+
Unless the values are explicitly changed during run time, the default values are "PST" and "PDT" respectively.
54
+
47
55
## Return Value
48
56
49
57
Zero if successful, otherwise an **errno** type value.
@@ -62,17 +70,51 @@ If either *timeZoneName* is **NULL**, or *sizeInBytes* is zero or less than zero
62
70
63
71
## Remarks
64
72
65
-
The **_get_tzname** function retrieves the character string representation of the time zone name or the daylight standard time zone name (DST) into the address of *timeZoneName* depending on the index value, along with the size of the string in *pReturnValue*. If *timeZoneName* is **NULL** and *sizeInBytes* is zero, just the size of the string of either time zone in bytes is returned in *pReturnValue*. The index values must be either 0 for standard time zone or 1 for daylight standard time zone; any other values of index have undetermined results.
73
+
The **_get_tzname** function retrieves the character string representation of the current time zone name or the daylight standard time zone name (DST) into the address of *timeZoneName* depending on the index value, along with the size of the string in *pReturnValue*. If *timeZoneName* is **NULL** and *sizeInBytes* is zero, the size of the string required to hold the specified time zone and a terminating null in bytes is returned in *pReturnValue*. The index values must be either 0 for standard time zone or 1 for daylight standard time zone; any other values of *index* have undetermined results.
66
74
67
-
### Index values
75
+
##Example
68
76
69
-
|*index*|Contents of *timeZoneName*|*timeZoneName* default value|
|> 1 or < 0|**errno** set to **EINVAL**|not modified|
77
+
This sample calls **_get_tzname** to get the required buffer size to display the current Daylight standard time zone name, allocates a buffer of that size, calls **_get_tzname** again to load the name in the buffer, and prints it to the console.
74
78
75
-
Unless the values are explicitly changed during run time, the default values are "PST" and "PDT" respectively. The sizes of these character arrays are governed by **TZNAME_MAX** value.
79
+
```C
80
+
// crt_get_tzname.c
81
+
// Compile by using: cl /W4 crt_get_tzname.c
82
+
#include<stdio.h>
83
+
#include<time.h>
84
+
#include<malloc.h>
85
+
86
+
enum TZINDEX {
87
+
STD,
88
+
DST
89
+
};
90
+
91
+
intmain()
92
+
{
93
+
size_t tznameSize = 0;
94
+
char * tznameBuffer = NULL;
95
+
96
+
// Get the size of buffer required to hold DST time zone name
97
+
if (_get_tzname(&tznameSize, NULL, 0, DST))
98
+
return 1; // Return an error value if it failed
99
+
100
+
// Allocate a buffer for the name
101
+
if (NULL == (tznameBuffer = (char *)(malloc(tznameSize))))
102
+
return 2; // Return an error value if it failed
103
+
104
+
// Load the name in the buffer
105
+
if (_get_tzname(&tznameSize, tznameBuffer, tznameSize, DST))
106
+
return 3; // Return an error value if it failed
107
+
108
+
printf_s("The current Daylight standard time zone name is %s.\n", tznameBuffer);
109
+
return 0;
110
+
}
111
+
```
112
+
113
+
### Output
114
+
115
+
```Output
116
+
The current Daylight standard time zone name is PDT.
117
+
```
76
118
77
119
## Requirements
78
120
@@ -89,4 +131,3 @@ For more information, see [Compatibility](../../c-runtime-library/compatibility.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/tzname-max.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "TZNAME_MAX | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "11/04/2016"
4
+
ms.date: "10/22/2018"
5
5
ms.technology: ["cpp-standard-libraries"]
6
6
ms.topic: "conceptual"
7
7
f1_keywords: ["TZNAME_MAX"]
@@ -14,7 +14,7 @@ ms.workload: ["cplusplus"]
14
14
---
15
15
# TZNAME_MAX
16
16
17
-
The maximum permissible string length for a time zone name variable.
17
+
**Obsolete**. The maximum permissible string length for a time zone name variable. This macro was defined in \<limits.h> in Visual Studio 2012 and earlier versions. It is not defined in Visual Studio 2013 and later versions. To get the length required to hold the current time zone name, use [_get_tzname](../c-runtime-library/reference/get-tzname.md).
18
18
19
19
## Syntax
20
20
@@ -26,4 +26,4 @@ The maximum permissible string length for a time zone name variable.
0 commit comments