Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Linq-To-XML Style of Node Creation for C++

, 7 Jun 2012
Linq-To-XML Node Creation for Native C++
elmax-84498.zip
BuildProcessTemplates
ElmaxNet
Properties
Elmax
Elmax.vcxproj.user
StringUtils
TestNativeElmax
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax
Properties
TestNetElmax.csproj.user
TryoutNet
Properties
Settings.settings
Tryout
res
Tryout.ico
Tryout.vcxproj.user
elmax-ver083.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
elmax-ver084.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
elmax-ver085.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
elmax-ver086.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
elmax-ver087.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
Elmax-ver089.zip
Elmax-ver089
Elmax.vsmdi
Elmax
Elmax.vcxproj.user
StringUtils
ElmaxNet
Properties
Local.testsettings
TestNativeElmax
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax
Properties
TestNetElmax.csproj.user
TraceAndTestImpact.testsettings
Tryout
res
Tryout.ico
Tryout.vcxproj.user
TryoutNet
Properties
Settings.settings
ElmaxSrcVer082.zip
Elmax.vcxproj.user
app.ico
TestNativeElmax.vcxproj.user
TestNetElmax.csproj.user
Settings.settings
Tryout.ico
Tryout.vcxproj.user
#pragma once

namespace Elmax
{
//! Simple rudimentary datetime class, the 'DateTime' is reserved name in VS2010, so have to rename to DateAndTime
//! Feel free to modify to your needs
//! Note: Regex is not used to validate the date string in SetString method
//! because regex could take a long time building the regex tree in
//! constructor if user instantiate many of this class.
class DateAndTime
{
public:
	//! Default constructor
	DateAndTime(void);
	//! Non-default constructor
	DateAndTime(short year, short month, short day, short hour, short minute, short second);
	//! Destructor
	~DateAndTime(void);

	void SetYear(short year) { m_nYear = year; }
	void SetMonth(short month) { m_nMonth = month; }
	void SetMonthDay(short day) { m_nMonthDay = day; }
	void SetHour(short hour) { m_nHour = hour; }
	void SetMinute(short minute) { m_nMinute = minute; }
	void SetSecond(short second) { m_nSecond = second; }

	short GetYear() { return m_nYear; }
	short GetMonth() { return m_nMonth; }
	short GetMonthDay() { return m_nMonthDay; }
	short GetHour() { return m_nHour; }
	short GetMinute() { return m_nMinute; }
	short GetSecond() { return m_nSecond; }

	//! Set date and time, throws std::exception when date or time is invalid
	bool SetDateTime(short year, short month, short day, short hour, short minute, short second);

	//! Set date and time, throws std::exception when strDateTime is invalid date string
	void SetString(const std::wstring& strDateTime);

	//! Get the DateTime string eg, "2010-10-01 23:00:00"
	std::wstring GetString() const;

private:
	short m_nYear; 
	short m_nMonth; // [1 - 12]
	short m_nMonthDay; // [1 - 31]
	short m_nHour; // [0 - 23]
	short m_nMinute; // [0 - 59]
	short m_nSecond; // [0 - 59]

};

} // ns Elmax

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.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

About the Author

SV Wong
Software Developer
Singapore Singapore

Currently into areas like 3D graphics and application security. Hoping to revisit the cryptography and design pattern topics if time permits.


| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 7 Jun 2012
Article Copyright 2011 by SV Wong
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid