M
Markus Freitag
Guest
Hello,
I have a console application and want to format the time with daylight
saving time.
- Problem: +1 instead +2
- Why does string formatting not work?
I have no MFC application, then the string does not work?
How I can solve it?
/ ------------------
// My code
#include "pch.h"
#include <iostream>
#include "DateHelper.h"
#include "atlstr.h"
CString GetTimeZoneDifference()
{
TIME_ZONE_INFORMATION TimeZoneInfo;
GetTimeZoneInformation(&TimeZoneInfo);
CString strTimeZoneDifference2;
int testValue = 2;
strTimeZoneDifference2.Format(_T("%d", testValue));
printf("%d", testValue);
CString strTimeZoneDifference;
strTimeZoneDifference.Format(_T("%+03d:00", -1 * TimeZoneInfo.Bias
/ 60)); // -1* da Bias add to local time
printf("%+03d:00", -1 * TimeZoneInfo.Bias / 60);
return strTimeZoneDifference;
}
int main()
{
std::cout << "Hello World!\n";
//COleDateTime time = COleDateTime::GetCurrentTime();
CDateHelper time = CDateHelper::GetCurrentTime();
CString strTimeBoard = time.Format("%Y-%m-%dT%H:%M:%S.00") +
GetTimeZoneDifference();
}
//h
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ATLComTime.h"
class CDateHelper : public COleDateTime
{
public:
CDateHelper();
CDateHelper(DATE);
CDateHelper(const COleDateTime&);
CDateHelper(int iYear, int iMonth, int iDay,
int iHour = 0, int iMinute = 0, int iSecond = 0);
CDateHelper(const CString&);
virtual ~CDateHelper() {}
const CDateHelper& operator=(COleDateTime dtSrc)
{
m_dt = dtSrc.m_dt;
return *this;
}
}
// CPP
CDateHelper::CDateHelper()
{
SetStatus(COleDateTime::null);
}
CDateHelper::CDateHelper(const COleDateTime& date)
: COleDateTime(date)
{}
CDateHelper::CDateHelper(DATE date)
: COleDateTime(date)
{}
CDateHelper::CDateHelper(int iYear, int iMonth, int iDay, int iHour, int
iMinute, int iSecond)
: COleDateTime(iYear, iMonth, iDay, iHour, iMinute, iSecond)
{}
CDateHelper::CDateHelper(const CString& str)
{
}
Regards Markus
Continue reading...
I have a console application and want to format the time with daylight
saving time.
- Problem: +1 instead +2
- Why does string formatting not work?
I have no MFC application, then the string does not work?
How I can solve it?
/ ------------------
// My code
#include "pch.h"
#include <iostream>
#include "DateHelper.h"
#include "atlstr.h"
CString GetTimeZoneDifference()
{
TIME_ZONE_INFORMATION TimeZoneInfo;
GetTimeZoneInformation(&TimeZoneInfo);
CString strTimeZoneDifference2;
int testValue = 2;
strTimeZoneDifference2.Format(_T("%d", testValue));
printf("%d", testValue);
CString strTimeZoneDifference;
strTimeZoneDifference.Format(_T("%+03d:00", -1 * TimeZoneInfo.Bias
/ 60)); // -1* da Bias add to local time
printf("%+03d:00", -1 * TimeZoneInfo.Bias / 60);
return strTimeZoneDifference;
}
int main()
{
std::cout << "Hello World!\n";
//COleDateTime time = COleDateTime::GetCurrentTime();
CDateHelper time = CDateHelper::GetCurrentTime();
CString strTimeBoard = time.Format("%Y-%m-%dT%H:%M:%S.00") +
GetTimeZoneDifference();
}
//h
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ATLComTime.h"
class CDateHelper : public COleDateTime
{
public:
CDateHelper();
CDateHelper(DATE);
CDateHelper(const COleDateTime&);
CDateHelper(int iYear, int iMonth, int iDay,
int iHour = 0, int iMinute = 0, int iSecond = 0);
CDateHelper(const CString&);
virtual ~CDateHelper() {}
const CDateHelper& operator=(COleDateTime dtSrc)
{
m_dt = dtSrc.m_dt;
return *this;
}
}
// CPP
CDateHelper::CDateHelper()
{
SetStatus(COleDateTime::null);
}
CDateHelper::CDateHelper(const COleDateTime& date)
: COleDateTime(date)
{}
CDateHelper::CDateHelper(DATE date)
: COleDateTime(date)
{}
CDateHelper::CDateHelper(int iYear, int iMonth, int iDay, int iHour, int
iMinute, int iSecond)
: COleDateTime(iYear, iMonth, iDay, iHour, iMinute, iSecond)
{}
CDateHelper::CDateHelper(const CString& str)
{
}
Regards Markus
Continue reading...