CTime.Format funzt nicht
-
Huhu
Hab mir gestern VC ebedded für WinCE programming runtergeladen. Problem: Wenn ich irgendwie die Uhrzeit formatieren will, macht er das nicht. Er sagt mir, dass Format kein Element von CTime ist, zeigt es aber an, wenn ich CTime. schreibe. Im Visual Studio macht er das ohne probs, ok, ich hab hier natürlich einschränkungen, klar, aber wenn er das Elemtn anzeigt, sollte er das doch auch eigentlich haben, oder?
Ich will nur irgendwie die Uhrzeit formatiert haben, mehr nicht
-
Quelle: http://msdn.microsoft.com/library/en-us/wcemfc/htm/ctime.asp
MFC for Windows CE does not support the following methods of the CTime class:
* GetGmtTm
* Format
* FormatGmt
-
jo, alles klar
thx für den link
jetzt weiß ich auch, wo ich was für CE nachschauen kann
-
hallo
ich hab mich nochmal an der Formatierung versucht, is aber fehlgeschlagen. hab mal unter dem link geschaut und mir die methoden mal angeschaut
ich kann da ja auch mit time_t einen long double ausgeben lassen. das funzt auch, aber wie rechne ich das jetzt dementsprechend um? also ich brauche den wert im string format
-
#include <time.h>
struct tm *newtime;
time_t long_time;
time( &long_time ); /* Get time as long integer. /
newtime = localtime( &long_time ); / Convert to local time. */
pDateTime =asctime( newtime );
-
pDateTime ist string, du kannst damit spielen wie du willst....schneiden und pasteln.
-
hmm,
ich krieg da 5 fehler die folgend lauten:
error C2065: 'time' : undeclared identifier
error C2065: 'localtime' : undeclared identifier
error C2440: '=' : cannot convert from 'int' to 'struct tm *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
error C2065: 'pDateTime' : undeclared identifier
error C2065: 'asctime' : undeclared identifier
-
string pDateTime=""; string aktuelledate=""; string jahr=""; string monat=""; string tag=""; string stunde=""; string joker=""; int z=0; int zz=0; int anzahl=0; int anzahlstund=0; struct tm *newtime; time_t long_time; time( &long_time ); /* Get time as long integer. */ newtime = localtime( &long_time ); /* Convert to local time. */ pDateTime =asctime( newtime );
vergiss nicht den Header #include <time.h>
Bei mir kommt die Reihnfolge.
#include "stdafx.h" #include <afxwin.h> #include <afxinet.h> #include <stdio.h> #include <direct.h> #include <time.h>
weiss nicht ob das was macht . du musst mal probieren
-
hmm, neee, nicht wirklich
bei mir fängt er schon bei 'string' an zu meckern
muss da nen CString draus machen
-
# include string hast du ja schon oder
-
# include <string>
-
mein gott diese Tastatur
# include <string>
-
ja, hab ich gemacht, bringt aber leider nüx
ich poste dir mal den code
//Header
// WeckerDlg.h : header file // #if !defined(AFX_WECKERDLG_H__1CFD6397_C343_4D85_94CB_F6AF07D02B5C__INCLUDED_) #define AFX_WECKERDLG_H__1CFD6397_C343_4D85_94CB_F6AF07D02B5C__INCLUDED_ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 #include "stdafx.h" #include <afxwin.h> #include <afxinet.h> #include <stdio.h> //#include <direct.h> #include <time.h> #include <string.h> ///////////////////////////////////////////////////////////////////////////// // CWeckerDlg dialog class CWeckerDlg : public CDialog { // Construction public: CWeckerDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(CWeckerDlg) enum { IDD = IDD_WECKER_DIALOG }; // NOTE: the ClassWizard will add data members here //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CWeckerDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: HICON m_hIcon; // Generated message map functions //{{AFX_MSG(CWeckerDlg) virtual BOOL OnInitDialog(); afx_msg void OnButton1(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_WECKERDLG_H__1CFD6397_C343_4D85_94CB_F6AF07D02B5C__INCLUDED_)
//CPP
// WeckerDlg.cpp : implementation file // #include "stdafx.h" #include "Wecker.h" #include "WeckerDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CWeckerDlg dialog CWeckerDlg::CWeckerDlg(CWnd* pParent /*=NULL*/) : CDialog(CWeckerDlg::IDD, pParent) { //{{AFX_DATA_INIT(CWeckerDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CWeckerDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CWeckerDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CWeckerDlg, CDialog) //{{AFX_MSG_MAP(CWeckerDlg) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CWeckerDlg message handlers BOOL CWeckerDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon CenterWindow(GetDesktopWindow()); // center to the hpc screen // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } void CWeckerDlg::OnButton1() { // TODO: Add your control notification handler code here /*CString str; CTime time(NULL,NULL,NULL,12,18,0); str.Format(_T("Zeit %ld"),time); MessageBox(str); time.GetTime(); str.Format(_T("Zeit %ld"),time); MessageBox(str);*/ string pDateTime=""; string aktuelledate=""; string jahr=""; string monat=""; string tag=""; string stunde=""; string joker=""; int z=0; int zz=0; int anzahl=0; int anzahlstund=0; struct tm *newtime; time_t long_time; time( &long_time ); /* Get time as long integer. */ newtime = localtime( &long_time ); /* Convert to local time. */ pDateTime =asctime( newtime ); }
auch wenn ich nur
#include <string>
anstatt
#include <string.h>
mache funzt es net
26 errors
-
Propiermal
fast für jede Projekt gibt es auch :_# include <iostream> # include <string> using namepace atd;
-
nee, nimmt er auch net
er hat da nen prob mit dem namespace
auch std nimmt er da nicht
aber mach mal das hier
CString str; CTime time = CTime::GetCurrentTime(); str.Format(_T("%d %d %d"),time.GetHour(),time.GetMinute(),time.GetSecond()); MessageBox(str);
das funzt wunderbar
-
Und was ist jetzt nochmals Dein Problem?
-
das kenne ich auch. ich dachte CTime funktioniert nicht bei dir.
here hast du halt CString und nicht string und musst umwandeln in string.