1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00
Files
winscp/libs/mfc/source/timecore.cpp
Martin Prikryl 693f5da37c Removing CFileException MFC class
Originally because it seemed that it was causing problems with 64-bit build, which wasn't true in the end. But it's a good move anyway.

Source commit: 2d2d341d8e98f31692c1beca8445899e289ee0cb
2026-04-18 01:11:47 +02:00

74 lines
1.9 KiB
C++

// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include "stdafx.h"
/////////////////////////////////////////////////////////////////////////////
// CTime - absolute time
CTime::CTime(const SYSTEMTIME& sysTime)
{
if (sysTime.wYear < 1900)
{
time_t time0 = 0L;
CTime timeT(time0);
*this = timeT;
}
else
{
struct tm atm;
atm.tm_sec = (int)sysTime.wSecond;
atm.tm_min = (int)sysTime.wMinute;
atm.tm_hour = (int)sysTime.wHour;
int nDay = (int)sysTime.wDay;
ASSERT(nDay >= 1 && nDay <= 31);
atm.tm_mday = nDay;
int nMonth = (int)sysTime.wMonth;
ASSERT(nMonth >= 1 && nMonth <= 12);
atm.tm_mon = nMonth - 1; // tm_mon is 0 based
ASSERT(nYear >= 1900);
atm.tm_year = (int)sysTime.wYear - 1900; // tm_year is 1900 based
atm.tm_isdst = -1;
m_time = mktime(&atm);
ASSERT(m_time != -1); // indicates an illegal input time
}
}
CTime::CTime(const FILETIME& fileTime)
{
// first convert file time (UTC time) to local time
FILETIME localTime;
if (!FileTimeToLocalFileTime(&fileTime, &localTime))
{
m_time = 0;
return;
}
// then convert that time to system time
SYSTEMTIME sysTime;
if (!FileTimeToSystemTime(&localTime, &sysTime))
{
m_time = 0;
return;
}
// then convert the system time to a time_t (C-runtime local time)
CTime timeT(sysTime);
*this = timeT;
}
CTime CTime::CreateForCurrentTime()
// return the current system time
{
return CTime(::time(NULL));
}
/////////////////////////////////////////////////////////////////////////////