C++中CTime的头文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C++中CTime的头文件相关的知识,希望对你有一定的参考价值。
我在用CTime::GetCurrentTime()的时候系统说undeclared identifier,应该是没有引入相应的头文件所致,请问那头文件是什么?
#include <afx.h>CTime
CTime does not have a base class.
A CTime object represents an absolute time and date. The CTime class incorporates the ANSI time_t data type and its associated run-time functions, including the ability to convert to and from a Gregorian date and 24-hour time.
CTime values are based on coordinated universal time (UTC), which is equivalent to Greenwich mean time (GMT). The local time zone is controlled by the TZ environment variable.
When creating a CTime, set the nDST parameter to 0 to indicate that standard time is in effect, or to a value greater than 0 to indicate that daylight savings time is in effect, or to a value less than zero to have the C run-time library code compute whether standard time or daylight savings time is in effect. tm_isdst is a required field. If not set, its value is undefined and the return value frommktime is unpredictable. If timeptr points to a tm structure returned by a previous call to asctime, gmtime, or localtime, the tm_isdst field contains the correct value.
See the Run-Time Library Reference for more information on the time_t data type and the run-time functions that are used by CTime.
A companion class, CTimeSpan, represents a time interval — the difference between two CTime objects.
The CTime and CTimeSpan classes are not designed for derivation. Because there are no virtual functions, the size of CTime and CTimeSpan objects is exactly 4 bytes. Most member functions are inline.
For more information on using CTime, see the articleDate and Time in Visual C++ Programmer’s Guide andTime Management in the Run-Time Library Reference.
#include <afx.h>
Class Members | Hierarchy Chart
See Also Run-time functions:asctime,_ftime,gmtime,localtime,strftime,time
--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources. 参考技术A CTime Constructs CTime objects in various ways.
GetCurrentTime Creates a CTime object that represents the current time (static member function).
Extraction GetTime Returns a time_t that corresponds to this CTime object.
GetYear Returns the year that this CTime object represents.
GetMonth Returns the month that this CTime object represents (1 through 12).
GetDay Returns the day that this CTime object represents (1 through 31).
GetHour Returns the hour that this CTime object represents (0 through 23).
GetMinute Returns the minute that this CTime object represents (0 through 59).
GetSecond Returns the second that this CTime object represents (0 through 59).
GetDayOfWeek Returns the day of the week (1 for Sunday, 2 for Monday, and so forth).
Conversion GetGmtTm Breaks down a CTime object into components — based on UTC.
GetLocalTm Breaks down a CTime object into components — based on the local time zone.
GetAsSystemTime Converts the time information stored in the CTime object to a Win32-compatibleSYSTEMTIME structure
Format Converts a CTime object into a formatted string — based on the local time zone.
FormatGmt Converts a CTime object into a formatted string — based on UTC.
Operators operator = Assigns new time values.
operator + – Add and subtract CTimeSpan and CTime objects.
operator +=, –= Add and subtract a CTimeSpan object to and from this CTime object.
operator ==, < , etc. Compare two absolute times.
Archive/Dump operator << Outputs a CTime object to CArchive or CDumpContext.
operator >> Inputs a CTime object from CArchive. 参考技术B 加 #include <Windows.h>语句,GetCurrentTime()是Win32的API函数 参考技术C atltime.h
以上是关于C++中CTime的头文件的主要内容,如果未能解决你的问题,请参考以下文章