description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: CFileTime class |
CFileTime class |
10/18/2018 |
|
|
1a358a65-1383-4124-b0d4-59b026e6860f |
This class provides methods for managing the date and time values associated with a file.
class CFileTime : public FILETIME
Name | Description |
---|---|
CFileTime::CFileTime |
The constructor. |
Name | Description |
---|---|
CFileTime::GetCurrentTime |
Call this static function to retrieve a CFileTime object that represents the current system date and time. |
CFileTime::GetTime |
Call this method to retrieve the time from the CFileTime object. |
CFileTime::LocalToUTC |
Call this method to convert a local file time to a file time based on the Coordinated Universal Time (UTC). |
CFileTime::SetTime |
Call this method to set the date and time stored by the CFileTime object. |
CFileTime::UTCToLocal |
Call this method to convert time based on the Coordinated Universal Time (UTC) to local file time. |
Name | Description |
---|---|
CFileTime::operator - |
This operator is used to perform subtraction on a CFileTime or CFileTimeSpan object. |
CFileTime::operator != |
This operator compares two CFileTime objects for inequality. |
CFileTime::operator + |
This operator is used to perform addition on a CFileTimeSpan object. |
CFileTime::operator += |
This operator is used to perform addition on a CFileTimeSpan object and assign the result to the current object. |
CFileTime::operator < |
This operator compares two CFileTime objects to determine the lesser. |
CFileTime::operator <= |
This operator compares two CFileTime objects to determine equality or the lesser. |
CFileTime::operator = |
The assignment operator. |
CFileTime::operator -= |
This operator is used to perform subtraction on a CFileTimeSpan object and assign the result to the current object. |
CFileTime::operator == |
This operator compares two CFileTime objects for equality. |
CFileTime::operator > |
This operator compares two CFileTime objects to determine the larger. |
CFileTime::operator >= |
This operator compares two CFileTime objects to determine equality or the larger. |
Name | Description |
---|---|
CFileTime::Day |
A static data member storing the number of 100-nanosecond intervals that make up one day. |
CFileTime::Hour |
A static data member storing the number of 100-nanosecond intervals that make up one hour. |
CFileTime::Millisecond |
A static data member storing the number of 100-nanosecond intervals that make up one millisecond. |
CFileTime::Minute |
A static data member storing the number of 100-nanosecond intervals that make up one minute. |
CFileTime::Second |
A static data member storing the number of 100-nanosecond intervals that make up one second. |
CFileTime::Week |
A static data member storing the number of 100-nanosecond intervals that make up one week. |
This class provides methods for managing the date and time values associated with the creation, access, and modification of files. The methods and data of this class are frequently used together with CFileTimeSpan
objects, which deal with relative time values.
The date and time value is stored as a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601. This format is the Coordinated Universal Time (UTC) format.
The following static const member variables are provided to simplify calculations:
Member variable | Number of 100-nanosecond intervals |
---|---|
Millisecond | 10,000 |
Second | Millisecond * 1,000 |
Minute | Second * 60 |
Hour | Minute * 60 |
Day | Hour * 24 |
Week | Day * 7 |
Note
Not all file systems can record creation and last access time and not all file systems record them in the same manner. For example, on the Windows NT FAT file system, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (the access date). On NTFS, access time has a resolution of 1 hour. Furthermore, FAT records times on disk in local time, but NTFS records times on disk in UTC. For more information, see File times.
Header: atltime.h
The constructor.
CFileTime() throw();
CFileTime(const FILETIME& ft) throw();
CFileTime(ULONGLONG nTime) throw();
ft
A FILETIME
structure.
nTime
The date and time expressed as a 64-bit value.
The CFileTime
object can be created using an existing date and time from a FILETIME
structure, or expressed as a 64-bit value (in local or Coordinated Universal Time (UTC) time formats). The default constructor sets the time to 0.
A static data member storing the number of 100-nanosecond intervals that make up one day.
static const ULONGLONG Day = Hour* 24;
See the example for CFileTime::Millisecond
.
Call this static function to retrieve a CFileTime
object that represents the current system date and time.
static CFileTime GetCurrentTime() throw();
Returns the current system date and time in Coordinated Universal Time (UTC) format.
[!code-cppNVC_MFCFiles#41]
Call this method to retrieve the time from the CFileTime
object.
ULONGLONG GetTime() const throw();
Returns the date and time as a 64-bit number, which may be in either local or Coordinated Universal Time (UTC) format.
A static data member storing the number of 100-nanosecond intervals that make up one hour.
static const ULONGLONG Hour = Minute* 60;
See the example for CFileTime::Millisecond
.
Call this method to convert a local file time to a file time based on the Coordinated Universal Time (UTC).
CFileTime LocalToUTC() const throw();
Returns a CFileTime
object containing the time in UTC format.
See the example for CFileTime::UTCToLocal
.
A static data member storing the number of 100-nanosecond intervals that make up one millisecond.
static const ULONGLONG Millisecond = 10000;
[!code-cppNVC_MFCFiles#44]
A static data member storing the number of 100-nanosecond intervals that make up one minute.
static const ULONGLONG Minute = Second* 60;
See the example for CFileTime::Millisecond
.
This operator is used to perform subtraction on a CFileTime
or CFileTimeSpan
object.
CFileTime operator-(CFileTimeSpan span) const throw();
CFileTimeSpan operator-(CFileTime ft) const throw();
span
A CFileTimeSpan
object.
ft
A CFileTime
object.
Returns a CFileTime
object or a CFileTimeSpan
object representing the result of the time difference between the two objects.
This operator compares two CFileTime
objects for inequality.
bool operator!=(CFileTime ft) const throw();
ft
The CFileTime
object to be compared.
Returns TRUE
if the item being compared isn't equal to the CFileTime
object, otherwise FALSE
.
This operator is used to perform addition on a CFileTimeSpan
object.
CFileTime operator+(CFileTimeSpan span) const throw();
span
A CFileTimeSpan
object.
Returns a CFileTime
object representing the result of the original time plus a relative time.
This operator is used to perform addition on a CFileTimeSpan
object and assign the result to the current object.
CFileTime& operator+=(CFileTimeSpan span) throw();
span
A CFileTimeSpan
object.
Returns the updated CFileTime
object, representing the result of the original time plus a relative time.
This operator compares two CFileTime
objects to determine the lesser.
bool operator<(CFileTime ft) const throw();
ft
The CFileTime
object to be compared.
Returns TRUE
if the first object is less (earlier in time) than the second, FALSE
otherwise.
[!code-cppNVC_MFCFiles#43]
This operator compares two CFileTime
objects to determine equality or the lesser.
bool operator<=(CFileTime ft) const throw();
ft
The CFileTime
object to be compared.
Returns TRUE
if the first object is less than (earlier in time) or equal to the second, otherwise FALSE
.
The assignment operator.
CFileTime& operator=(const FILETIME& ft) throw();
ft
A CFileTime
object containing the new time and date.
Returns the updated CFileTime
object.
This operator is used to perform subtraction on a CFileTimeSpan
object and assign the result to the current object.
CFileTime& operator-=(CFileTimeSpan span) throw();
span
A CFileTimeSpan
object containing the relative time to subtract.
Returns the updated CFileTime
object.
This operator compares two CFileTime
objects for equality.
bool operator==(CFileTime ft) const throw();
ft
The CFileTime
object to compare.
Returns TRUE
if the objects are equal, otherwise FALSE
.
This operator compares two CFileTime
objects to determine the larger.
bool operator>(CFileTime ft) const throw();
ft
The CFileTime
object to be compared.
Returns TRUE
if the first object is greater than (later in time) than the second, otherwise FALSE
.
This operator compares two CFileTime
objects to determine equality or the larger.
bool operator>=(CFileTime ft) const throw();
ft
The CFileTime
object to be compared.
Returns TRUE
if the first object is greater than (later in time) or equal to the second, otherwise FALSE
.
A static data member storing the number of 100-nanosecond intervals that make up one day.
static const ULONGLONG Second = Millisecond* 1000;
See the example for CFileTime::Millisecond
.
Call this method to set the date and time stored by the CFileTime
object.
void SetTime(ULONGLONG nTime) throw();
nTime
The 64-bit value representing the date and time, in either local or Coordinated Universal Time (UTC) format.
Call this method to convert time based on the Coordinated Universal Time (UTC) to local file time.
CFileTime UTCToLocal() const throw();
Returns a CFileTime
object containing the time in local file time format.
[!code-cppNVC_MFCFiles#42]
A static data member storing the number of 100-nanosecond intervals that make up one week.
static const ULONGLONG Week = Day* 7;
See the example for CFileTime::Millisecond
.
FILETIME
CFileTimeSpan
class
Hierarchy chart
ATL/MFC shared classes