Click here to Skip to main content
15,891,777 members
Articles / Programming Languages / Objective C

Date-Time Conversion Utility

Rate me:
Please Sign up or sign in to vote.
4.57/5 (14 votes)
21 Sep 20012 min read 234.4K   3.1K   40  
A simple app that converts to and between time_t, DATE, and regular date string expressions
// DTConverterDlg.h : header file
//

#if !defined(AFX_DTCONVERTERDLG_H__1635F2FA_9076_11D3_9134_00105A6E5DE4__INCLUDED_)
#define AFX_DTCONVERTERDLG_H__1635F2FA_9076_11D3_9134_00105A6E5DE4__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#define AUTOPASTE_NONE    0
#define AUTOPASTE_HALF    1
#define AUTOPASTE_FULL    2

#define AUTOCONV_NONE     0
#define AUTOCONV_TIMET    1
#define AUTOCONV_DATE     2
#define AUTOCONV_STRING   3
#define AUTOCONV_SPAN     4
#define AUTOCONV_TOTALSEC 5

#define OPTION_AUTOPASTE        "AutoPaste"
#define OPTION_AUTOCONVERT      "AutoConvert"
#define OPTION_FULLAUTOCONVERT  "FullAutoConvert"
#define OPTION_ALWAYSONTOP      "AlwaysOnTop"

#define OPTIONSFILE       "DTConverter.ini"

/////////////////////////////////////////////////////////////////////////////
// CDTConverterDlg dialog

class CDTConverterDlg : public CDialog
{
// Construction
public:
	CDTConverterDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	//{{AFX_DATA(CDTConverterDlg)
	enum { IDD = IDD_DTCONVERTER };
	CButton	m_btnString;
	CButton	m_btnPartsSpan;
	CButton	m_btnTimeT;
	CButton	m_btnSpan;
	CButton	m_btnOleDate;
	CButton	m_btnConvTotalSec;
	CEdit	m_edbSpan;
	CEdit	m_edbString;
	CEdit	m_edbOleDate;
	CEdit	m_edbTimeT;
	CString	m_strEditTimeT;
	CString	m_strEditOleDate;
	CString	m_strEditString;
	CString	m_strDays;
	CString	m_strHours;
	CString	m_strMinutes;
	CString	m_strSeconds;
	CString	m_strSpan;
	CString	m_strTotalSec;
	BOOL	m_bAlwaysOnTop;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CDTConverterDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;
  BOOL  m_bAutoPaste;
  int   m_iAutoPaste;   // AUTOPASTE_NONE, AUTOPASTE_HALF or AUTOPASTE_FULL
  int   m_iAutoConvert; // AUTOCONV_xxx
  BOOL  m_bAutoConvert;
  int   m_iLastPressedButton; // 1,2,3,4,5,6  (I know. I was too lazy to define enums:o)

  CString GetClipboardText();
  CString CutOffAt2ndSpace(LPCTSTR strInput);
  CString CutOffAt1stSpace(LPCTSTR strInput);
  void    ClearAllDTFields(void);
  void    ClearAllDTSFields(void);
  void    SetDefaultButton(void);
  void    SaveOptions(void);
  void    ReadOptions(void);

	// Generated message map functions
	//{{AFX_MSG(CDTConverterDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnButtonConvertTimeT();
	afx_msg void OnButtonConvertOleDate();
	afx_msg void OnButtonConvertString();
	afx_msg void OnButtonConvertSpanParts();
	afx_msg void OnButtonConvertSpan();
	afx_msg void OnButtonConvertTotalsec();
	afx_msg void OnSetfocusEditSpan();
	afx_msg void OnSetfocusEditString();
	afx_msg void OnSetfocusEditTimeT();
	afx_msg void OnSetfocusEditOleDate();
	afx_msg void OnSetfocusEditTotalsec();
	afx_msg void OnBtnOptions();
	afx_msg void OnChkAlwaysontop();
	afx_msg void OnQuit();
	//}}AFX_MSG
  afx_msg void OnActivateApp( BOOL bActive, HTASK hTask );
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DTCONVERTERDLG_H__1635F2FA_9076_11D3_9134_00105A6E5DE4__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Web Developer
United States United States
I've done extensive work with C++, MFC, COM, and ATL on the Windows side. On the Web side, I've worked with VB, ASP, JavaScript, and COM+. I've also been involved with server-side Java, which includes JSP, Servlets, and EJB, and more recently with ASP.NET/C#.

Comments and Discussions