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
Copy file name to clipboardExpand all lines: docs/atl-mfc-shared/date-and-time.md
+13-14Lines changed: 13 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -3,33 +3,32 @@ description: "Learn more about: Date and Time"
3
3
title: "Date and Time"
4
4
ms.date: "08/13/2019"
5
5
helpviewer_keywords: ["time, MFC programming", "time", "MFC, date and time", "dates, MFC"]
6
-
ms.assetid: ecf56dc5-d418-4603-ad3e-af7e205a6403
7
6
---
8
7
# Date and Time
9
8
10
9
MFC supports several different ways of working with dates and times:
11
10
12
-
- Support for the Automation [DATE data type](../atl-mfc-shared/date-type.md). DATE supports date, time, and date/time values. The [COleDateTime](../atl-mfc-shared/reference/coledatetime-class.md) and [COleDateTimeSpan](../atl-mfc-shared/reference/coledatetimespan-class.md) classes encapsulate this functionality. They work with the [COleVariant](../mfc/reference/colevariant-class.md) class using Automation support.
11
+
- Support for the Automation [`DATE` data type](../atl-mfc-shared/date-type.md). `DATE` supports date, time, and date/time values. The [`COleDateTime`](../atl-mfc-shared/reference/coledatetime-class.md) and [`COleDateTimeSpan`](../atl-mfc-shared/reference/coledatetimespan-class.md) classes encapsulate this functionality. They work with the [`COleVariant`](../mfc/reference/colevariant-class.md) class using Automation support.
13
12
14
-
- General-purpose time classes. The [CTime](../atl-mfc-shared/reference/ctime-class.md) and [CTimeSpan](../atl-mfc-shared/reference/ctimespan-class.md) classes encapsulate most of the functionality associated with the ANSI-standard time library, which is declared in TIME.H.
13
+
- General-purpose time classes. The [`CTime`](../atl-mfc-shared/reference/ctime-class.md) and [`CTimeSpan`](../atl-mfc-shared/reference/ctimespan-class.md) classes encapsulate most of the functionality associated with the ANSI-standard time library, which is declared in `time.h`.
15
14
16
15
- Support for system clock. With MFC version 3.0, support was added to `CTime` for the Win32 `SYSTEMTIME` and `FILETIME` data types.
17
16
18
17
## Date and Time: Automation Support
19
18
20
-
The [COleDateTime](../atl-mfc-shared/reference/coledatetime-class.md) class provides a way to represent date and time information. It provides finer granularity and a greater range than the [CTime](../atl-mfc-shared/reference/ctime-class.md) class. The [COleDateTimeSpan](../atl-mfc-shared/reference/coledatetimespan-class.md) class represents elapsed time, such as the difference between two `COleDateTime` objects.
19
+
The [`COleDateTime`](../atl-mfc-shared/reference/coledatetime-class.md) class provides a way to represent date and time information. It provides finer granularity and a greater range than the [`CTime`](../atl-mfc-shared/reference/ctime-class.md) class. The [`COleDateTimeSpan`](../atl-mfc-shared/reference/coledatetimespan-class.md) class represents elapsed time, such as the difference between two `COleDateTime` objects.
21
20
22
-
The `COleDateTime` and `COleDateTimeSpan` classes are designed for use with the `COleVariant` class. `COleDateTime` and `COleDateTimeSpan` are also useful in MFC database programming, but they can be used whenever you want to manipulate date and time values. Although the `COleDateTime` class has a greater range of values and finer granularity than the `CTime` class, it requires more storage per object than `CTime`. There are also some special considerations when working with the underlying DATE type. For more information on the implementation of DATE, see [The DATE Type](../atl-mfc-shared/date-type.md).
21
+
The `COleDateTime` and `COleDateTimeSpan` classes are designed for use with the `COleVariant` class. `COleDateTime` and `COleDateTimeSpan` are also useful in MFC database programming, but they can be used whenever you want to manipulate date and time values. Although the `COleDateTime` class has a greater range of values and finer granularity than the `CTime` class, it requires more storage per object than `CTime`. There are also some special considerations when working with the underlying DATE type. For more information on the implementation of `DATE`, see [The `DATE` Type](../atl-mfc-shared/date-type.md).
23
22
24
-
`COleDateTime` objects can be used to represent dates between January 1, 100, and December 31, 9999. `COleDateTime` objects are floating point values, with an approximate resolution of 1 millisecond. `COleDateTime` is based on the DATE data type, defined in the MFC documentation under [COleDateTime::operator DATE](../atl-mfc-shared/reference/coledatetime-class.md#operator_date). The actual implementation of DATE extends beyond these bounds. The `COleDateTime` implementation imposes these bounds to make it easier to work with the class.
23
+
`COleDateTime` objects can be used to represent dates between January 1, 100, and December 31, 9999. `COleDateTime` objects are floating point values, with an approximate resolution of 1 millisecond. `COleDateTime` is based on the `DATE` data type, defined in the MFC documentation under [`COleDateTime::operator DATE`](../atl-mfc-shared/reference/coledatetime-class.md#operator_date). The actual implementation of `DATE` extends beyond these bounds. The `COleDateTime` implementation imposes these bounds to make it easier to work with the class.
25
24
26
25
`COleDateTime` doesn't support Julian dates. The Gregorian calendar is assumed to extend back in time to January 1, 100.
27
26
28
27
`COleDateTime` ignores Daylight Saving Time (DST). The following code example compares two methods of calculating a time span that crosses the DST switchover date: one using the CRT, and the other using `COleDateTime`.
29
28
30
-
The first method sets two `CTime` objects, *time1* and *time2*, to April 5 and April 6 respectively, using the standard C type structures `tm` and `time_t`. The code displays *time1* and *time2* and the time span between them.
29
+
The first method sets two `CTime` objects, *`time1`* and *`time2`*, to April 5 and April 6 respectively, using the standard C type structures `tm` and `time_t`. The code displays *`time1`* and *`time2`* and the time span between them.
31
30
32
-
The second method creates two `COleDateTime` objects, `oletime1` and `oletime2`, and sets them to the same dates as *time1* and *time2*. It displays `oletime1` and `oletime2` and the time span between them.
31
+
The second method creates two `COleDateTime` objects, `oletime1` and `oletime2`, and sets them to the same dates as *`time1`* and *`time2`*. It displays `oletime1` and `oletime2` and the time span between them.
33
32
34
33
The CRT correctly calculates a difference of 23 hours. `COleDateTimeSpan` calculates a difference of 24 hours.
35
34
@@ -69,21 +68,21 @@ This procedure shows how to calculate the difference between two `COleDateTime`
69
68
70
69
#### To format a time
71
70
72
-
Use the `Format` member function of either [COleDateTime](../atl-mfc-shared/reference/coledatetime-class.md) or [COleDateTimeSpan](../atl-mfc-shared/reference/coledatetimespan-class.md) to create a character string representing the time or elapsed time.
71
+
Use the `Format` member function of either [`COleDateTime`](../atl-mfc-shared/reference/coledatetime-class.md) or [`COleDateTimeSpan`](../atl-mfc-shared/reference/coledatetimespan-class.md) to create a character string representing the time or elapsed time.
For more information, see class [COleVariant](../mfc/reference/colevariant-class.md).
75
+
For more information, see class [`COleVariant`](../mfc/reference/colevariant-class.md).
77
76
78
77
## Date and Time: Database Support
79
78
80
-
Starting in version 4.0, MFC database programming uses the [COleDateTime](../atl-mfc-shared/reference/coledatetime-class.md) and [COleDateTimeSpan](../atl-mfc-shared/reference/coledatetimespan-class.md) classes to represent date and time data. These classes, also used in Automation, are derived from class [COleVariant](../mfc/reference/colevariant-class.md). They supply better support for managing date and time data than do [CTime](../atl-mfc-shared/reference/ctime-class.md) and [CTimeSpan](../atl-mfc-shared/reference/ctimespan-class.md).
79
+
Starting in version 4.0, MFC database programming uses the [`COleDateTime`](../atl-mfc-shared/reference/coledatetime-class.md) and [`COleDateTimeSpan`](../atl-mfc-shared/reference/coledatetimespan-class.md) classes to represent date and time data. These classes, also used in Automation, are derived from class [`COleVariant`](../mfc/reference/colevariant-class.md). They supply better support for managing date and time data than do [`CTime`](../atl-mfc-shared/reference/ctime-class.md) and [`CTimeSpan`](../atl-mfc-shared/reference/ctimespan-class.md).
81
80
82
-
## Date and Time: SYSTEMTIME Support
81
+
## Date and Time: `SYSTEMTIME` Support
83
82
84
-
The [COleDateTime](../atl-mfc-shared/reference/coledatetime-class.md) class has constructors that accept system and file times from Win32.
83
+
The [`COleDateTime`](../atl-mfc-shared/reference/coledatetime-class.md) class has constructors that accept system and file times from Win32.
85
84
86
-
The Win32 `FILETIME` structure represents time as a 64-bit value. It's a more convenient format for internal storage than a `SYSTEMTIME` structure, and the format used by Win32 to represent the time of file creation. For information about the SYSTEMTIME structure, see [SYSTEMTIME](/windows/desktop/api/minwinbase/ns-minwinbase-systemtime). For information about the FILETIME structure, see [FILETIME](/windows/desktop/api/minwinbase/ns-minwinbase-filetime).
85
+
The Win32 `FILETIME` structure represents time as a 64-bit value. It's a more convenient format for internal storage than a `SYSTEMTIME` structure, and the format used by Win32 to represent the time of file creation. For information about the `SYSTEMTIME` structure, see [`SYSTEMTIME`](/windows/desktop/api/minwinbase/ns-minwinbase-systemtime). For information about the `FILETIME` structure, see [`FILETIME`](/windows/desktop/api/minwinbase/ns-minwinbase-filetime).
Copy file name to clipboardExpand all lines: docs/c-runtime-library/console-and-port-i-o.md
+18-19Lines changed: 18 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -3,33 +3,32 @@ description: "Learn more about: Console and Port I/O"
3
3
title: "Console and Port I/O"
4
4
ms.date: "11/04/2016"
5
5
helpviewer_keywords: ["routines, console and port I/O", "routines", "ports, I/O routines", "I/O [CRT], console", "I/O [CRT], port", "I/O routines, console and port I/O"]
6
-
ms.assetid: 0eee1c92-9b3d-41e0-a43a-257e546eeec8
7
6
---
8
7
# Console and Port I/O
9
8
10
-
These routines read and write on your console or on the specified port. The console I/O routines are not compatible with stream I/O or low-level I/O library routines. The console or port does not have to be opened or closed before I/O is performed, so there are no open or close routines in this category. In the Windows operating systems, the output from these functions is always directed to the console and cannot be redirected.
9
+
These routines read and write on your console or on the specified port. The console I/O routines aren't compatible with stream I/O or low-level I/O library routines. The console or port doesn't have to be opened or closed before I/O is performed, so there are no open or close routines in this category. In the Windows operating systems, the output from these functions is always directed to the console and can’t be redirected.
11
10
12
11
## Console and Port I/O Routines
13
12
14
13
|Routine|Use|
15
14
|-------------|---------|
16
-
|[_cgets, _cgetws](../c-runtime-library/cgets-cgetws.md), [_cgets_s, _cgetws_s](../c-runtime-library/reference/cgets-s-cgetws-s.md)|Read string from console|
17
-
|[_cprintf, _cwprintf](../c-runtime-library/reference/cprintf-cprintf-l-cwprintf-cwprintf-l.md), [_cprintf_s, _cprintf_s_l, _cwprintf_s, _cwprintf_s_l](../c-runtime-library/reference/cprintf-s-cprintf-s-l-cwprintf-s-cwprintf-s-l.md)|Write formatted data to console|
18
-
|[_cputs](../c-runtime-library/reference/cputs-cputws.md)|Write string to console|
19
-
|[_cscanf, _cwscanf](../c-runtime-library/reference/cscanf-cscanf-l-cwscanf-cwscanf-l.md), [_cscanf_s, _cscanf_s_l, _cwscanf_s, _cwscanf_s_l](../c-runtime-library/reference/cscanf-s-cscanf-s-l-cwscanf-s-cwscanf-s-l.md)|Read formatted data from console|
20
-
|[_getch, _getwch](../c-runtime-library/reference/getch-getwch.md)|Read character from console|
21
-
|[_getche, _getwche](../c-runtime-library/reference/getch-getwch.md)|Read character from console and echo it|
22
-
|[_inp](../c-runtime-library/inp-inpw-inpd.md)|Read one byte from specified I/O port|
23
-
|[_inpd](../c-runtime-library/inp-inpw-inpd.md)|Read double word from specified I/O port|
24
-
|[_inpw](../c-runtime-library/inp-inpw-inpd.md)|Read 2-byte word from specified I/O port|
25
-
|[_kbhit](../c-runtime-library/reference/kbhit.md)|Check for keystroke at console; use before attempting to read from console|
26
-
|[_outp](../c-runtime-library/outp-outpw-outpd.md)|Write one byte to specified I/O port|
27
-
|[_outpd](../c-runtime-library/outp-outpw-outpd.md)|Write double word to specified I/O port|
28
-
|[_outpw](../c-runtime-library/outp-outpw-outpd.md)|Write word to specified I/O port|
29
-
|[_putch, _putwch](../c-runtime-library/reference/putch-putwch.md)|Write character to console|
30
-
|[_ungetch, _ungetwch](../c-runtime-library/reference/ungetch-ungetwch-ungetch-nolock-ungetwch-nolock.md)|"Unget" last character read from console so it becomes next character read|
15
+
|[`_cgets`, `_cgetws`](../c-runtime-library/cgets-cgetws.md), [`_cgets_s`, `_cgetws_s`](../c-runtime-library/reference/cgets-s-cgetws-s.md)|Read string from console|
16
+
|[`_cprintf`, `_cwprintf`](../c-runtime-library/reference/cprintf-cprintf-l-cwprintf-cwprintf-l.md), [`_cprintf_s`, `_cprintf_s_l`, `_cwprintf_s`, `_cwprintf_s_l`](../c-runtime-library/reference/cprintf-s-cprintf-s-l-cwprintf-s-cwprintf-s-l.md)|Write formatted data to console|
17
+
|[`_cputs`](../c-runtime-library/reference/cputs-cputws.md)|Write string to console|
18
+
|[`_cscanf`, `_cwscanf`](../c-runtime-library/reference/cscanf-cscanf-l-cwscanf-cwscanf-l.md), [`_cscanf_s`, `_cscanf_s_l`, `_cwscanf_s`, `_cwscanf_s_l`](../c-runtime-library/reference/cscanf-s-cscanf-s-l-cwscanf-s-cwscanf-s-l.md)|Read formatted data from console|
19
+
|[`_getch`, `_getwch`](../c-runtime-library/reference/getch-getwch.md)|Read character from console|
20
+
|[`_getche`, `_getwche`](../c-runtime-library/reference/getch-getwch.md)|Read character from console and echo it|
21
+
|[`_inp`](../c-runtime-library/inp-inpw-inpd.md)|Read one byte from specified I/O port|
22
+
|[`_inpd`](../c-runtime-library/inp-inpw-inpd.md)|Read double word from specified I/O port|
23
+
|[`_inpw`](../c-runtime-library/inp-inpw-inpd.md)|Read 2-byte word from specified I/O port|
24
+
|[`_kbhit`](../c-runtime-library/reference/kbhit.md)|Check for keystroke at console; use before attempting to read from console|
25
+
|[`_outp`](../c-runtime-library/outp-outpw-outpd.md)|Write one byte to specified I/O port|
26
+
|[`_outpd`](../c-runtime-library/outp-outpw-outpd.md)|Write double word to specified I/O port|
27
+
|[`_outpw`](../c-runtime-library/outp-outpw-outpd.md)|Write word to specified I/O port|
28
+
|[`_putch`, `_putwch`](../c-runtime-library/reference/putch-putwch.md)|Write character to console|
29
+
|[`_ungetch`, `_ungetwch`](../c-runtime-library/reference/ungetch-ungetwch-ungetch-nolock-ungetwch-nolock.md)|"Unget" last character read from console so it becomes next character read|
31
30
32
31
## See also
33
32
34
-
[Input and Output](../c-runtime-library/input-and-output.md)<br/>
35
-
[Universal C runtime routines by category](../c-runtime-library/run-time-routines-by-category.md)<br/>
33
+
[Input and Output](../c-runtime-library/input-and-output.md)\
34
+
[Universal C runtime routines by category](../c-runtime-library/run-time-routines-by-category.md)
0 commit comments